Re: TypeError: exceptions must be strings, classes, or instances, not type
Yang Zhang <[email protected]>
| Newsgroups | gmane.comp.python.pyrex |
|---|---|
| Message-ID | <[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): > 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! 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). -- Yang Zhang http://www.mit.edu/~y_z/