From 8e08bf802b599065f47b839588a94409a4b516ed Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Thu, 7 Nov 2024 13:28:01 +0100 Subject: [PATCH] [3.11] gh-111942: Remove an extra incref in textiowrapper_change_encoding There's an issue with the 3.11 backport commit e2421a36f0868e2c5eb492ca9e74ae3d7c37357e The chane for the main branch was: ```diff + Py_INCREF(errors); ... Py_SETREF(self->encoding, encoding); - Py_SETREF(self->errors, Py_NewRef(errors)); + Py_SETREF(self->errors, errors); ``` but in 3.11 this became: ```diff + Py_INCREF(errors); ... Py_INCREF(errors); Py_SETREF(self->encoding, encoding); Py_SETREF(self->errors, errors); ``` i.e. there's an extra incref, but it looks -- at least to Git -- like the change that removes `Py_NewRef` was already applied. This was not caught because `test_io` refleaks tests were ineffective on 3.11 (see https://github.com/python/cpython/pull/126478#issuecomment-2462070264). Remove the extraneous incref. --- Modules/_io/textio.c | 1 - 1 file changed, 1 deletion(-) diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index ba69e2afd27570..e9dd85f1ea1850 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -1313,7 +1313,6 @@ textiowrapper_change_encoding(textio *self, PyObject *encoding, } Py_DECREF(codec_info); - Py_INCREF(errors); Py_SETREF(self->encoding, encoding); Py_SETREF(self->errors, errors);