[pypy-issue] [issue1122] [cpyext] PyVarObject builtins and definition of Py_SIZE()
tracker at bugs.pypy.org
Wed Apr 11 10:52:31 CEST 2012
Stefan Behnel <stefan_ml at behnel.de> added the comment:
No, not meant as a contradiction. I think it's rather rare that user code would
call Py_SIZE() on builtin types that have their well and much more prominently
documented dedicated macros (Py_SIZE() is a rather new addition in comparison).
I find it more important that user code that implements PyVarObjects and calls
Py_SIZE() on them works as expected, regardless of the value in tp_itemsize.
I'm not strictly objecting, but I see it as an indirect condition that may not
work for all user code, so there is a certain risk that it makes the behaviour
of the macro less predictable, both by making it work substantially different in
some cases (in CPython, it never calls __len__(), which may execute arbitrary
code and fail) and by posing it on the assumption that all PyVarObjects have a
non-zero tp_itemsize, which will usually be the case, but is not a strict
requirement, e.g. for constant objects of length 0.
My intuition is that it's easier to control builtins than to know what
assumptions user code makes.
PyPy bug tracker <tracker at bugs.pypy.org>
More information about the pypy-issue