Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fbcf4d7

Browse files
committed
#18681: merge with 3.3.
2 parents b37278c + 056bafe commit fbcf4d7

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

Lib/importlib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def reload(module):
115115
parent_name = name.rpartition('.')[0]
116116
if parent_name and parent_name not in sys.modules:
117117
msg = "parent {!r} not in sys.modules"
118-
raise ImportError(msg.format(parentname), name=parent_name)
118+
raise ImportError(msg.format(parent_name), name=parent_name)
119119
return module.__loader__.load_module(name)
120120
finally:
121121
try:

Lib/test/test_imp.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,15 @@ def test_builtin(self):
314314
import marshal
315315
imp.reload(marshal)
316316

317+
def test_with_deleted_parent(self):
318+
# see #18681
319+
from html import parser
320+
del sys.modules['html']
321+
def cleanup(): del sys.modules['html.parser']
322+
self.addCleanup(cleanup)
323+
with self.assertRaisesRegex(ImportError, 'html'):
324+
imp.reload(parser)
325+
317326

318327
class PEP3147Tests(unittest.TestCase):
319328
"""Tests of PEP 3147."""

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ Core and Builtins
221221
Library
222222
-------
223223

224+
- Issue #18681: Fix a NameError in importlib.reload() (noticed by Weizhao Li).
225+
224226
- Issue #14323: Expanded the number of digits in the coefficients for the
225227
RGB -- YIQ conversions so that they match the FCC NTSC versions.
226228

0 commit comments

Comments
 (0)