python3-netsnmp
python3-netsnmp copied to clipboard
Trying to use any value in a Varbind results in an exception being thrown when attempting to set
Reproduction:
>>> import netsnmp
>>> session = netsnmp.Session(Version = 2, DestHost='localhost', Community='public')
>>> vbind = netsnmp.Varbind('sysUpTime', 0, 1, 'INTEGER')
>>> session.set(netsnmp.VarList(vbind))
TypeError: expected bytes, int found
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib64/python3.6/site-packages/netsnmp/client.py", line 205, in set
res = client_intf.set(self, varlist)
SystemError: <built-in function set> returned a result with an error set
Even when using a bytes
object, it throws a different exception.
Issue seems to be from this call here: https://github.com/bluecmd/python3-netsnmp/blob/9f51ee26b3f70ddca9f35116ae53a08c16bb6b8f/netsnmp/client_intf.c#L1047 As per the Python 3 documentation here:
If obj is not a bytes object at all, PyBytes_AsStringAndSize() returns -1 and raises TypeError.
This makes the library completely unusable if you ever need to try and set a value
@repnop - I'm stuck with the exact same problem. Can you point me to what ended up working for you?
@shameersirajuddin oh jeez, its been a long time since I last dealt with this. I want to say I may have ended up modifying the source to get it to work -- I'll try and find out at some point but feel free to ping me after a while if I don't respond