Re: TypeError: exceptions must be strings, classes, or instances, not type

Lenard Lindstrom <[email protected]>
Newsgroups gmane.comp.python.pyrex
Message-ID <[email protected]>
Quoting Yang Zhang <[email protected]>:

> Yang Zhang wrote:
> > Hi, I'm trying to use this Pyrex module:
> > 
> > http://code.google.com/p/pypcap/
> > 
> > but I get:
> > 
> > Traceback (most recent call last):
> >   File "./analyze.py", line 11, in <module>
> >     for x in pc: xs.append(x)
> >   File "pcap.pyx", line 346, in pcap.pcap.__next__
> > TypeError: exceptions must be strings, classes, or instances, not type
> > 
> > because the places marked "here" below are apparently doing something 
> > that Pyrex can't handle:
> > 
> >     def __next__(self):
[snip code]
> >             elif n == -1:
> >                 raise KeyboardInterrupt # here
> >             elif n == -2:
> >                 raise StopIteration # here
> > 
> > Does anybody know what's going on? Are exceptions not allowed in Pyrex? 
> > Is there a workaround?
> > 
> > Thanks in advance for any answers!
> 
> Just to clarify: I also retried with the latest pyrex (0.9.6.4), with 
> the same results.  Also I'm using Python 2.5 on Ubuntu 7.10 (I tried 
> with the distro-supplied pyrex initially).
> 
Exceptions can be raised in Pyrex just as in Python, with an instance of an 
exception type:

                 raise KeyboardInterrupt("optional message goes here")


-- 
Lenard Lindstrom
<[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.