Closed tlalexander closed 4 years ago
Hi, great find. I personally never worked with that particular error, but it seems that you understood it better than I did when I played a bit around with it.
I would suggest that you go ahead and push the fix. Would be nice if you could also fix the other lines with os.strerror() there.
Would be interesting to know what it is that way @gvalkov. Is that something historic that worked in python at some time? My guess would be that it might've been possible in python2 to get the last error value and use it without specifying explicitly. But that doesn't seem to be the case.
Python 2.7.18 (default, Sep 5 2020, 11:17:26)
[GCC 10.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> open('/etc/passwd', 'w')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 13] Permission denied: '/etc/passwd'
>>> os.strerror()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: strerror() takes exactly 1 argument (0 given)
Okay I will work on a PR. ☺️
Hi @LinusCDE . It seems like os.strerror()
always took a non-optional argument (just checked with Python 2.4). It's just something I overlooked.
I am trying to create a custom force feedback device.
Something isn't working right, and so input tries to throw an error with this line: https://github.com/gvalkov/python-evdev/blob/862c4111e6adfe316d2d1c8222507f41f9d1e75e/evdev/uinput.py#L246
Except that line seems to have a bug. Instead of throwing UInputError it throws:
TypeError: strerror() takes exactly one argument (0 given)
It looks like the return code from line 245 needs to be stored. So instead of:
You might want:
Or am I missing something? If it is an error and I can help with a pull request please let me know!