diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2022-06-14 04:15:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-14 04:15:26 (GMT) |
commit | 6fd4c8ec7740523bb81191c013118d9d6959bc9d (patch) | |
tree | df4df3a66a89cb1acff0d7721adb62d5553512e3 /Modules/faulthandler.c | |
parent | 7b2064b4b942e1d3c7fd74b5c463250319bc20fb (diff) | |
download | cpython-6fd4c8ec7740523bb81191c013118d9d6959bc9d.zip cpython-6fd4c8ec7740523bb81191c013118d9d6959bc9d.tar.gz cpython-6fd4c8ec7740523bb81191c013118d9d6959bc9d.tar.bz2 |
gh-93741: Add private C API _PyImport_GetModuleAttrString() (GH-93742)
It combines PyImport_ImportModule() and PyObject_GetAttrString()
and saves 4-6 lines of code on every use.
Add also _PyImport_GetModuleAttr() which takes Python strings as arguments.
Diffstat (limited to 'Modules/faulthandler.c')
-rw-r--r-- | Modules/faulthandler.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c index 08c4083..d33cd58 100644 --- a/Modules/faulthandler.c +++ b/Modules/faulthandler.c @@ -1340,13 +1340,13 @@ PyInit_faulthandler(void) static int faulthandler_init_enable(void) { - PyObject *module = PyImport_ImportModule("faulthandler"); - if (module == NULL) { + PyObject *enable = _PyImport_GetModuleAttrString("faulthandler", "enable"); + if (enable == NULL) { return -1; } - PyObject *res = PyObject_CallMethodNoArgs(module, &_Py_ID(enable)); - Py_DECREF(module); + PyObject *res = PyObject_CallNoArgs(enable); + Py_DECREF(enable); if (res == NULL) { return -1; } |