[Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.114,1.115

Tim Peters tim.one@comcast.net
Fri, 01 Mar 2002 18:18:34 -0500


[Guido]
> Due to the bizarre definition of _PyLong_Copy(), creating an instance
> of a subclass of long with a negative value could cause core dumps
> later on.  Unfortunately it looks like the behavior of _PyLong_Copy()
> is quite intentional, so the fix is more work than feels comfortable.

What specifically is bizarre?  Looks to me like _PyLong_Copy() is plain
wrong, and I probably wrote it <wink>.

		result->ob_size = i;

should be

		result->ob_size = src->ob_size;

if I'm guessing what bizarre means to you.

Is that what you mean, or something else?

The bizarreness *begins* with that _longobject fakes a PyObject_VAR_HEAD
header by hand, then abuses the ob_size member to store the sign bit of the
long as well as the number of bytes.  So I expect there was more than one
bug here (and that _PyLong_Copy() is one of them).