limifly / pypcap

Exported from
http://code.google.com/p/pypcap
Other
0 stars 0 forks source link

Exception errors with python 2.5 #3

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Build pypcap-1.1 from source using Ubuntu and python 2.5

$ sudo python setup.py config
$ sudo pyhton setup.py build
$ sudo python setup.py install

2. Do anything that generates an exception

I've had the same issues building from source on OS X using MacPython 2.5,
but the .dmg on this site works fine so I assume this a build issue somehow.

What is the expected output? What do you see instead?

ubuntu-vm:~ 640: uname -a                  
Linux ubuntu-vm 2.6.20-15-generic #2 SMP Sun Apr 15 07:36:31 UTC 2007 i686
GNU/Linux

ubnntu-vm:~/honeynet/test_data 645: python                                

Python 2.5.1c1 (release25-maint, Apr 12 2007, 21:00:25) 
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pcap
>>> p = pcap.pcap("not a file")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pcap.pyx", line 180, in pcap.pcap.__init__
TypeError: exceptions must be strings, classes, or instances, not type
>>> p = pcap.pcap("pcap.20050922")
>>> count = 0
>>> for ts, buf in p:
...     count += 1
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pcap.pyx", line 346, in pcap.pcap.__next__
TypeError: exceptions must be strings, classes, or instances, not type
>>> 

What version of the product are you using? On what operating system?

1.1 on OS X and Ubuntu 7. Python 2.5 (as above) with pyrexc 0.9.4.1

Please provide any additional information below.

Original issue reported on code.google.com by art...@honeynet.org.uk on 21 Apr 2007 at 2:43

GoogleCodeExporter commented 9 years ago
something like this might suffice...

--- pypcap-1.1/pcap.pyx 2005-10-16 18:00:11.000000000 -0500
+++ pypcap-1.1-new/pcap.pyx     2007-06-12 11:11:41.000000000 -0500
@@ -285,7 +285,7 @@
                           <unsigned char *>&ctx)
         if ctx.got_exc:
             exc = sys.exc_info()
-            raise exc[0], exc[1], exc[2]
+            raise OSError, "%s [%s]" % (exc[0], exc[1]), exc[2]
         return n

     def loop(self, callback, *args):

Original comment by yard...@gmail.com on 12 Jun 2007 at 4:14

GoogleCodeExporter commented 9 years ago

The problem is the pcap.c is shipped in the tarball. On linux, deleting pcap.c 
then
running

make all

solves the problem.

Arthur

Original comment by art...@honeynet.org.uk on 11 Aug 2007 at 5:10

GoogleCodeExporter commented 9 years ago
yep, sorry about that Arthur - pcap.c in the 1.1 release generated by an older
version of Pyrex, pre-Python 2.5. it took some time for the exception handling 
to be
updated properly in Pyrex for Python 2.5, and it was not originally done in a
backward-compatible manner.

you'll note that the binary MacOS X and win32 builds for Python 2.5 work fine - 
for
those builds, i used the updated Pyrex, but used the older version for Python 
2.3 and
2.4.

i committed a pcap.c generated with the latest Pyrex back in March, but never 
cut a
new release. i'll go ahead and do that soon...

Original comment by dugsong on 16 Aug 2007 at 3:01

GoogleCodeExporter commented 9 years ago
This doesn't appear to be fixed on OS X yet.

I had to download the source of Pyrex from 
http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/ and install this 
module as root on my system (apparently Pyrex doesn't play nicely with virtual 
environments and complains like this: ImportError: No module named 
Pyrex.Compiler.Main) before running `make all` to generate a new pcap.c file.

After generating new pcap.c file I was able to install the module correctly.

Original comment by shols...@gmail.com on 15 Jul 2013 at 12:04