File tree Expand file tree Collapse file tree 2 files changed +11
-8
lines changed
Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -1254,17 +1254,19 @@ class Spec2:
12541254 _imp .create_dynamic (Spec2 ())
12551255
12561256 def test_create_builtin (self ):
1257- for internal_mod in (sys , builtins ):
1258- class Spec :
1259- name = internal_mod .__name__
1257+ class Spec :
1258+ name = "sys"
12601259
1261- self .assertIs (_imp .create_builtin (Spec ()), internal_mod )
1260+ spec = Spec ()
1261+ self .assertIs (_imp .create_builtin (spec ), sys )
12621262
1263- class Spec :
1264- name = "nonexistent_lib"
1263+ spec . name = "builtins"
1264+ self . assertIs ( _imp . create_builtin ( spec ), builtins )
12651265
12661266 # gh-142029
1267- self .assertIs (_imp .create_builtin (Spec ()), None )
1267+ spec .name = "nonexistent_lib"
1268+ with self .assertRaises (ModuleNotFoundError ):
1269+ _imp .create_builtin (spec )
12681270
12691271 def test_filter_syntax_warnings_by_module (self ):
12701272 module_re = r'test\.test_import\.data\.syntax_warnings\z'
Original file line number Diff line number Diff line change @@ -2434,7 +2434,8 @@ create_builtin(
24342434 if (initfunc == NULL ) {
24352435 struct _inittab * entry = lookup_inittab_entry (& info );
24362436 if (entry == NULL ) {
2437- mod = Py_NewRef (Py_None );
2437+ mod = NULL ;
2438+ _PyErr_SetModuleNotFoundError (name );
24382439 goto finally ;
24392440 }
24402441
You can’t perform that action at this time.
0 commit comments