Possible bug with TypeError in Python

Anoop Chandran anoopcj at gmail.com
Wed Jan 30 14:04:21 UTC 2008


On Jan 30, 2008 7:28 PM, Mark C. Allman <mcallman at allmanpc.com> wrote:

>
> On Wed, 2008-01-30 at 07:40 -0600, Aaron Konstam wrote:
> > The following seems like an bug in python in both f7 and f8 but I would
> > like input before I post a bugzilla. It seems the exception handler
> > cannot trap the TypeError in python.
> > For example:
> > def plus(a,b):
> >       try:
> >               return(a+b)
> >       except TypeError:
> >               return None
> >
> > If we define plus as above and call it with: plus(3,) we should get
> > nothing returned. Instead we get:
> > Traceback (most recent call last):
> >   File "./calculator", line 47, in <module>
> >     exec("register=op[tokens[0]](register)")
> >   File "<string>", line 1, in <module>
> > TypeError: plus() takes exactly 2 arguments (1 given)
> >
> > This seems like a bug. An ideas out there?
> > --
> > =======================================================================
> > Please keep your hands off the secretary's reproducing equipment.
> > =======================================================================
> > Aaron Konstam telephone: (210) 656-0355 e-mail: akonstam at sbcglobal.net
> >
> If I remember right, the exception is occurring before the actual call
> into "plus()."  Try:
>    plus(3,"My String");
> and you should see the TypeError.
>


try:
  a = plus(3)
except TypeError:
  a = 0
print a

Output should be 0..



> -- Mark C. Allman, PMP
> -- Allman Professional Consulting, Inc.
> -- www.allmanpc.com, 617-947-4263
>
> BusinessMsg -- the secure, managed, J2EE/AJAX Enterprise IM/IC solution
>
>
>
>
> --
> fedora-list mailing list
> fedora-list at redhat.com
> To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
>



-- 
- Anoop
 <>_<>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/fedora-list/attachments/20080130/73dd7ccd/attachment-0001.htm>


More information about the fedora-list mailing list