New submission from Douglas Rudd:
pth files for logilab (e.g. logilab_common, logilab_astng) and mpl_toolkit
(e.g. basemap, matplotlib) contain code like the following (taken from basemap
1.0.7):
import sys, types, os;p = os.path.join(sys._getframe(1).f_locals['sitedir'],
*('mpl_toolkits',));ie = os.path.exists(os.path.join(p,'__init__.py'));m = not
ie and sys.modules.setdefault('mpl_toolkits',
types.ModuleType('mpl_toolkits'));mp = (m or []) and
m.__dict__.setdefault('__path__',[]);(p not in mp) and mp.append(p)
This leads to the types module being loaded on import, which then causes
test_site/test_startup_imports to fail since types is in collection_mods:
collection_mods = {'_collections', 'collections', 'functools',
'heapq', 'itertools', 'keyword', 'operator',
'reprlib', 'types', 'weakref'
}.difference(sys.builtin_module_names)
self.assertFalse(modules.intersection(collection_mods), stderr)
$ python3.4 -c 'import sys; print(set(sys.modules))'
{'builtins', '_codecs', 'io', 'errno', 'abc', '_weakref', '_collections_abc',
'_bootlocale', 'stat', 'os', '_frozen_importlib', 'encodings.utf_8',
'_sitebuiltins', '_sysconfigdata', 'sysconfig', 'posixpath', 'sys',
'mpl_toolkits', '_weakrefset', 'encodings', 'encodings.aliases', 'signal',
'__main__', '_stat', 'zipimport', 'genericpath', 'site', '_io', 'posix',
'codecs', 'types', '_imp', 'os.path', '_warnings', 'marshal', '_locale',
'_thread', 'encodings.latin_1'}
This is a similar bug to http://bugs.python.org/issue20986
I don't know the purpose of this test well enough to propose a fix, but given
the number of exceptions already there it doesn't seem to be a robust test.
----------
components: Tests
messages: 234345
nosy: drudd
priority: normal
severity: normal
status: open
title: test_site/test_startup_imports fails when mpl_toolkit or logilab based
modules installed
versions: Python 3.4
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue23279>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com