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

Tim Peters tim.one@comcast.net
Sat, 02 Mar 2002 14:15:20 -0500


[Guido, on _PyLong_Copy()]
> I had misread the code and thought that long_pos() was depending on
> this property.  But it isn't -- I somehow confused long_pos and
> long_abs.

Ah, understandable.  I'm glad we were looking at the same thing.

> So thanks for fixing this.

My pleasure.

[on whether longs should use PyObject_VAR_HEAD]
> I have half a feeling that the header was explicitly not using
> VAR_HEAD because it isn't quite a standard variable size object.  But
> since PyLong_Type sets tp_itemsize, it really should be defined a
> variable size object.

In 2.2, pointers to long subtype instances can get cast to PyVarObject*, so
I changed the decl to use VAR_HEAD, and added a caution there about the sign
bit.

> I wonder if there could be places where the assumption ob_size >= 0 is
> made.  (I checked _PyObject_GetDictPtr() and it correctly checks for
> tsize < 0.)

That's the only place I found that I believe can cast a pointer to a long
subtype instance to a PyVarObject*.  There are several hundred instances of
ob_size in the codebase, though, so I wouldn't call this proof <wink>.