diff options
author | Jeroen Demeyer <J.Demeyer@UGent.be> | 2019-07-08 08:19:25 (GMT) |
---|---|---|
committer | Inada Naoki <songofacandy@gmail.com> | 2019-07-08 08:19:25 (GMT) |
commit | 762f93ff2efd6b7ef0177cad57939c0ab2002eac (patch) | |
tree | 4811b08fa9342c3b2575de7e7c1030d1d5eea8a0 /Python | |
parent | 38f44b4a4adc37e8f5f8971917d8b3145f351a56 (diff) | |
download | cpython-762f93ff2efd6b7ef0177cad57939c0ab2002eac.zip cpython-762f93ff2efd6b7ef0177cad57939c0ab2002eac.tar.gz cpython-762f93ff2efd6b7ef0177cad57939c0ab2002eac.tar.bz2 |
bpo-37337: Add _PyObject_CallMethodNoArgs() (GH-14267)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/bltinmodule.c | 12 | ||||
-rw-r--r-- | Python/errors.c | 2 | ||||
-rw-r--r-- | Python/import.c | 2 | ||||
-rw-r--r-- | Python/pylifecycle.c | 10 | ||||
-rw-r--r-- | Python/pythonrun.c | 6 | ||||
-rw-r--r-- | Python/traceback.c | 4 |
6 files changed, 18 insertions, 18 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 5de4363..65110d8 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -1889,7 +1889,7 @@ builtin_print(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject if (do_flush == -1) return NULL; else if (do_flush) { - tmp = _PyObject_CallMethodId(file, &PyId_flush, NULL); + tmp = _PyObject_CallMethodIdNoArgs(file, &PyId_flush); if (tmp == NULL) return NULL; else @@ -1959,7 +1959,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt) } /* First of all, flush stderr */ - tmp = _PyObject_CallMethodId(ferr, &PyId_flush, NULL); + tmp = _PyObject_CallMethodIdNoArgs(ferr, &PyId_flush); if (tmp == NULL) PyErr_Clear(); else @@ -1968,7 +1968,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt) /* We should only use (GNU) readline if Python's sys.stdin and sys.stdout are the same as C's stdin and stdout, because we need to pass it those. */ - tmp = _PyObject_CallMethodId(fin, &PyId_fileno, NULL); + tmp = _PyObject_CallMethodIdNoArgs(fin, &PyId_fileno); if (tmp == NULL) { PyErr_Clear(); tty = 0; @@ -1981,7 +1981,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt) tty = fd == fileno(stdin) && isatty(fd); } if (tty) { - tmp = _PyObject_CallMethodId(fout, &PyId_fileno, NULL); + tmp = _PyObject_CallMethodIdNoArgs(fout, &PyId_fileno); if (tmp == NULL) { PyErr_Clear(); tty = 0; @@ -2019,7 +2019,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt) stdin_errors_str = PyUnicode_AsUTF8(stdin_errors); if (!stdin_encoding_str || !stdin_errors_str) goto _readline_errors; - tmp = _PyObject_CallMethodId(fout, &PyId_flush, NULL); + tmp = _PyObject_CallMethodIdNoArgs(fout, &PyId_flush); if (tmp == NULL) PyErr_Clear(); else @@ -2114,7 +2114,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt) if (PyFile_WriteObject(prompt, fout, Py_PRINT_RAW) != 0) return NULL; } - tmp = _PyObject_CallMethodId(fout, &PyId_flush, NULL); + tmp = _PyObject_CallMethodIdNoArgs(fout, &PyId_flush); if (tmp == NULL) PyErr_Clear(); else diff --git a/Python/errors.c b/Python/errors.c index a7d40c1..b935341 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -1263,7 +1263,7 @@ write_unraisable_exc_file(PyThreadState *tstate, PyObject *exc_type, } /* Explicitly call file.flush() */ - PyObject *res = _PyObject_CallMethodId(file, &PyId_flush, NULL); + PyObject *res = _PyObject_CallMethodIdNoArgs(file, &PyId_flush); if (!res) { return -1; } diff --git a/Python/import.c b/Python/import.c index 76866ae..df25875 100644 --- a/Python/import.c +++ b/Python/import.c @@ -539,7 +539,7 @@ _PyImport_Cleanup(PyThreadState *tstate) } else { _Py_IDENTIFIER(clear); - if (_PyObject_CallMethodId(modules, &PyId_clear, "") == NULL) { + if (_PyObject_CallMethodIdNoArgs(modules, &PyId_clear) == NULL) { PyErr_WriteUnraisable(NULL); } } diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 10765da..e3333db 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -1106,7 +1106,7 @@ flush_std_files(void) int status = 0; if (fout != NULL && fout != Py_None && !file_is_closed(fout)) { - tmp = _PyObject_CallMethodId(fout, &PyId_flush, NULL); + tmp = _PyObject_CallMethodIdNoArgs(fout, &PyId_flush); if (tmp == NULL) { PyErr_WriteUnraisable(fout); status = -1; @@ -1116,7 +1116,7 @@ flush_std_files(void) } if (ferr != NULL && ferr != Py_None && !file_is_closed(ferr)) { - tmp = _PyObject_CallMethodId(ferr, &PyId_flush, NULL); + tmp = _PyObject_CallMethodIdNoArgs(ferr, &PyId_flush); if (tmp == NULL) { PyErr_Clear(); status = -1; @@ -1762,7 +1762,7 @@ create_stdio(const PyConfig *config, PyObject* io, text = PyUnicode_FromString(name); if (text == NULL || _PyObject_SetAttrId(raw, &PyId_name, text) < 0) goto error; - res = _PyObject_CallMethodId(raw, &PyId_isatty, NULL); + res = _PyObject_CallMethodIdNoArgs(raw, &PyId_isatty); if (res == NULL) goto error; isatty = PyObject_IsTrue(res); @@ -2026,7 +2026,7 @@ _Py_FatalError_PrintExc(int fd) Py_XDECREF(tb); /* sys.stderr may be buffered: call sys.stderr.flush() */ - res = _PyObject_CallMethodId(ferr, &PyId_flush, NULL); + res = _PyObject_CallMethodIdNoArgs(ferr, &PyId_flush); if (res == NULL) { _PyErr_Clear(tstate); } @@ -2220,7 +2220,7 @@ wait_for_thread_shutdown(PyThreadState *tstate) /* else: threading not imported */ return; } - result = _PyObject_CallMethodId(threading, &PyId__shutdown, NULL); + result = _PyObject_CallMethodIdNoArgs(threading, &PyId__shutdown); if (result == NULL) { PyErr_WriteUnraisable(threading); } diff --git a/Python/pythonrun.c b/Python/pythonrun.c index f1d946a..6089086 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -978,7 +978,7 @@ _PyErr_Display(PyObject *file, PyObject *exception, PyObject *value, PyObject *t Py_XDECREF(seen); /* Call file.flush() */ - PyObject *res = _PyObject_CallMethodId(file, &PyId_flush, NULL); + PyObject *res = _PyObject_CallMethodIdNoArgs(file, &PyId_flush); if (!res) { /* Silently ignore file.flush() error */ PyErr_Clear(); @@ -1072,7 +1072,7 @@ flush_io(void) f = _PySys_GetObjectId(&PyId_stderr); if (f != NULL) { - r = _PyObject_CallMethodId(f, &PyId_flush, NULL); + r = _PyObject_CallMethodIdNoArgs(f, &PyId_flush); if (r) Py_DECREF(r); else @@ -1080,7 +1080,7 @@ flush_io(void) } f = _PySys_GetObjectId(&PyId_stdout); if (f != NULL) { - r = _PyObject_CallMethodId(f, &PyId_flush, NULL); + r = _PyObject_CallMethodIdNoArgs(f, &PyId_flush); if (r) Py_DECREF(r); else diff --git a/Python/traceback.c b/Python/traceback.c index 0463eb6..f396f1a 100644 --- a/Python/traceback.c +++ b/Python/traceback.c @@ -430,7 +430,7 @@ _Py_DisplaySourceLine(PyObject *f, PyObject *filename, int lineno, int indent) if (fob == NULL) { PyErr_Clear(); - res = _PyObject_CallMethodId(binary, &PyId_close, NULL); + res = _PyObject_CallMethodIdNoArgs(binary, &PyId_close); Py_DECREF(binary); if (res) Py_DECREF(res); @@ -450,7 +450,7 @@ _Py_DisplaySourceLine(PyObject *f, PyObject *filename, int lineno, int indent) break; } } - res = _PyObject_CallMethodId(fob, &PyId_close, NULL); + res = _PyObject_CallMethodIdNoArgs(fob, &PyId_close); if (res) Py_DECREF(res); else |