On Sun, Apr 17, 2005 at 11:53:31AM -0400, Jack Diederich wrote:
> 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:
> > 
> > http://sourceforge.net/tracker/index.php?func=detail&aid=1184449&group_id=5470&atid=105470
> > 
> 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.
> 

I just did a quick grep for raised ValueErrors with "range" in the
explanation string and didn't find any general consensus.  I dunno what 
that means, if anything.

wopr:~/src/python_head/dist/src# find ./ -name '*.c' | xargs grep ValueError | 
grep range | wc -l
13
wopr:~/src/python_head/dist/src# find ./ -name '*.c' | xargs grep IndexError | 
grep range | wc -l
31

(long versions below)

-jackdied

wopr:~/src/python_head/dist/src# find ./ -name '*.c' | xargs grep -n IndexError 
| grep range 
./Modules/arraymodule.c:599:            PyErr_SetString(PyExc_IndexError, 
"array index out of range");
./Modules/arraymodule.c:997:            PyErr_SetString(PyExc_IndexError, "pop 
index out of range");
./Modules/mmapmodule.c:639:             PyErr_SetString(PyExc_IndexError, "mmap 
index out of range");
./Modules/mmapmodule.c:727:             PyErr_SetString(PyExc_IndexError, "mmap 
index out of range");
./Modules/_heapqmodule.c:19:            PyErr_SetString(PyExc_IndexError, 
"index out of range");
./Modules/_heapqmodule.c:58:            PyErr_SetString(PyExc_IndexError, 
"index out of range");
./Modules/_heapqmodule.c:136:           PyErr_SetString(PyExc_IndexError, 
"index out of range");
./Modules/_heapqmodule.c:173:           PyErr_SetString(PyExc_IndexError, 
"index out of range");
./Modules/_heapqmodule.c:310:           PyErr_SetString(PyExc_IndexError, 
"index out of range");
./Modules/_heapqmodule.c:349:           PyErr_SetString(PyExc_IndexError, 
"index out of range");
./Objects/bufferobject.c:403:           PyErr_SetString(PyExc_IndexError, 
"buffer index out of range");
./Objects/listobject.c:876:             PyErr_SetString(PyExc_IndexError, "pop 
index out of range");
./Objects/rangeobject.c:94:             PyErr_SetString(PyExc_IndexError,
./Objects/stringobject.c:1055:          PyErr_SetString(PyExc_IndexError, 
"string index out of range");
./Objects/structseq.c:62:               PyErr_SetString(PyExc_IndexError, 
"tuple index out of range");
./Objects/tupleobject.c:104:            PyErr_SetString(PyExc_IndexError, 
"tuple index out of range");
./Objects/tupleobject.c:310:            PyErr_SetString(PyExc_IndexError, 
"tuple index out of range");
./Objects/unicodeobject.c:5164:        PyErr_SetString(PyExc_IndexError, 
"string index out of range");
./Python/exceptions.c:1504:PyDoc_STRVAR(IndexError__doc__, "Sequence index out 
of range.");
./RISCOS/Modules/drawfmodule.c:534:  { PyErr_SetString(PyExc_IndexError,"drawf 
index out of range");
./RISCOS/Modules/drawfmodule.c:555:  { PyErr_SetString(PyExc_IndexError,"drawf 
index out of range");
./RISCOS/Modules/drawfmodule.c:578:  { PyErr_SetString(PyExc_IndexError,"drawf 
index out of range");
./RISCOS/Modules/swimodule.c:113:  { PyErr_SetString(PyExc_IndexError,"block 
index out of range");
./RISCOS/Modules/swimodule.c:124:  { PyErr_SetString(PyExc_IndexError,"block 
index out of range");
./RISCOS/Modules/swimodule.c:136:  { PyErr_SetString(PyExc_IndexError,"block 
index out of range");
./RISCOS/Modules/swimodule.c:150:  { PyErr_SetString(PyExc_IndexError,"block 
index out of range");
./RISCOS/Modules/swimodule.c:164:  { PyErr_SetString(PyExc_IndexError,"block 
index out of range");
./RISCOS/Modules/swimodule.c:225:  { PyErr_SetString(PyExc_IndexError,"block 
index out of range");
./RISCOS/Modules/swimodule.c:237:  { PyErr_SetString(PyExc_IndexError,"block 
index out of range");
./RISCOS/Modules/swimodule.c:248:  { PyErr_SetString(PyExc_IndexError,"block 
index out of range");
./RISCOS/Modules/swimodule.c:264:  { PyErr_SetString(PyExc_IndexError,"block 
index out of range");
wopr:~/src/python_head/dist/src# find ./ -name '*.c' | xargs grep -n ValueError 
| grep range
./Modules/mmapmodule.c:181:             PyErr_SetString (PyExc_ValueError, 
"read byte out of range");
./Modules/mmapmodule.c:301:             PyErr_SetString (PyExc_ValueError, 
"data out of range");
./Modules/mmapmodule.c:524:     PyErr_SetString (PyExc_ValueError, "seek out of 
range");
./Modules/timemodule.c:405:            PyErr_SetString(PyExc_ValueError, "month 
out of range");
./Modules/timemodule.c:409:            PyErr_SetString(PyExc_ValueError, "day 
of month out of range");
./Modules/timemodule.c:413:            PyErr_SetString(PyExc_ValueError, "hour 
out of range");
./Modules/timemodule.c:417:            PyErr_SetString(PyExc_ValueError, 
"minute out of range");
./Modules/timemodule.c:421:            PyErr_SetString(PyExc_ValueError, 
"seconds out of range");
./Modules/timemodule.c:427:            PyErr_SetString(PyExc_ValueError, "day 
of week out of range");
./Modules/timemodule.c:431:            PyErr_SetString(PyExc_ValueError, "day 
of year out of range");
./Objects/rangeobject.c:61:             PyErr_SetString(PyExc_ValueError, 
"xrange() arg 3 must not be zero");
./Objects/rangeobject.c:106:            PyErr_SetString(PyExc_ValueError,
./RISCOS/Modules/drawfmodule.c:450:      { 
PyErr_SetString(PyExc_ValueError,"Object out of range");
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to