Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0661009

Browse files
committed
Get rid of some dead code and unneeded XXX comments by Neal.
1 parent 5f22af1 commit 0661009

2 files changed

Lines changed: 4 additions & 17 deletions

File tree

Modules/datetimemodule.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,17 +1159,12 @@ make_Zreplacement(PyObject *object, PyObject *tzinfoarg)
11591159
if (Zreplacement == NULL)
11601160
return NULL;
11611161
if (PyUnicode_Check(Zreplacement)) {
1162-
/* XXX(nnorwitz): this is really convoluted, is it correct? */
11631162
PyObject *Zreplacement2 =
11641163
_PyUnicode_AsDefaultEncodedString(Zreplacement, NULL);
11651164
if (Zreplacement2 == NULL)
11661165
return NULL;
11671166
Py_INCREF(Zreplacement2);
1168-
/* Zreplacement is owned, but Zreplacement2 is borrowed.
1169-
If they are different, we have to release Zreplacement. */
1170-
if (Zreplacement != Zreplacement2) {
1171-
Py_DECREF(Zreplacement);
1172-
}
1167+
Py_DECREF(Zreplacement);
11731168
Zreplacement = Zreplacement2;
11741169
}
11751170
if (!PyString_Check(Zreplacement)) {

Objects/unicodeobject.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,17 +1189,9 @@ PyObject *_PyUnicode_AsDefaultEncodedString(PyObject *unicode,
11891189
return v;
11901190
if (errors != NULL)
11911191
Py_FatalError("non-NULL encoding in _PyUnicode_AsDefaultEncodedString");
1192-
/* XXX(nnorwitz): errors will always be NULL due to the check above.
1193-
Should this check and the else be removed since it's dead code?
1194-
*/
1195-
if (errors == NULL) {
1196-
b = PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(unicode),
1197-
PyUnicode_GET_SIZE(unicode),
1198-
NULL);
1199-
}
1200-
else {
1201-
b = PyUnicode_AsEncodedString(unicode, NULL, errors);
1202-
}
1192+
b = PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(unicode),
1193+
PyUnicode_GET_SIZE(unicode),
1194+
NULL);
12031195
if (!b)
12041196
return NULL;
12051197
v = PyString_FromStringAndSize(PyBytes_AsString(b),

0 commit comments

Comments
 (0)