diff options
| author | Tom Forbes <tom@tomforb.es> | 2019-06-26 05:44:10 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-06-26 06:44:10 +0200 |
| commit | 8454f6dea49dddb821bfcb7569ea222bb487dfd1 (patch) | |
| tree | 9edde9702497d00d929f54c8490953f72770ca25 /django/utils | |
| parent | 698df6a009cb1c4dbd55905264f24f6edf41066e (diff) | |
Fixed #30588 -- Fixed crash of autoreloader when __main__ module doesn't have __file__ attribute.
Diffstat (limited to 'django/utils')
| -rw-r--r-- | django/utils/autoreload.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/django/utils/autoreload.py b/django/utils/autoreload.py index d33ee9096d..3a0d5fbe73 100644 --- a/django/utils/autoreload.py +++ b/django/utils/autoreload.py @@ -120,7 +120,9 @@ def iter_modules_and_files(modules, extra_files): # __main__ (usually manage.py) doesn't always have a __spec__ set. # Handle this by falling back to using __file__, resolved below. # See https://docs.python.org/reference/import.html#main-spec - sys_file_paths.append(module.__file__) + # __file__ may not exists, e.g. when running ipdb debugger. + if hasattr(module, '__file__'): + sys_file_paths.append(module.__file__) continue if getattr(module, '__spec__', None) is None: continue |
