Skip to content

Commit 6e35c8d

Browse files
authored
Apply suggestions from code review
1 parent 62df0dd commit 6e35c8d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

Python/codecs.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,7 @@ _PyCodec_SurrogatePassUnicodeEncodeError(PyObject *exc)
11711171
Py_UCS4 ch = PyUnicode_READ_CHAR(obj, i);
11721172
if (!Py_UNICODE_IS_SURROGATE(ch)) {
11731173
/* Not a surrogate, fail with original exception */
1174+
Py_DECREF(obj);
11741175
Py_DECREF(res);
11751176
goto bail;
11761177
}
@@ -1208,13 +1209,11 @@ _PyCodec_SurrogatePassUnicodeEncodeError(PyObject *exc)
12081209
}
12091210
}
12101211

1211-
PyObject *restuple = Py_BuildValue("(On)", res, end);
12121212
Py_DECREF(obj);
1213-
Py_DECREF(res);
1213+
PyObject *restuple = Py_BuildValue("(Nn)", res, end);
12141214
return restuple;
12151215

12161216
bail:
1217-
Py_XDECREF(obj);
12181217
PyErr_SetObject(PyExceptionInstance_Class(exc), exc);
12191218
return NULL;
12201219

0 commit comments

Comments
 (0)