GeezerVison is showing github.com — We already know the def is okay. · python/cpython@cd4c52d
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: Python/import.c +12-4Lines changed: 12 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1270,7 +1270,7 @@ finish_singlephase_extension(PyThreadState *tstate, |
1270 | 1270 | PyObject *name, PyObject *modules) |
1271 | 1271 | { |
1272 | 1272 | assert(mod != NULL && PyModule_Check(mod)); |
1273 | | - assert(def == PyModule_GetDef(mod)); |
| 1273 | + assert(def == _PyModule_GetDef(mod)); |
1274 | 1274 |
|
1275 | 1275 | if (_modules_by_index_set(tstate->interp, def, mod) < 0) { |
1276 | 1276 | return -1; |
@@ -1419,9 +1419,17 @@ create_dynamic(PyThreadState *tstate, struct _Py_ext_module_loader_info *info, |
1419 | 1419 | goto finally; |
1420 | 1420 | } |
1421 | 1421 |
|
1422 | | - if (res.module == NULL) { |
1423 | | - //assert(!is_singlephase(res.def)); |
1424 | | - mod = PyModule_FromDefAndSpec(res.def, spec); |
| 1422 | + mod = res.module; |
| 1423 | + res.module = NULL; |
| 1424 | + def = res.def; |
| 1425 | + assert(def != NULL); |
| 1426 | + |
| 1427 | + if (mod == NULL) { |
| 1428 | + //assert(!is_singlephase(def)); |
| 1429 | + mod = PyModule_FromDefAndSpec(def, spec); |
| 1430 | + if (mod == NULL) { |
| 1431 | + goto finally; |
| 1432 | + } |
1425 | 1433 | } |
1426 | 1434 | else { |
1427 | 1435 | assert(is_singlephase(res.def)); |
|