diff options
author | Petr Viktorin <encukou@gmail.com> | 2020-11-03 21:27:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-03 21:27:12 (GMT) |
commit | 57aaaa8d2a43bddffeca4ead5632ce6652945cc0 (patch) | |
tree | 30d87542dadc05d27d170ae279cb80c82855c9fc /Modules/_testmultiphase.c | |
parent | a603c3d371cda76bae75836faf068e146eb6ab76 (diff) | |
download | cpython-57aaaa8d2a43bddffeca4ead5632ce6652945cc0.zip cpython-57aaaa8d2a43bddffeca4ead5632ce6652945cc0.tar.gz cpython-57aaaa8d2a43bddffeca4ead5632ce6652945cc0.tar.bz2 |
Add _PyType_GetModuleByDef (GH-22835)
See https://mail.python.org/archives/list/capi-sig@python.org/thread/T3P2QNLNLBRFHWSKYSTPMVEIL2EEKFJU/ for discussion.
https://bugs.python.org/issue42100
Diffstat (limited to 'Modules/_testmultiphase.c')
-rw-r--r-- | Modules/_testmultiphase.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Modules/_testmultiphase.c b/Modules/_testmultiphase.c index 8bba077..ad60f32 100644 --- a/Modules/_testmultiphase.c +++ b/Modules/_testmultiphase.c @@ -121,24 +121,30 @@ static PyType_Spec Example_Type_spec = { }; +static PyModuleDef def_meth_state_access; + /*[clinic input] _testmultiphase.StateAccessType.get_defining_module cls: defining_class Return the module of the defining class. + +Also tests that result of _PyType_GetModuleByDef matches defining_class's +module. [clinic start generated code]*/ static PyObject * _testmultiphase_StateAccessType_get_defining_module_impl(StateAccessTypeObject *self, PyTypeObject *cls) -/*[clinic end generated code: output=ba2a14284a5d0921 input=946149f91cf72c0d]*/ +/*[clinic end generated code: output=ba2a14284a5d0921 input=356f999fc16e0933]*/ { PyObject *retval; retval = PyType_GetModule(cls); if (retval == NULL) { return NULL; } + assert(_PyType_GetModuleByDef(Py_TYPE(self), &def_meth_state_access) == retval); Py_INCREF(retval); return retval; } |