diff --git a/CHANGES.rst b/CHANGES.rst index b3fc39b27..05e5acf29 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,8 @@ Version 3.0.3 Unreleased +- Make reloader more robust when ``""`` is in ``sys.path``. :pr:`2823` + Version 3.0.2 ------------- diff --git a/src/werkzeug/_reloader.py b/src/werkzeug/_reloader.py index 24c2dab79..d7e91a61c 100644 --- a/src/werkzeug/_reloader.py +++ b/src/werkzeug/_reloader.py @@ -157,7 +157,9 @@ def _walk(node: t.Mapping[str, dict[str, t.Any]], path: tuple[str, ...]) -> None for prefix, child in node.items(): _walk(child, path + (prefix,)) - if not node: + # If there are no more nodes, and a path has been accumulated, add it. + # Path may be empty if the "" entry is in sys.path. + if not node and path: rv.add(os.path.join(*path)) _walk(root, ())