File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 :
Original file line number Diff line number Diff 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
318327class PEP3147Tests (unittest .TestCase ):
319328 """Tests of PEP 3147."""
Original file line number Diff line number Diff line change @@ -221,6 +221,8 @@ Core and Builtins
221221Library
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
You can’t perform that action at this time.
0 commit comments