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:57 +0200 |
| commit | bdc1de21992bfbc58e719442d3fb990894b6b713 (patch) | |
| tree | 9bf936152f628f7c2783021e4efd5db9ab800a0f /django | |
| parent | 04965bf92d3064cff1a10dd401b7368e54164148 (diff) | |
[2.2.x] Fixed #30588 -- Fixed crash of autoreloader when __main__ module doesn't have __file__ attribute.
Backport of 8454f6dea49dddb821bfcb7569ea222bb487dfd1 from master
Diffstat (limited to 'django')
| -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 c959cd04ca..2fdc2f3f83 100644 --- a/django/utils/autoreload.py +++ b/django/utils/autoreload.py @@ -117,7 +117,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 |
