Bugs item #1687163, was opened at 2007-03-23 17:51
Message generated for change (Comment added) made by jackdied
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1687163&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Raymond Hettinger (rhettinger)
Assigned to: Nobody/Anonymous (nobody)
Summary: Inconsistent Exceptions for Readonly Attributes

Initial Comment:
Attempting assignment to a readonly attribute raises an Attribute error for 
pure Python attributes but raises a TypeError for C readonly attributes.  I 
think the AttributeError is the correct exception.



>>> class A(object):
...     _x = []
...
...     @property
...     def x(self):
...             return self._x
...     
>>> a = A()
>>> a.x = None

Traceback (most recent call last):
    a.x = None
AttributeError: can't set attribute




>>> def f():
...     yield None
>>> g = f()
>>> g.gi_frame = None

Traceback (most recent call last):
    g.gi_frame = None
TypeError: readonly attribute

----------------------------------------------------------------------

>Comment By: Jack Diederich (jackdied)
Date: 2007-03-23 18:12

Message:
Logged In: YES 
user_id=591932
Originator: NO

I think this has something peculiar to frames, for instance:

Python 2.5 (r25:51908, Sep 25 2006, 17:50:07) 
[GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> f = 'asdf'
>>> f.strip = 42
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'str' object attribute 'strip' is read-only
>>> 


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1687163&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to