[Python-Dev] Exception for setting attributes of built-in type (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Mon Jun 15 13:27:24 CEST 2009
- Previous message: [Python-Dev] Exception for setting attributes of built-in type
- Next message: [Python-Dev] Exception for setting attributes of built-in type
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Guido van Rossum wrote:
In general, CPython isn't always consistent in raising AttributeError and TypeError when it comes to such policy issues: there are various places that raise TypeError in typeobject.c (and probably elsewhere) that simply forbid setting a specific attribute (another example is name).
We're pretty inconsistent when it comes to looking up special methods as well - those that are looked up through dedicated slots in abstract.c usually raise TypeError, while those that are looked up via a PyType method usually raise AttributeError.
I'm not sure that there is any practical way to handle that other than for applications that care about cross-implementation compatibility in this area to catch a (TypeError, AttributeError) tuple rather than one or the other.
CHeers, Nick.
-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- Previous message: [Python-Dev] Exception for setting attributes of built-in type
- Next message: [Python-Dev] Exception for setting attributes of built-in type
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]