Get rid of some dead code and unneeded XXX comments by Neal.

This commit is contained in:
Guido van Rossum 2007-08-16 21:02:22 +00:00
parent 5f22af167f
commit 066100909a
2 changed files with 4 additions and 17 deletions

View file

@ -1159,17 +1159,12 @@ make_Zreplacement(PyObject *object, PyObject *tzinfoarg)
if (Zreplacement == NULL) if (Zreplacement == NULL)
return NULL; return NULL;
if (PyUnicode_Check(Zreplacement)) { if (PyUnicode_Check(Zreplacement)) {
/* XXX(nnorwitz): this is really convoluted, is it correct? */
PyObject *Zreplacement2 = PyObject *Zreplacement2 =
_PyUnicode_AsDefaultEncodedString(Zreplacement, NULL); _PyUnicode_AsDefaultEncodedString(Zreplacement, NULL);
if (Zreplacement2 == NULL) if (Zreplacement2 == NULL)
return NULL; return NULL;
Py_INCREF(Zreplacement2); Py_INCREF(Zreplacement2);
/* Zreplacement is owned, but Zreplacement2 is borrowed. Py_DECREF(Zreplacement);
If they are different, we have to release Zreplacement. */
if (Zreplacement != Zreplacement2) {
Py_DECREF(Zreplacement);
}
Zreplacement = Zreplacement2; Zreplacement = Zreplacement2;
} }
if (!PyString_Check(Zreplacement)) { if (!PyString_Check(Zreplacement)) {

View file

@ -1189,17 +1189,9 @@ PyObject *_PyUnicode_AsDefaultEncodedString(PyObject *unicode,
return v; return v;
if (errors != NULL) if (errors != NULL)
Py_FatalError("non-NULL encoding in _PyUnicode_AsDefaultEncodedString"); Py_FatalError("non-NULL encoding in _PyUnicode_AsDefaultEncodedString");
/* XXX(nnorwitz): errors will always be NULL due to the check above. b = PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(unicode),
Should this check and the else be removed since it's dead code? PyUnicode_GET_SIZE(unicode),
*/ NULL);
if (errors == NULL) {
b = PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(unicode),
PyUnicode_GET_SIZE(unicode),
NULL);
}
else {
b = PyUnicode_AsEncodedString(unicode, NULL, errors);
}
if (!b) if (!b)
return NULL; return NULL;
v = PyString_FromStringAndSize(PyBytes_AsString(b), v = PyString_FromStringAndSize(PyBytes_AsString(b),