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 /Parser/pegen.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 'Parser/pegen.c')
-rw-r--r-- | Parser/pegen.c | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/Parser/pegen.c b/Parser/pegen.c index ec4fee3..dbf105a 100644 --- a/Parser/pegen.c +++ b/Parser/pegen.c @@ -77,13 +77,7 @@ init_normalization(Parser *p) if (p->normalize) { return 1; } - PyObject *m = PyImport_ImportModule("unicodedata"); - if (!m) - { - return 0; - } - p->normalize = PyObject_GetAttrString(m, "normalize"); - Py_DECREF(m); + p->normalize = _PyImport_GetModuleAttrString("unicodedata", "normalize"); if (!p->normalize) { return 0; |