summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Objects/longobject.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c
index 7e12b34..f452840 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -4285,8 +4285,8 @@ long_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
string = PyByteArray_AS_STRING(x);
else
string = PyBytes_AS_STRING(x);
- if (strlen(string) != (size_t)size) {
- /* We only see this if there's a null byte in x,
+ if (strlen(string) != (size_t)size || !size) {
+ /* We only see this if there's a null byte in x or x is empty,
x is a bytes or buffer, *and* a base is given. */
PyErr_Format(PyExc_ValueError,
"invalid literal for int() with base %d: %R",