Skip to content

Commit e87617a

Browse files
committed
Support path-like objects in InputDevice constructor
1 parent 388ce6f commit e87617a

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

docs/changelog.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ Changelog
55
Unreleased
66
====================
77

8-
- Support path protocol in ``InputDevice``.
8+
- ``InputDevice`` now accepts objects that support the path protocol. For
9+
example::
10+
11+
pth = pathlib.Path('/dev/input/event0')
12+
dev = evdev.InputDevice(pth)
13+
14+
- Support path protocol in ``InputDevice``. This means that ``InputDevice``
15+
instances can be passed to callers that expect a ``os.PathLike`` object.
916

1017
- Exceptions raised during ``InputDevice.async_read()`` (and similar) are now
1118
handled properly (i.e. an exception is set on the returned future instead of

evdev/device.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ def __init__(self, dev):
114114
'''
115115
Arguments
116116
---------
117-
dev : str
117+
dev : str|bytes|PathLike
118118
Path to input device
119119
'''
120120

121121
#: Path to input device.
122-
self.fn = dev
122+
self.fn = dev if not hasattr(dev, '__fspath__') else dev.__fspath__()
123123

124124
# Certain operations are possible only when the device is opened in
125125
# read-write mode.

0 commit comments

Comments
 (0)