[Pyrex] TypeError: exceptions must be strings, classes, or instances, not type
Yang Zhang
yanghatespam at gmail.com
Tue Apr 22 20:27:42 CEST 2008
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/
More information about the Pyrex
mailing list