Skip to content

Commit

Permalink
Replace mutable default arguments with the correct implementation (#677)
Browse files Browse the repository at this point in the history
* Replace mutable default arguments with the correct implementation.
This will avoid potential sharing states problem through different instances of the EventHandler

* update changelog.rst
  • Loading branch information
Sraw committed Jul 11, 2020
1 parent e32272e commit 4bd3cfe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Changelog

2020-xx-xx • `full history <https://github.com/gorakhargosh/watchdog/compare/v0.10.3...master>`__

- Thanks to our beloved contributors: @
- Replace mutable default arguments with ``if None`` implementation (`#677 <https://github.com/gorakhargosh/watchdog/pull/677>`_)
- Thanks to our beloved contributors: @Sraw


0.10.3
Expand Down
6 changes: 5 additions & 1 deletion src/watchdog/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,14 @@ class RegexMatchingEventHandler(FileSystemEventHandler):
Matches given regexes with file paths associated with occurring events.
"""

def __init__(self, regexes=[r".*"], ignore_regexes=[],
def __init__(self, regexes=None, ignore_regexes=None,
ignore_directories=False, case_sensitive=False):
super(RegexMatchingEventHandler, self).__init__()

if regexes is None:
regexes = [r".*"]
if ignore_regexes is None:
ignore_regexes = []
if case_sensitive:
self._regexes = [re.compile(r) for r in regexes]
self._ignore_regexes = [re.compile(r) for r in ignore_regexes]
Expand Down

0 comments on commit 4bd3cfe

Please sign in to comment.