seb-m / pyinotify

Monitoring filesystems events with inotify on Linux.
http://github.com/seb-m/pyinotify/wiki
MIT License
2.29k stars 377 forks source link

ctypes.ArgumentError when tutorial_threadednotifier.py is run though seems to function normally #119

Open ghost opened 8 years ago

ghost commented 8 years ago

I was just going through the tutorials in this useful package.

machine:

Linux DX4860 3.16.0-51-generic #69~14.04.1-Ubuntu SMP Wed Oct 7 15:32:41 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

python:

Python 3.4.3

When I run python3 tutorial_threadednotifier.py I get the following even though it seems to function in terms of watching the /tmp directory:

Traceback (most recent call last):
  File "tutorial_threadednotifier.py", line 23, in <module>
    wm.rm_watch(wdd.values())
  File "/home/ubuntu/.virtualenvs/pyinotify/lib/python3.4/site-packages/pyinotify.py", line 2123, in rm_watch
    wd_ = self._inotify_wrapper.inotify_rm_watch(self._fd, awd)
  File "/home/ubuntu/.virtualenvs/pyinotify/lib/python3.4/site-packages/pyinotify.py", line 156, in inotify_rm_watch
    return self._inotify_rm_watch(fd, wd)
  File "/home/ubuntu/.virtualenvs/pyinotify/lib/python3.4/site-packages/pyinotify.py", line 252, in _inotify_rm_watch
    return self._libc.inotify_rm_watch(fd, wd)
ctypes.ArgumentError: argument 2: <class 'TypeError'>: wrong type

Creating: /tmp/virtualenvwrapper-initialize-hook-ti3ajuLNgv
Removing: /tmp/virtualenvwrapper-initialize-hook-ti3ajuLNgv
Creating: /tmp/vfZedyF
Creating: /tmp/issue.py
Removing: /tmp/vfZedyF
Creating: /tmp/sh-thd-1026113757
Removing: /tmp/sh-thd-1026113757
Creating: /tmp/test
Removing: /tmp/test
Grief commented 8 years ago

As a workaround, surround wd.values with list(): wm.rm_watch(list(wdd.values())). It seems like an issue with pyinotify's understanding that .items() is actually a list in Python3