Skip to content

Commit

Permalink
add support for pathlib objects, improve logging, fixes seb-m#187
Browse files Browse the repository at this point in the history
  • Loading branch information
fthiery committed Jul 2, 2020
1 parent 0f3f895 commit 965f672
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion python3/pyinotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -1903,9 +1903,16 @@ def add_watch(self, path, mask, proc_fun=None, rec=False,

# normalize args as list elements
for npath in self.__format_param(path):
# Require that path be a unicode string
# attempt to cast to string so that pathlib objects are supported
try:
npath = str(path)
except ValueError:
pass

# require that path be a unicode string
if not isinstance(npath, str):
ret_[path] = -3
log.error('add_watch: invalid path "%s"' % repr(path))
continue

# unix pathname pattern expansion
Expand Down

0 comments on commit 965f672

Please sign in to comment.