mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
gh-104879: Fix TypeAliasType.__module__ in exec() (#104881)
This commit is contained in:
parent
1497607a8e
commit
fe77a99fc8
4 changed files with 52 additions and 2 deletions
|
@ -1319,8 +1319,13 @@ typealias_module(PyObject *self, void *unused)
|
|||
return Py_NewRef(ta->module);
|
||||
}
|
||||
if (ta->compute_value != NULL) {
|
||||
// PyFunction_GetModule() returns a borrowed reference
|
||||
return Py_NewRef(PyFunction_GetModule(ta->compute_value));
|
||||
PyObject* mod = PyFunction_GetModule(ta->compute_value);
|
||||
if (mod != NULL) {
|
||||
// PyFunction_GetModule() returns a borrowed reference,
|
||||
// and it may return NULL (e.g., for functions defined
|
||||
// in an exec()'ed block).
|
||||
return Py_NewRef(mod);
|
||||
}
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue