diff options
author | Victor Stinner <vstinner@python.org> | 2025-02-05 11:03:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-05 11:03:58 +0100 |
commit | dc804ffb2f7cfaf60916b36f3d5cac9c00e4f1ea (patch) | |
tree | 3eb3cce29397c318c1eba574c0cb41efe3b2f37e /Python/crossinterp.c | |
parent | fb5d1c923677e7982360bad934d70cf9ad3366ca (diff) | |
download | cpython-dc804ffb2f7cfaf60916b36f3d5cac9c00e4f1ea.tar.gz cpython-dc804ffb2f7cfaf60916b36f3d5cac9c00e4f1ea.zip |
gh-128911: Use PyImport_ImportModuleAttr() function (#129657)
* Replace PyImport_ImportModule() + PyObject_GetAttr() with
PyImport_ImportModuleAttr().
* Replace PyImport_ImportModule() + PyObject_GetAttrString() with
PyImport_ImportModuleAttrString().
Diffstat (limited to 'Python/crossinterp.c')
-rw-r--r-- | Python/crossinterp.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/Python/crossinterp.c b/Python/crossinterp.c index 7eb5bc26748..aa2c1cb78bc 100644 --- a/Python/crossinterp.c +++ b/Python/crossinterp.c @@ -368,12 +368,9 @@ _convert_exc_to_TracebackException(PyObject *exc, PyObject **p_tbexc) PyObject *create = NULL; // This is inspired by _PyErr_Display(). - PyObject *tbmod = PyImport_ImportModule("traceback"); - if (tbmod == NULL) { - return -1; - } - PyObject *tbexc_type = PyObject_GetAttrString(tbmod, "TracebackException"); - Py_DECREF(tbmod); + PyObject *tbexc_type = PyImport_ImportModuleAttrString( + "traceback", + "TracebackException"); if (tbexc_type == NULL) { return -1; } |