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

Yang Zhang <[email protected]>
Newsgroups gmane.comp.python.pyrex
Message-ID <[email protected]>
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):
         cdef pcap_pkthdr *hdr
         cdef char *pkt
         cdef int n
         while 1:
             Py_BEGIN_ALLOW_THREADS
             n = pcap_ex_next(self.__pcap, &hdr, &pkt)
             Py_END_ALLOW_THREADS
             if n == 1:
                 return (hdr.ts.tv_sec + (hdr.ts.tv_usec / 1000000.0),
                         PyBuffer_FromMemory(pkt, hdr.caplen))
             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!
-- 
Yang Zhang
http://www.mit.edu/~y_z/
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.