[Python-Dev] Fw: list.index(..) -> TypeError bug or feature?

M.-A. Lemburg mal@lemburg.com
Tue, 06 Feb 2001 19:01:58 +0100


Fredrik Lundh wrote:
> 
> (from comp.lang.python)
> 
> can this be fixed?  should this be fixed?  (please?)

Depends on whether gmpy (what is this, BTW) uses the old coercion
mechanism correctly or not which is hard to say from here ;)

Also, was gmpy recompiled for 2.1a2 and which part raised the
exception (Python or gmpy) ?

In any case, I'd say that .index() should not raise TypeErrors
in case coercion fails.

> </F>
> 
> ----- Original Message -----
> From: "Pearu Peterson" <pearu@cens.ioc.ee>
> Newsgroups: comp.lang.python
> Sent: Tuesday, February 06, 2001 2:42 PM
> Subject: list.index(..) -> TypeError bug or feature?
> 
> >
> > In Python 2.1a2 I get TypeError exception from list index() method even if
> > the list contains given object:
> >
> > >>> from gmpy import mpz
> > >>> a = [mpz(1),[]]
> > >>> a.index([])
> > Traceback (most recent call last):
> >   File "<stdin>", line 1, in ?
> > TypeError: coercion to gmpy.mpz type failed
> >
> > while in Python 2.0b2 it works:
> >
> > >>> a = [mpz(1),[]]
> > >>> a.index([])
> > 1
> >
> > Is this Python 2.1a2 bug or gmpy bug? Or my bug and Python 2.1 feature?
> >
> > Thanks,
> > Pearu
> 
> _______________________________________________
> Python-Dev mailing list
> Python-Dev@python.org
> http://mail.python.org/mailman/listinfo/python-dev

-- 
Marc-Andre Lemburg
______________________________________________________________________
Company:                                        http://www.egenix.com/
Consulting:                                    http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/