epics-base / p4p

Python bindings for the PVAccess network client and server.
BSD 3-Clause "New" or "Revised" License
27 stars 38 forks source link

rpccall with 0-ady functions fails #130

Open Synthetica9 opened 10 months ago

Synthetica9 commented 10 months ago

Description

@rpccall for functions that take no arguments throws an error when defining a function with no arguments.

To reproduce

Try to run the following file:

from p4p.rpc import rpcproxy, rpccall

@rpcproxy
class MyProxy(object):
    @rpccall("%s:foo")
    def foo():
        pass

Observed behaviour

This throws the following error:

$ python3 /tmp/p4p_rpcproxy_noargs.py 
Traceback (most recent call last):
  File "/tmp/p4p_rpcproxy_noargs.py", line 4, in <module>
    class MyProxy(object):
  File "/home/training/dev/epics-rpc-ads-proxy/p4ptest/lib/python3.8/site-packages/p4p/rpc.py", line 317, in rpcproxy
    obj[K] = _wrapMethod(K, V)
  File "/home/training/dev/epics-rpc-ads-proxy/p4ptest/lib/python3.8/site-packages/p4p/rpc.py", line 267, in _wrapMethod
    if len(S.args) != len(S.defaults):
TypeError: object of type 'NoneType' has no len()

Expected behaviour

Runs without error, allowing the user to access the function over PVA.

mdavidsaver commented 2 months ago

Fixed with 4f6b9e9e67293acd142cf1ce377c87da9e6ab549. Please retest with p4p==4.2.0a3.

mdavidsaver commented 2 months ago

My added tests did trigger the same error prior to this fix, so I think I have adequately addressed this issue. Confirmation would be appreciated though.