Terry J. Reedy added the comment:

I discovered the same thing a different way. Grepping Lib/*.py for
'Warning (from warnings module)' hits
F:\Python\dev\cpython\Lib\idlelib\PyShell.py: 67:
F:\Python\dev\cpython\Lib\idlelib\run.py: 34:
Both monkey-patch warnings, when imported, to show warnings 'the Idle way' ;-). 

I am not sure which test file indirectly imports PyShell, but one must. Idle 
was written to be run from the command line. It was not written to be imported 
but not run, as in a test environment, or to be run as part of another script.

Roger, can the monkey patching be put in a function that is only called when 
Idle runs? Perhaps in PyShell.main and run.main? There is no need to reformat 
warning sent to the console (if there is one) during import, before Idle 
starts. Can the monkey-patching be undone when Python exits (in case it is 
being run from within a script)?

In the meanwhile, I will try using support.import_fresh_module('warnings') in 
test_logging, or better, saving and restoring warnings in test_idle.

[Although the alteration warnings are red-herrings for this issue, I am sure 
silencing them, including in tkinter tests, would be a good idea.]

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18081>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to