diff options
author | neonene <53406459+neonene@users.noreply.github.com> | 2024-04-25 11:51:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-25 11:51:31 (GMT) |
commit | 2c451489122d539080c8d674b391dedc1dedcb53 (patch) | |
tree | a6269c4a7a3c07ca982ef8f0d8fd586f39df3424 /Modules/_decimal | |
parent | f180b31e7629d36265fa36f1560365358b4fd47c (diff) | |
download | cpython-2c451489122d539080c8d674b391dedc1dedcb53.zip cpython-2c451489122d539080c8d674b391dedc1dedcb53.tar.gz cpython-2c451489122d539080c8d674b391dedc1dedcb53.tar.bz2 |
gh-117578: Introduce _PyType_GetModuleByDef2 private function (GH-117661)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Diffstat (limited to 'Modules/_decimal')
-rw-r--r-- | Modules/_decimal/_decimal.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c index 2481455..fa425f4 100644 --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -32,6 +32,7 @@ #include <Python.h> #include "pycore_long.h" // _PyLong_IsZero() #include "pycore_pystate.h" // _PyThreadState_GET() +#include "pycore_typeobject.h" #include "complexobject.h" #include "mpdecimal.h" @@ -120,11 +121,8 @@ get_module_state_by_def(PyTypeObject *tp) static inline decimal_state * find_state_left_or_right(PyObject *left, PyObject *right) { - PyObject *mod = PyType_GetModuleByDef(Py_TYPE(left), &_decimal_module); - if (mod == NULL) { - PyErr_Clear(); - mod = PyType_GetModuleByDef(Py_TYPE(right), &_decimal_module); - } + PyObject *mod = _PyType_GetModuleByDef2(Py_TYPE(left), Py_TYPE(right), + &_decimal_module); assert(mod != NULL); return get_module_state(mod); } |