diff options
Diffstat (limited to 'Parser')
| -rw-r--r-- | Parser/pegen.c | 8 | ||||
| -rw-r--r-- | Parser/tokenizer.c | 10 |
2 files changed, 6 insertions, 12 deletions
diff --git a/Parser/pegen.c b/Parser/pegen.c index ec4fee3fc4..dbf105aedc 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; diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index d5b549c870..952265eb92 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -421,7 +421,7 @@ error: static int fp_setreadl(struct tok_state *tok, const char* enc) { - PyObject *readline, *io, *stream; + PyObject *readline, *open, *stream; int fd; long pos; @@ -438,13 +438,13 @@ fp_setreadl(struct tok_state *tok, const char* enc) return 0; } - io = PyImport_ImportModule("io"); - if (io == NULL) { + open = _PyImport_GetModuleAttrString("io", "open"); + if (open == NULL) { return 0; } - stream = _PyObject_CallMethod(io, &_Py_ID(open), "isisOOO", + stream = PyObject_CallFunction(open, "isisOOO", fd, "r", -1, enc, Py_None, Py_None, Py_False); - Py_DECREF(io); + Py_DECREF(open); if (stream == NULL) { return 0; } |
