diff --git a/python2/pyinotify.py b/python2/pyinotify.py index d2f0816..fa9d9b0 100755 --- a/python2/pyinotify.py +++ b/python2/pyinotify.py @@ -1979,7 +1979,8 @@ def __get_sub_rec(self, lpath): root = os.path.normpath(root) # recursion lend = len(root) - for iwd in self._wmd.items(): + wmd = self._wmd.copy().items() + for iwd in wmd: cur = iwd[1].path pref = os.path.commonprefix([root, cur]) if root == os.sep or (len(pref) == lend and \ diff --git a/python3/pyinotify.py b/python3/pyinotify.py index bc24313..cc3aa6e 100755 --- a/python3/pyinotify.py +++ b/python3/pyinotify.py @@ -1958,7 +1958,8 @@ def __get_sub_rec(self, lpath): root = os.path.normpath(root) # recursion lend = len(root) - for iwd in self._wmd.items(): + wmd = self._wmd.copy().items() + for iwd in wmd: cur = iwd[1].path pref = os.path.commonprefix([root, cur]) if root == os.sep or (len(pref) == lend and \