| Store | Cart

[Python-Dev] Exception for setting attributes of built-in type

From: Terry Reedy <tjre...@udel.edu>
Sun, 14 Jun 2009 18:40:56 -0400
Seo Sanghyeon wrote:
> Exception for setting attributes of built-in type differs between> CPython and IronPython. This is not purely theoretical, as> zope.interface tries to set Implements declaration as __implemented__> attribute of built-in type object, and excepts TypeError.> > Python 2.6.1>>>> object.flag = True> TypeError: can't set attributes of built-in/extension type 'object'> > IronPython 2.6>>>> object.flag = True> AttributeError: 'object' object has no attribute 'flag'> > I was surprised that CPython raises TypeError. Library Reference seems> to mention it here:> > exception AttributeError> Raised when an attribute reference or assignment fails. (When an> object does not support attribute references or attribute assignments> at all, TypeError is raised.)> http://docs.python.org/library/exceptions.html> > What does it mean that "an object does not support attribute> references or attribute assignments at all"?

I see it as slightly ambiguous:
1. It neither supports references nor assignments.
2. It either does not support reference or it does not support assignments.

1 could hardly apply any more, certainly to built-ins since everything 
now has attributes.  2 covers object, so if that is meant, then 
TypeError is appropriate.

Or were you unclear about 'at all', which means 'never'?

Terry Jan Reedy

Recent Messages in this Thread
Seo Sanghyeon Jun 14, 2009 07:09 pm
Terry Reedy Jun 14, 2009 10:40 pm
MRAB Jun 14, 2009 10:42 pm
Guido van Rossum Jun 14, 2009 11:19 pm
Nick Coghlan Jun 15, 2009 11:27 am
Benjamin Peterson Jun 15, 2009 07:09 pm
Nick Coghlan Jun 15, 2009 09:31 pm
Guido van Rossum Jun 15, 2009 02:48 pm
Dino Viehland Jun 15, 2009 03:54 pm
Michael Foord Jun 15, 2009 04:10 pm
Guido van Rossum Jun 15, 2009 05:10 pm
Michael Foord Jun 15, 2009 05:20 pm
Dino Viehland Jul 02, 2009 11:45 pm
Messages in this thread