NewLionwang / dpkt

Automatically exported from code.google.com/p/dpkt
Other
0 stars 0 forks source link

Building from sources Error (Python 2.6.4 [GCC 3.4.6]) #29

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. # python setup.py install

What is the expected output? What do you see instead?
  File "setup.py", line 4, in <module>
    import dpkt
  File "/home/super/dpkt-1.6/dpkt/__init__.py", line 17, in <module>
    import bgp
  File "/home/super/dpkt-1.6/dpkt/bgp.py", line 678
    self.failUnless(c.as == 65215)
                       ^
SyntaxError: invalid syntax

What version of the product are you using? On what operating system?
Python 2.6.4 [GCC 3.4.6]
Kernel: 2.6.10-72032U10_12clsmp (too old, but necessary for the moment)

Please provide any additional information below.

This is an syntax error because of attribute named "as" what is an python
reserved word, i make some changes in the file "bgp.py" and all works
pretty, the patch file is in attachment.

Original issue reported on code.google.com by allisonv...@gmail.com on 4 Feb 2010 at 12:30

Attachments:

GoogleCodeExporter commented 8 years ago
No need to DL the file below.

Go to line 143, within class Open(dpkt.Packet)
Change   ('as', 'H', 0),   to   ('asn', 'H', 0),

Go to line 404, within class Aggregator(dpkt.Packet)
change   ('as', 'H', 0),   to   ('asn', 'H', 0),

Go to line 431, within class Community(dpkt.Packet)
change   ('as', 'H', 0),   to   ('asn', 'H', 0),

Go to line 678, with the testUnpack(self) function within the BGPTestCase class
change   self.failUnless(c.as == 65215)  to  self.failUnless(c.asn == 65215)

Go to line 715, within the same code segment as listed above
change   self.failUnless(b4.open.as == 237)  to  self.failUnless(b4.open.asn == 
237)

Takes maybe 15 seconds. you can search/replace subsets of the string  "as" 
with "asn", but don't do a blanket replace-all as there are some as_<name> 
items in 
this function as well.

Original comment by thedepar...@gmail.com on 8 Feb 2010 at 10:41

GoogleCodeExporter commented 8 years ago
c.__setattr__('as', 65215)

Original comment by and...@gmail.com on 28 Feb 2010 at 7:23

GoogleCodeExporter commented 8 years ago
I am confused.  I was hoping to use dpkt for some real work...does it work?  It 
seems
like a really big problem that the project was using a reserved word as an
identifier.  How has it ever worked??

Thanks,

-kb

Original comment by kentb...@borg.org on 24 Mar 2010 at 2:08

GoogleCodeExporter commented 8 years ago
Use SVN.

http://code.google.com/p/dpkt/source/detail?r=51

Original comment by jon.ober...@gmail.com on 24 Mar 2010 at 2:25