You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
agents/sysfsgpio: fix misleading Python error when permission denied
If the executor doesn't have the proper permissions to control the GPIO
or export it, a Permission Denied will be raised. However, __del__ is
called regardless and gpio_sysfs_value_fd attribute isn't present if the
__init__ doesn't finish.
Thus, Python prints the following:
"""
Exception ignored in: <function GpioDigitalOutput.__del__ at 0x7f5b017f80e0>
Traceback (most recent call last):
File "<loaded sysfsgpio>", line 44, in __del__
AttributeError: 'GpioDigitalOutput' object has no attribute 'gpio_sysfs_value_fd'
""" before the raised Exception, possibly misleading the user on their
debugging quest.
Therefore, let's make sure the attribute exists before anything can
throw an Exception in __init__.
os.close() can only be called on a valid file descriptor, which None
isn't, therefore only call os.close() if self.gpio_sysfs_value_fd is not
None.
Signed-off-by: Quentin Schulz <[email protected]>
0 commit comments