From 6bdc22306527e58061bad2e49ab3bb4b525a2f86 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Sat, 20 Aug 2016 00:57:43 +0200 Subject: PyErr_PrintEx() now uses fast call Issue #27128. --- Python/pythonrun.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'Python/pythonrun.c') diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 678ebfe5f6..2968b34cc8 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -630,8 +630,13 @@ PyErr_PrintEx(int set_sys_last_vars) } hook = _PySys_GetObjectId(&PyId_excepthook); if (hook) { - PyObject *args = PyTuple_Pack(3, exception, v, tb); - PyObject *result = PyEval_CallObject(hook, args); + PyObject* stack[3]; + PyObject *result; + + stack[0] = exception; + stack[1] = v; + stack[2] = tb; + result = _PyObject_FastCall(hook, stack, 3, NULL); if (result == NULL) { PyObject *exception2, *v2, *tb2; if (PyErr_ExceptionMatches(PyExc_SystemExit)) { @@ -660,7 +665,6 @@ PyErr_PrintEx(int set_sys_last_vars) Py_XDECREF(tb2); } Py_XDECREF(result); - Py_XDECREF(args); } else { PySys_WriteStderr("sys.excepthook is missing\n"); PyErr_Display(exception, v, tb); -- cgit v1.2.1 From de03c6d8066496680a1ea99ff9e67e28852b0007 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 22 Aug 2016 22:48:54 +0200 Subject: Rename _PyObject_FastCall() to _PyObject_FastCallDict() Issue #27809: * Rename _PyObject_FastCall() function to _PyObject_FastCallDict() * Add _PyObject_FastCall(), _PyObject_CallNoArg() and _PyObject_CallArg1() macros calling _PyObject_FastCallDict() --- Python/pythonrun.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Python/pythonrun.c') diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 2968b34cc8..3fb6f15dd7 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -636,7 +636,7 @@ PyErr_PrintEx(int set_sys_last_vars) stack[0] = exception; stack[1] = v; stack[2] = tb; - result = _PyObject_FastCall(hook, stack, 3, NULL); + result = _PyObject_FastCall(hook, stack, 3); if (result == NULL) { PyObject *exception2, *v2, *tb2; if (PyErr_ExceptionMatches(PyExc_SystemExit)) { -- cgit v1.2.1 From 06d0337c7565e35432fe744713260e2ef3e8a545 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 5 Sep 2016 18:16:01 -0700 Subject: Avoid calling functions with an empty string as format string Directly pass NULL rather than an empty string. --- Python/pythonrun.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Python/pythonrun.c') diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 3fb6f15dd7..1fc86c0a3e 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -950,7 +950,7 @@ flush_io(void) f = _PySys_GetObjectId(&PyId_stderr); if (f != NULL) { - r = _PyObject_CallMethodId(f, &PyId_flush, ""); + r = _PyObject_CallMethodId(f, &PyId_flush, NULL); if (r) Py_DECREF(r); else @@ -958,7 +958,7 @@ flush_io(void) } f = _PySys_GetObjectId(&PyId_stdout); if (f != NULL) { - r = _PyObject_CallMethodId(f, &PyId_flush, ""); + r = _PyObject_CallMethodId(f, &PyId_flush, NULL); if (r) Py_DECREF(r); else -- cgit v1.2.1 From 57c0f2e61c8a5893c37e576a3a03ba5e57c1132c Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 20 Nov 2016 09:13:07 +0200 Subject: Replaced outdated macros _PyUnicode_AsString and _PyUnicode_AsStringAndSize with PyUnicode_AsUTF8 and PyUnicode_AsUTF8AndSize. --- Python/pythonrun.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Python/pythonrun.c') diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 5b1b78672b..c881f901ab 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -171,7 +171,7 @@ PyRun_InteractiveOneObject(FILE *fp, PyObject *filename, PyCompilerFlags *flags) if (v && v != Py_None) { oenc = _PyObject_GetAttrId(v, &PyId_encoding); if (oenc) - enc = _PyUnicode_AsString(oenc); + enc = PyUnicode_AsUTF8(oenc); if (!enc) PyErr_Clear(); } @@ -182,7 +182,7 @@ PyRun_InteractiveOneObject(FILE *fp, PyObject *filename, PyCompilerFlags *flags) if (v == NULL) PyErr_Clear(); else if (PyUnicode_Check(v)) { - ps1 = _PyUnicode_AsString(v); + ps1 = PyUnicode_AsUTF8(v); if (ps1 == NULL) { PyErr_Clear(); ps1 = ""; @@ -195,7 +195,7 @@ PyRun_InteractiveOneObject(FILE *fp, PyObject *filename, PyCompilerFlags *flags) if (w == NULL) PyErr_Clear(); else if (PyUnicode_Check(w)) { - ps2 = _PyUnicode_AsString(w); + ps2 = PyUnicode_AsUTF8(w); if (ps2 == NULL) { PyErr_Clear(); ps2 = ""; @@ -514,7 +514,7 @@ print_error_text(PyObject *f, int offset, PyObject *text_obj) char *text; char *nl; - text = _PyUnicode_AsString(text_obj); + text = PyUnicode_AsUTF8(text_obj); if (text == NULL) return; -- cgit v1.2.1