Message262352
Example of script.py:
-------------------------
class Bla:
def __del__(self):
try:
import xxxx
except Exception as exc:
print("import error: [%s] %r" % (type(exc), exc))
bla = Bla()
-------------------------
Running this example logs a strange error:
-------------------------
$ python3.5 script.py
import error: [<class 'TypeError'>] TypeError("'NoneType' object is not iterable",)
-------------------------
The error comes from importlib._bootstrap._find_spec() which tries to iterator on sys.meta_path, whereas PyImport_Cleanup() was called and this function setted sys.meta_path to None.
Attached patch enhances _find_spec() to handle this case to return None. Error with the patch:
-------------------------
$ python3.5 script.py
import error: [<class 'ImportError'>] ImportError('sys.meta_path is None, Python is likely shutting down',)
------------------------- |
|
Date |
User |
Action |
Args |
2016-03-24 15:06:33 | vstinner | set | recipients:
+ vstinner, brett.cannon, eric.snow |
2016-03-24 15:06:33 | vstinner | set | messageid: <1458831993.32.0.609008052486.issue26637@psf.upfronthosting.co.za> |
2016-03-24 15:06:33 | vstinner | link | issue26637 messages |
2016-03-24 15:06:32 | vstinner | create | |
|