[Python-Dev] 2.4.4: backport classobject.c HAVE_WEAKREFS?
"Martin v. Löwis"
martin at v.loewis.de
Wed Oct 11 06:15:20 CEST 2006
Raymond Hettinger schrieb:
>> the slightly obscure bit that requires some getting used to is
>> that all these flags don't really mean "I have such and such
>> feature" but just "I could have such and such
>> feature, if the corresponding tp_xxx field were set".
> I would like to see that cleaned-up for Py3k. Ideally, the NULL or
> non_NULL status of a slot should serve as its flag.
The flag indicates that the field is even present. If you have
an extension module from an earlier Python release (in binary
form), it won't *have* the field, so you can't test whether it's
null. Accessing it will get to some other place in the data
segment, and interpreting it as a function pointer will cause
a crash. That's why the flags where initially introduced;
presence of the flag indicates that the field was there at
Of course, if everybody would always recompile all extension modules
for a new Python feature release, those flags weren't necessary.
More information about the Python-Dev