Message7650

Author amak
Recipients amak, mete0r
Date 2013-02-09.14:36:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1360420597.44.0.314292602638.issue1985@psf.upfronthosting.co.za>
In-reply-to
Content
Fixing this would require breaking some tests we take from cpython.

The code reads

/////////
    public void readonlyAttributeError(String name) {
        // XXX: Should be an AttributeError but CPython throws TypeError for read only
        // member descriptors (in structmember.c::PyMember_SetOne), which is expected by a
        // few tests. fixed in py3k: http://bugs.python.org/issue1687163
        throw Py.TypeError("readonly attribute");
    }
/////

The problem is described in detail in this bug

Inconsistent Exceptions for Readonly Attributes
http://bugs.python.org/issue1687163

So we won't be able to fix this in 2.x without breaking tests.

What problems does this create for you?

Can you change your exception handling slightly to work around it? i.e.

try:
    A().attr = 2
except (AttributeError, TypeError):
    print "That was a read-only attribute"

or even

try:
    A().attr = 2
except TypeError, t:
    if t.message == "readonly attribute":
        raise AttributeError(t)
History
Date User Action Args
2013-02-09 14:36:37amaksetmessageid: <1360420597.44.0.314292602638.issue1985@psf.upfronthosting.co.za>
2013-02-09 14:36:37amaksetrecipients: + amak, mete0r
2013-02-09 14:36:37amaklinkissue1985 messages
2013-02-09 14:36:37amakcreate