Skip to content

Commit 4131da5

Browse files
committed
check fd > 0 before os.close()
1 parent 738fdf9 commit 4131da5

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

evdev/device.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,9 @@ def __repr__(self):
211211
return '{}({!r})'.format(*msg)
212212

213213
def close(self):
214-
os.close(self.fd)
215-
self.fd = -1
214+
if self.fd > 0:
215+
os.close(self.fd)
216+
self.fd = -1
216217

217218
def fileno(self):
218219
'''

0 commit comments

Comments
 (0)