mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
[3.12] gh-104879: Fix TypeAliasType.__module__ in exec() (GH-104881) (#104890)
(cherry picked from commit fe77a99fc8
)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
parent
3d91d034a0
commit
b670214636
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