1 parent a03f389 commit e860705Copy full SHA for e860705
1 file changed
evdev/uinput.py
@@ -91,7 +91,8 @@ def __enter__(self):
91
return self
92
93
def __exit__(self, type, value, tb):
94
- self.close()
+ if hasattr(self, 'fd'):
95
+ self.close()
96
97
def __repr__(self):
98
# :todo:
@@ -111,12 +112,12 @@ def __str__(self):
111
112
return msg
113
114
def close(self):
- # close the associated InputDevice, if we managed to open it
115
+ # close the associated InputDevice, if it was previously opened
116
if self.device is not None:
117
self.device.close()
118
119
# destroy the uinput device
- if self.fd and self.fd > -1:
120
+ if self.fd > -1:
121
_uinput.close(self.fd)
122
self.fd = -1
123
0 commit comments