diff options
| author | Tom Forbes <tom@tomforb.es> | 2019-06-24 08:48:59 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-06-24 09:48:59 +0200 |
| commit | e28671187903e6aca2428374fdd504fca3032aee (patch) | |
| tree | 752348dce55fb6bb4150bb9e8b1c19a9bcfb092f | |
| parent | 833878411c35e1d47abfb77c23863a9dc9bb6d27 (diff) | |
Simplified handling of non-existent paths in autoreloader with Path.resolve(strict=True).
| -rw-r--r-- | django/utils/autoreload.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/django/utils/autoreload.py b/django/utils/autoreload.py index 9a3b10bf20..d33ee9096d 100644 --- a/django/utils/autoreload.py +++ b/django/utils/autoreload.py @@ -136,11 +136,13 @@ def iter_modules_and_files(modules, extra_files): if not filename: continue path = pathlib.Path(filename) - if not path.exists(): + try: + resolved_path = path.resolve(strict=True).absolute() + except FileNotFoundError: # The module could have been removed, don't fail loudly if this # is the case. continue - results.add(path.resolve().absolute()) + results.add(resolved_path) return frozenset(results) @@ -182,14 +184,15 @@ def sys_path_directories(): """ for path in sys.path: path = Path(path) - if not path.exists(): + try: + resolved_path = path.resolve(strict=True).absolute() + except FileNotFoundError: continue - path = path.resolve().absolute() # If the path is a file (like a zip file), watch the parent directory. - if path.is_file(): - yield path.parent + if resolved_path.is_file(): + yield resolved_path.parent else: - yield path + yield resolved_path def get_child_arguments(): |
