[Python-Dev] Inconsistent exception for read-only properties?
jack at performancedrivers.com
Sun Apr 17 17:53:31 CEST 2005
On Sat, Apr 16, 2005 at 07:24:27PM -0400, Barry Warsaw wrote:
> On Thu, 2005-04-14 at 23:46, Barry Warsaw wrote:
> > I've noticed an apparent inconsistency in the exception thrown for
> > read-only properties for C extension types vs. Python new-style
> > classes.
> I haven't seen any follow ups on this, so I've gone ahead and posted a
> patch, assigning it to Raymond:
In 2.4 & 2.3 does it make sense to raise an exception that multiply inherits
from both TypeError and AttributeError? If anyone currently does catch the
error raising only AttributeError will break their code. 2.5 should just
raise an AttributeError, of course.
If that's acceptable I'll gladly submit a similar patch for mmap.get_byte()
PyErr_SetString (PyExc_ValueError, "read byte out of range");
has always irked me (the same thing with mmap[i] is an IndexError).
I hadn't thought of a clean way to fix it, but MI on the error might work.
More information about the Python-Dev