[New-bugs-announce] [issue45183] Unexpected exception with zip importer
Ronald Oussoren
report at bugs.python.org
Mon Sep 13 07:29:05 EDT 2021
New submission from Ronald Oussoren <ronaldoussoren at mac.com>:
The attached file demonstrates the problem:
If importlib.invalidate_caches() is called while the zipfile used by the zip importer is not available the import system breaks entirely. I found this in a testsuite that accedently did this (it should have updated sys.path).
I get the following exception:
$ python3.10 t.py
Traceback (most recent call last):
File "/Users/ronald/Projects/modulegraph2/t.py", line 27, in <module>
import uu
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1002, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 945, in _find_spec
File "<frozen importlib._bootstrap_external>", line 1430, in find_spec
File "<frozen importlib._bootstrap_external>", line 1402, in _get_spec
File "<frozen zipimport>", line 168, in find_spec
File "<frozen zipimport>", line 375, in _get_module_info
TypeError: argument of type 'NoneType' is not iterable
This exception is not very friendly....
This particular exception is caused by setting self._files to None in the importer's invalidate_caches method, while not checking for None in _get_modules_info.
I'm not sure what the best fix would be, setting self._files to an empty list would likely be the easiest fix.
Note that the script runs without errors in Python 3.9.
----------
files: repro.py
keywords: 3.10regression
messages: 401698
nosy: ronaldoussoren
priority: normal
severity: normal
status: open
title: Unexpected exception with zip importer
versions: Python 3.10, Python 3.11
Added file: https://bugs.python.org/file50279/repro.py
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45183>
_______________________________________
More information about the New-bugs-announce
mailing list