File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -315,8 +315,13 @@ def test_multiple_calls_to_get_data(self):
315
315
loader .get_data (imp .__file__ ) # Will need to create a newly opened file
316
316
317
317
def test_load_source (self ):
318
- with self .assertRaisesRegex (ValueError , 'embedded null' ):
319
- imp .load_source (__name__ , __file__ + "\0 " )
318
+ # Create a temporary module since load_source(name) modifies
319
+ # sys.modules[name] attributes like __loader___
320
+ modname = f"tmp{ __name__ } "
321
+ mod = type (sys .modules [__name__ ])(modname )
322
+ with support .swap_item (sys .modules , modname , mod ):
323
+ with self .assertRaisesRegex (ValueError , 'embedded null' ):
324
+ imp .load_source (modname , __file__ + "\0 " )
320
325
321
326
@support .cpython_only
322
327
def test_issue31315 (self ):
You can’t perform that action at this time.
0 commit comments