From: Christian Heimes Date: Wed, 30 Jan 2008 11:28:29 +0000 (+0000) Subject: Fixed issue #1973: bytes.fromhex('') raises SystemError X-Git-Tag: v3.0a3~139 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2c4a07249f736c0502b79db63d400928f6aa0484;p=thirdparty%2FPython%2Fcpython.git Fixed issue #1973: bytes.fromhex('') raises SystemError --- diff --git a/Objects/stringobject.c b/Objects/stringobject.c index 011fc323abde..d714a779ee48 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -2772,7 +2772,7 @@ string_fromhex(PyObject *cls, PyObject *args) } buf[j++] = (top << 4) + bot; } - if (_PyString_Resize(&newstring, j) < 0) + if (j != byteslen && _PyString_Resize(&newstring, j) < 0) goto error; return newstring; @@ -2788,7 +2788,7 @@ string_getnewargs(PyStringObject *v) return Py_BuildValue("(s#)", v->ob_sval, Py_SIZE(v)); } - + static PyMethodDef string_methods[] = { {"__getnewargs__", (PyCFunction)string_getnewargs, METH_NOARGS},