Fixed issue #1973: bytes.fromhex('') raises SystemError

This commit is contained in:
Christian Heimes 2008-01-30 11:28:29 +00:00
parent c04dac08c4
commit 2c4a07249f
1 changed files with 2 additions and 2 deletions

View File

@ -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},