@@ -128,6 +128,12 @@ _Py_ext_module_loader_info_init_from_spec(
128
128
return -1 ;
129
129
}
130
130
131
+ info .newcontext = PyUnicode_AsUTF8 (info .name );
132
+ if (info .newcontext == NULL ) {
133
+ _Py_ext_module_loader_info_clear (& info );
134
+ return -1 ;
135
+ }
136
+
131
137
info .path = PyObject_GetAttrString (spec , "origin" );
132
138
if (info .path == NULL ) {
133
139
_Py_ext_module_loader_info_clear (& info );
@@ -152,16 +158,11 @@ _PyImport_LoadDynamicModuleWithSpec(struct _Py_ext_module_loader_info *info,
152
158
{
153
159
PyObject * m = NULL ;
154
160
const char * name_buf = PyBytes_AS_STRING (info -> name_encoded );
155
- const char * oldcontext , * newcontext ;
161
+ const char * oldcontext ;
156
162
dl_funcptr exportfunc ;
157
163
PyModInitFunction p0 ;
158
164
PyModuleDef * def ;
159
165
160
- newcontext = PyUnicode_AsUTF8 (info -> name );
161
- if (newcontext == NULL ) {
162
- goto error ;
163
- }
164
-
165
166
#ifdef MS_WINDOWS
166
167
exportfunc = _PyImport_FindSharedFuncptrWindows (
167
168
info -> hook_prefix , name_buf , info -> path , fp );
@@ -191,7 +192,7 @@ _PyImport_LoadDynamicModuleWithSpec(struct _Py_ext_module_loader_info *info,
191
192
p0 = (PyModInitFunction )exportfunc ;
192
193
193
194
/* Package context is needed for single-phase init */
194
- oldcontext = _PyImport_SwapPackageContext (newcontext );
195
+ oldcontext = _PyImport_SwapPackageContext (info -> newcontext );
195
196
m = p0 ();
196
197
_PyImport_SwapPackageContext (oldcontext );
197
198
0 commit comments