From 1f532b8ad90c582ca1a756ac472a68c3b552d37c Mon Sep 17 00:00:00 2001 From: David Lord Date: Mon, 15 Jul 2019 14:09:07 -0700 Subject: [PATCH] don't detect executable file for reloader Reverts #1242 In order to support NixOS wrappers, the reloader would call an executable script directly. This caused issues with Windows, Docker, and other common development environments, resulting in an "Exec format error". Revert that change until a better workaround can be found. --- CHANGES.rst | 5 +++++ src/werkzeug/_reloader.py | 12 ++---------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 42bd46af0..23db01396 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -19,6 +19,11 @@ Unreleased reloader to fail. :issue:`1607` - Work around an issue where the reloader couldn't introspect a setuptools script installed as an egg. :issue:`1600` +- The reloader will use ``sys.executable`` even if the script is + marked executable, reverting a behavior intended for NixOS + introduced in 0.15. The reloader should no longer cause + ``OSError: [Errno 8] Exec format error``. :issue:`1482`, + :issue:`1580` - ``SharedDataMiddleware`` safely handles paths with Windows drive names. :issue:`1589` diff --git a/src/werkzeug/_reloader.py b/src/werkzeug/_reloader.py index f085d44a2..b04432012 100644 --- a/src/werkzeug/_reloader.py +++ b/src/werkzeug/_reloader.py @@ -61,11 +61,8 @@ def _find_observable_paths(extra_files=None): def _get_args_for_reloading(): - """Returns the executable. This contains a workaround for windows - if the executable is incorrectly reported to not have the .exe - extension which can cause bugs on reloading. This also contains - a workaround for linux where the file is executable (possibly with - a program other than python) + """Determine how the script was executed, and return the args needed + to execute it again in a new process. """ rv = [sys.executable] py_script = sys.argv[0] @@ -91,11 +88,6 @@ def _get_args_for_reloading(): ): rv.pop(0) - elif os.path.isfile(py_script) and os.access(py_script, os.X_OK): - # The file is marked as executable. Nix adds a wrapper that - # shouldn't be called with the Python executable. - rv.pop(0) - rv.append(py_script) else: # Executed a module, like "python -m werkzeug.serving".