This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Fix reload() error message
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: collinwinter, georg.brandl, georg.brandl
Priority: normal Keywords: patch

Created on 2005-09-13 20:57 by collinwinter, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
import.c.patch collinwinter, 2005-09-13 20:57 Patch against import.c, r2.242
Messages (2)
msg48731 - (view) Author: Collin Winter (collinwinter) * (Python committer) Date: 2005-09-13 20:57
As of CVS revision 2.242, PyImport_ReloadModule gives
the wrong error message when the parent module no
longer exists in sys.modules. Below is a sample session:

Python 2.4.1 (#1, Aug 11 2005, 08:51:39)
[GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> import distutils.command.sdist 
>>> import sys
>>> del sys.modules['distutils.command']
>>> del sys.modules['distutils']
>>> reload(distutils.command.sdist)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: reload(): parent distutils.command.sdist
not in sys.modules
>>>

The ImportError message should read "reload(): parent
distutils.command not in sys.modules". The attached
patch (against import.c, r2.242) fixes this behaviour.
The patch has been tested with the regression suite
shipped with Python 2.4.1.
msg48732 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-09-14 07:01
Logged In: YES 
user_id=1188172

Thanks for the fix! However, please produce a context diff
in the future, it makes it much easier to grasp, ehm, the
context of the changes, so that one does not have to apply
the patch before reviewing it.

Committed as import.c r2.243, r2.240.2.1.
History
Date User Action Args
2022-04-11 14:56:13adminsetgithub: 42369
2005-09-13 20:57:33collinwintercreate