[Python-Dev] Py_TPFLAGS_HEAPTYPE too overloaded

Nick Coghlan ncoghlan at gmail.com
Tue Jul 28 13:26:58 CEST 2009


Greg Ewing wrote:
> The only real concern would be if it were somehow possible to crash
> the interpreter by modifying the type dict. I don't see how that
> could happen -- but maybe someone else on python-dev knows more about
> this?

I believe a major part of the issue is that attempting to answer the
question "Will allowing mutating operation *X* on
object/type/float/int/etc create any interpreter stability or security
problems?" is awfully close to trying to prove a negative.

Certainly, at least some of the "generic" operations involving types
include additional sanity checks that are bypassed for the builtin types.

One specific example I can think of is that object.__hash__ is special
cased in a few places due to the way its definition interacts with the
definition of comparison operations. Allowing changes to the contents of
object's tp_hash slot could lead to much weirdness when it came to
__hash__ inheritance.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------


More information about the Python-Dev mailing list