]> granicus.if.org Git - python/commitdiff
Fixed issue #1973: bytes.fromhex('') raises SystemError
authorChristian Heimes <christian@cheimes.de>
Wed, 30 Jan 2008 11:28:29 +0000 (11:28 +0000)
committerChristian Heimes <christian@cheimes.de>
Wed, 30 Jan 2008 11:28:29 +0000 (11:28 +0000)
Objects/stringobject.c

index 011fc323abde7d010d1b33063e3ba08a2e122306..d714a779ee488ec88af3f42e25c080898ed265db 100644 (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));
 }
 
-\f
+
 static PyMethodDef
 string_methods[] = {
        {"__getnewargs__",      (PyCFunction)string_getnewargs, METH_NOARGS},