diff options
Diffstat (limited to 'Objects/longobject.c')
-rw-r--r-- | Objects/longobject.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c index 6fd4feb..7437155 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -2509,21 +2509,18 @@ PyLong_FromUnicodeObject(PyObject *u, int base) asciidig = _PyUnicode_TransformDecimalAndSpaceToASCII(u); if (asciidig == NULL) return NULL; + assert(PyUnicode_IS_ASCII(asciidig)); + /* Simply get a pointer to existing ASCII characters. */ buffer = PyUnicode_AsUTF8AndSize(asciidig, &buflen); - if (buffer == NULL) { - Py_DECREF(asciidig); - if (!PyErr_ExceptionMatches(PyExc_UnicodeEncodeError)) - return NULL; - } - else { - result = PyLong_FromString(buffer, &end, base); - if (end == NULL || (result != NULL && end == buffer + buflen)) { - Py_DECREF(asciidig); - return result; - } + assert(buffer != NULL); + + result = PyLong_FromString(buffer, &end, base); + if (end == NULL || (result != NULL && end == buffer + buflen)) { Py_DECREF(asciidig); - Py_XDECREF(result); + return result; } + Py_DECREF(asciidig); + Py_XDECREF(result); PyErr_Format(PyExc_ValueError, "invalid literal for int() with base %d: %.200R", base, u); |