diff options
| author | hippo91 <guillaume.peillex@gmail.com> | 2020-12-30 11:12:35 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-30 11:12:35 +0100 |
| commit | da2f454a0910360cadbab26a8fb660e2a9134122 (patch) | |
| tree | 0c4d90183831b6245187a8ef68dd5fd845c7a395 | |
| parent | 3554cab57f8cc06abfcdfa82bbe6bebe96b7e292 (diff) | |
| parent | a8bde99124c4213c26fd92a4b287786e5f4829ed (diff) | |
| download | astroid-git-da2f454a0910360cadbab26a8fb660e2a9134122.tar.gz | |
Merge branch 'master' into bug_pylint_3856
| -rw-r--r-- | ChangeLog | 4 | ||||
| -rw-r--r-- | astroid/interpreter/_import/spec.py | 17 |
2 files changed, 20 insertions, 1 deletions
@@ -11,6 +11,10 @@ Release Date: TBA Fixes PyCQA/pylint#3856 +* Fix deprecated importlib methods + + Closes #703 + * Add `python 3.9` support. * The flat attribute of ``numpy.ndarray`` is now inferred as an ``numpy.ndarray`` itself. diff --git a/astroid/interpreter/_import/spec.py b/astroid/interpreter/_import/spec.py index 48cae526..95b069e0 100644 --- a/astroid/interpreter/_import/spec.py +++ b/astroid/interpreter/_import/spec.py @@ -7,6 +7,7 @@ # Copyright (c) 2018 Nick Drozd <nicholasdrozd@gmail.com> # Copyright (c) 2019 Hugo van Kemenade <hugovk@users.noreply.github.com> # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> +# Copyright (c) 2020 Gergely Kalmar <GergelyKalmar@users.noreply.github.com> # Copyright (c) 2020 Peter Kolbus <peter.kolbus@gmail.com> # Copyright (c) 2020 Raphael Gaschignard <raphael@rtpg.co> @@ -272,6 +273,16 @@ def _cached_set_diff(left, right): def _precache_zipimporters(path=None): + """ + For each path that has not been already cached + in the sys.path_importer_cache, create a new zipimporter + instance and add it into the cache. + Return a dict associating all paths, stored in the cache, to corresponding + zipimporter instances. + + :param path: paths that has to be added into the cache + :return: association between paths stored in the cache and zipimporter instances + """ pic = sys.path_importer_cache # When measured, despite having the same complexity (O(n)), @@ -287,7 +298,11 @@ def _precache_zipimporters(path=None): pic[entry_path] = zipimport.zipimporter(entry_path) except zipimport.ZipImportError: continue - return pic + return { + key: value + for key, value in pic.items() + if isinstance(value, zipimport.zipimporter) + } def _search_zip(modpath, pic): |
