diff --git a/CHANGES.rst b/CHANGES.rst index ada5e43d9..846c4f291 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -16,6 +16,8 @@ Unreleased :pr:`1592` - Work around an issue in some external debuggers that caused the reloader to fail. :issue:`1607` +- Work around an issue where the reloader couldn't introspect a + setuptools script installed as an egg. :issue:`1600` Version 0.15.4 diff --git a/src/werkzeug/_reloader.py b/src/werkzeug/_reloader.py index 8d22859d5..f085d44a2 100644 --- a/src/werkzeug/_reloader.py +++ b/src/werkzeug/_reloader.py @@ -73,7 +73,9 @@ def _get_args_for_reloading(): # Need to look at main module to determine how it was executed. __main__ = sys.modules["__main__"] - if __main__.__package__ is None: + # The value of __package__ indicates how Python was called. It may + # not exist if a setuptools script is installed as an egg. + if getattr(__main__, "__package__", None) is None: # Executed a file, like "python app.py". py_script = os.path.abspath(py_script)