[issue13487] inspect.getmodule fails when module imports change sys.modules

2011-11-26 Thread Erik Tollerud

New submission from Erik Tollerud :

The inspect.getmodule function crashes if packages are installed that futz with 
sys.modules while they are being tested for module status or the like.  I'm not 
actually sure which packages are doing this, but the symptom is the for loop 
over sys.modules raises an Exception because it is modified while the loop is 
running.

This is *not* a problem in Python 2.x because sys.modules.items() returns a 
copy of the dictionary instead of an iterator, and 3.x changes that behavior.  
The comment above the for loop makes it clear that the expected behavior is a 
copy rather than an iterator, so the attached patch corrects the problem by 
simply wrapping the items() call in list().

--
components: Library (Lib)
files: getmodulefix.patch
keywords: patch
messages: 148438
nosy: Erik.Tollerud
priority: normal
severity: normal
status: open
title: inspect.getmodule fails when module imports change sys.modules
versions: Python 3.1, Python 3.2, Python 3.3
Added file: http://bugs.python.org/file23790/getmodulefix.patch

___
Python tracker 
<http://bugs.python.org/issue13487>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13487] inspect.getmodule fails when module imports change sys.modules

2011-11-28 Thread Erik Tollerud

Erik Tollerud  added the comment:

The package that triggers it for me is the py (http://pypi.python.org/pypi/py) 
package - when in gets imported, it does some trick with sys.modules that is in 
place to get around some pickling restriction, but that means sys.modules is 
altered during the import of the `py` package... and that triggers the 
exception.

--

___
Python tracker 
<http://bugs.python.org/issue13487>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com