diff options
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/abstract.c | 12 | ||||
-rw-r--r-- | Objects/object.c | 10 |
2 files changed, 18 insertions, 4 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c index 2acfd08..cae474c 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -933,8 +933,16 @@ PyNumber_Long(PyObject *o) Py_INCREF(o); return o; } - if (PyLong_Check(o)) - return _PyLong_Copy((PyLongObject *)o); + if (PyLong_Check(o)) { + PyObject *res; + + res = _PyLong_Copy((PyLongObject *)o); + if (res != NULL) + ((PyLongObject *)res)->ob_size = + ((PyLongObject *)o)->ob_size; + + return res; + } if (PyString_Check(o)) /* need to do extra error checking that PyLong_FromString() * doesn't do. In particular long('9.5') must raise an diff --git a/Objects/object.c b/Objects/object.c index 5812178..8babf79 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -1191,8 +1191,14 @@ _PyObject_GetDictPtr(PyObject *obj) if (dictoffset == 0) return NULL; if (dictoffset < 0) { - const size_t size = _PyObject_VAR_SIZE(tp, - ((PyVarObject *)obj)->ob_size); + int tsize; + size_t size; + + tsize = ((PyVarObject *)obj)->ob_size; + if (tsize < 0) + tsize = -tsize; + size = _PyObject_VAR_SIZE(tp, tsize); + dictoffset += (long)size; assert(dictoffset > 0); assert(dictoffset % SIZEOF_VOID_P == 0); |