summaryrefslogtreecommitdiffstats
path: root/Objects/longobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/longobject.c')
-rw-r--r--Objects/longobject.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c
index 1db4ca4..51ac869 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -5638,6 +5638,11 @@ long_subtype_new(PyTypeObject *type, PyObject *x, PyObject *obase)
n = Py_SIZE(tmp);
if (n < 0)
n = -n;
+ /* Fast operations for single digit integers (including zero)
+ * assume that there is always at least one digit present. */
+ if (n == 0) {
+ n = 1;
+ }
newobj = (PyLongObject *)type->tp_alloc(type, n);
if (newobj == NULL) {
Py_DECREF(tmp);