closes bpo-39870: Remove unused arg from sys_displayhook_unencodable. (GH-18796)

Also move int err to its innermost scope.
This commit is contained in:
Andy Lester 2020-03-05 22:34:36 -06:00 committed by GitHub
parent ce305d6410
commit da4d656e95
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -551,7 +551,7 @@ PyDoc_STRVAR(breakpointhook_doc,
Helper function for sys_displayhook(). */ Helper function for sys_displayhook(). */
static int static int
sys_displayhook_unencodable(PyThreadState *tstate, PyObject *outf, PyObject *o) sys_displayhook_unencodable(PyObject *outf, PyObject *o)
{ {
PyObject *stdout_encoding = NULL; PyObject *stdout_encoding = NULL;
PyObject *encoded, *escaped_str, *repr_str, *buffer, *result; PyObject *encoded, *escaped_str, *repr_str, *buffer, *result;
@ -624,7 +624,6 @@ sys_displayhook(PyObject *module, PyObject *o)
PyObject *outf; PyObject *outf;
PyObject *builtins; PyObject *builtins;
static PyObject *newline = NULL; static PyObject *newline = NULL;
int err;
PyThreadState *tstate = _PyThreadState_GET(); PyThreadState *tstate = _PyThreadState_GET();
builtins = _PyImport_GetModuleId(&PyId_builtins); builtins = _PyImport_GetModuleId(&PyId_builtins);
@ -652,10 +651,11 @@ sys_displayhook(PyObject *module, PyObject *o)
} }
if (PyFile_WriteObject(o, outf, 0) != 0) { if (PyFile_WriteObject(o, outf, 0) != 0) {
if (_PyErr_ExceptionMatches(tstate, PyExc_UnicodeEncodeError)) { if (_PyErr_ExceptionMatches(tstate, PyExc_UnicodeEncodeError)) {
int err;
/* repr(o) is not encodable to sys.stdout.encoding with /* repr(o) is not encodable to sys.stdout.encoding with
* sys.stdout.errors error handler (which is probably 'strict') */ * sys.stdout.errors error handler (which is probably 'strict') */
_PyErr_Clear(tstate); _PyErr_Clear(tstate);
err = sys_displayhook_unencodable(tstate, outf, o); err = sys_displayhook_unencodable(outf, o);
if (err) { if (err) {
return NULL; return NULL;
} }