summaryrefslogtreecommitdiff
path: root/django/utils/autoreload.py
diff options
context:
space:
mode:
authorsarahboyce <sarahvboyce95@gmail.com>2023-08-26 16:23:19 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-08-28 12:57:14 +0200
commitf6ed2c36ddf35bcc32c912123a4eb6fe0a6bfc6a (patch)
tree3fc99a6503da6d0c091b6040cf35796591812320 /django/utils/autoreload.py
parent24f1a38b37c0af3a5ce0dd7b5392fe4e75d7e1dc (diff)
Fixed #34787 -- Fixed autoreloader crash when run from installed script on Windows.
Diffstat (limited to 'django/utils/autoreload.py')
-rw-r--r--django/utils/autoreload.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/django/utils/autoreload.py b/django/utils/autoreload.py
index 5b22aef2b1..e570f89300 100644
--- a/django/utils/autoreload.py
+++ b/django/utils/autoreload.py
@@ -227,6 +227,7 @@ def get_child_arguments():
import __main__
py_script = Path(sys.argv[0])
+ exe_entrypoint = py_script.with_suffix(".exe")
args = [sys.executable] + ["-W%s" % o for o in sys.warnoptions]
if sys.implementation.name == "cpython":
@@ -237,7 +238,7 @@ def get_child_arguments():
# __spec__ is set when the server was started with the `-m` option,
# see https://docs.python.org/3/reference/import.html#main-spec
# __spec__ may not exist, e.g. when running in a Conda env.
- if getattr(__main__, "__spec__", None) is not None:
+ if getattr(__main__, "__spec__", None) is not None and not exe_entrypoint.exists():
spec = __main__.__spec__
if (spec.name == "__main__" or spec.name.endswith(".__main__")) and spec.parent:
name = spec.parent
@@ -248,7 +249,6 @@ def get_child_arguments():
elif not py_script.exists():
# sys.argv[0] may not exist for several reasons on Windows.
# It may exist with a .exe extension or have a -script.py suffix.
- exe_entrypoint = py_script.with_suffix(".exe")
if exe_entrypoint.exists():
# Should be executed directly, ignoring sys.executable.
return [exe_entrypoint, *sys.argv[1:]]