Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events from non-ASCII paths raise UncodeDecodeError #516

Closed
exarkun opened this issue Jan 31, 2019 · 4 comments
Closed

Events from non-ASCII paths raise UncodeDecodeError #516

exarkun opened this issue Jan 31, 2019 · 4 comments

Comments

@exarkun
Copy link
Contributor

exarkun commented Jan 31, 2019

from os import mkdir
from watchdog.observers.inotify import InotifyObserver
from watchdog.events import FileSystemEventHandler

class H(FileSystemEventHandler):
    def on_any_event(self, event):
        print(event)

def main():
    d = u"demo"
    handler = H()

    mkdir(d)
    obs = InotifyObserver()
    obs.schedule(handler, d, recursive=True)
    obs.start()
    mkdir(u"/".join((d, u"\N{SNOWMAN}")))
    obs.join()

main()

results in this exception

Exception in thread Thread-3:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "watchdog/src/watchdog/observers/inotify_buffer.py", line 87, in run
    inotify_events = self._inotify.read_events()
  File "watchdog/src/watchdog/observers/inotify_c.py", line 324, in read_events
    inotify_event = InotifyEvent(wd, mask, cookie, name, src_path)
  File "watchdog/src/watchdog/observers/inotify_c.py", line 478, in __init__
    self._name = name.decode()
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 0: ordinal not in range(128)

Apparently introduced in 0c5e353

@BoboTiG
Copy link
Collaborator

BoboTiG commented Jan 31, 2019

Python 2 is no more supported. Do you reproduce the error on Python 3?

@exarkun
Copy link
Contributor Author

exarkun commented Jan 31, 2019

Python 2 is no more supported. Do you reproduce the error on Python 3?

That's quite disappointing and frustrating to discover, considering the README:

Works on Python 2.7 and 3.4+. If you want to use an old version of Python, you should stick with watchdog < 0.10.0.

My project is a large Python 2 code base and there's zero chance I will be using Python 3 with it in the next year (maybe slightly higher than zero chance after that). It's 70kloc of messy code with un-ported dependencies.

Is there no way the watchdog project can continue to support Python 2 at least until python-dev abandons it? (And note that even after python-dev abandons Python 2, there's still PyPy.)

If you're dead set on dropping Python 2 then as a huge favor to your users, I suggest changing the README to stop advertising Python 2.7 support.

@BoboTiG
Copy link
Collaborator

BoboTiG commented Jan 31, 2019

Ooops sorry ! I said bullshit: Python 2.7 is still supported. I dropped support on another project and mixed my brain :/

For the bug, it would be great if you can have a look for a PR (including a simple test).

@exarkun
Copy link
Contributor Author

exarkun commented Jan 31, 2019

Okay, thanks! I'll see about putting together a PR tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants