diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-05-26 11:19:47 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-26 11:19:47 +0200 |
| commit | 12b19a1d76e1a6f80923c8358290d605dacd65d4 (patch) | |
| tree | 380ae23df39e65b1eb2d83c9b610d7a26dda07d7 /django/utils/autoreload.py | |
| parent | 1143f3bb5ecaa2be58f2cd9077f147040291659d (diff) | |
Fixed #32783 -- Fixed crash of autoreloader when __main__ module doesn't have __spec__ attribute.
Regression in ec6d2531c59466924b645f314ac33f54470d7ac3.
Thanks JonathanNickelson for the report.
Diffstat (limited to 'django/utils/autoreload.py')
| -rw-r--r-- | django/utils/autoreload.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/django/utils/autoreload.py b/django/utils/autoreload.py index 9bd2cff066..b6af5f5491 100644 --- a/django/utils/autoreload.py +++ b/django/utils/autoreload.py @@ -222,7 +222,8 @@ def get_child_arguments(): args = [sys.executable] + ['-W%s' % o for o in sys.warnoptions] # __spec__ is set when the server was started with the `-m` option, # see https://docs.python.org/3/reference/import.html#main-spec - if __main__.__spec__ is not None and __main__.__spec__.parent: + # __spec__ may not exist, e.g. when running in a Conda env. + if getattr(__main__, '__spec__', None) is not None and __main__.__spec__.parent: args += ['-m', __main__.__spec__.parent] args += sys.argv[1:] elif not py_script.exists(): |
