[Python-Dev] Failures in test_site.py - how to debug?

Chris Angelico rosuav at gmail.com
Fri Aug 19 10:13:45 EDT 2016


On my main dev system (Debian Stretch), I've had a single
long-standing test failure - test_site.py,
StartupImportTests.test_startup_imports. It's annoying (partly because
it's such a noisy failure), and doesn't appear to be happening on the
buildbots, nor presumably on core devs' computers, so it's probably
not a Python bug. How can I go about figuring out what's actually
going on here?

The test effectively runs this (but with -v, which makes it noisy):

$ ./python -I -c 'import sys; print(set(sys.modules))'
{'_frozen_importlib_external', 'keyword', '_stat', 'weakref',
'sysconfig', 'genericpath', '_sysconfigdata_m', '_io', '_operator',
'_bootlocale', 'encodings.utf_8', 'itertools', '_locale', 'codecs',
'_weakrefset', 'operator', '_frozen_importlib', 'types',
'_sitebuiltins', 'os', 'posixpath', '_functools', '__main__',
'_weakref', '_warnings', '_codecs', 'builtins', 'posix', 'functools',
'io', 'encodings.aliases', 'collections.abc', 'encodings', '_thread',
'collections', 'errno', '_collections', '_collections_abc', '_heapq',
'_imp', 'site', 'sys', 'reprlib', '_signal', 'stat', 'zipimport',
'abc', 'encodings.latin_1', 'os.path', 'marshal', 'heapq',
'mpl_toolkits'}

It then runs into a failure when it asserts that this set has no
intersection with the set of collection_mods. Apparently 'import sys'
on my system (even with -I for isolation mode) loads up a bunch of
modules that it shouldn't be loading. How do I track down what and
why, and figure out whether it's a config problem unique to my system
or not?

ChrisA


More information about the Python-Dev mailing list