Brett Cannon wrote:
Really? Without really digging into the code too much I see that if
warnings were set on the command-line it's loaded, otherwise it's
skipped.
You are right. It's not loaded by pythonrun.c. The io module is
importing warnings w/o using it. I fixed it in r65694
./python -S -c "import sys; print(list(sorted(sys.modules)),
len(sys.modules))"
Before:
['__main__', '_abcoll', '_codecs', '_fileio', '_sre', '_thread',
'_warnings', '_weakref', '_weakrefset', 'abc', 'builtins', 'codecs',
'copyreg', 'encodings', 'encodings.aliases', 'encodings.latin_1',
'encodings.utf_8', 'errno', 'genericpath', 'io', 'linecache', 'os',
'os.path', 'posix', 'posixpath', 're', 'signal', 'sre_compile',
'sre_constants', 'sre_parse', 'stat', 'sys', 'types', 'warnings',
'zipimport'] 35
After:
['__main__', '_abcoll', '_codecs', '_fileio', '_thread', '_weakref',
'_weakrefset', 'abc', 'builtins', 'codecs', 'copyreg', 'encodings',
'encodings.aliases', 'encodings.latin_1', 'encodings.utf_8', 'errno',
'genericpath', 'io', 'os', 'os.path', 'posix', 'posixpath', 'signal',
'stat', 'sys', 'zipimport'] 26
I'm able to remove copyreg as well. It's imported to register some
pickle/unpickle hooks. The code can be moved into the copyreg module safely.
Christian
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com