Reputation: 1
I had worked on a program in Python2.7 and need to retool it for Python 2.6.6. I made some minor changes but receive this error when trying to compile. Has anyone ran into this before? I couldn't find very much on Google. Any help would be appreciated
Traceback (most recent call last):
File "makexml.py", line 13, in <module>
from scapy.all import rdpcap
File "/user/.pyenv/versions/2.6.6/lib/python2.6/site-
packages/scapy/all.py", line 11, in <module>
from scapy.config import *
File "/user/.pyenv/versions/2.6.6/lib/python2.6/site-
packages/scapy/config.py", line 84
self.layers = {owner for f in self.fields for owner in f.owners}
^
SyntaxError: invalid syntax
Upvotes: 0
Views: 566
Reputation: 6237
Scapy 2.4.0 is not compatible with Python 2.6. You should downgrade Scapy to 2.3.3, which has Python 2.6 (and 2.5, I think) support.
Upvotes: 0
Reputation: 366133
Set comprehensions are a new feature from Python 3 that got backported to Python 2.7.
So if you try to use one in an earlier version, you get a SyntaxError
.
The simplest change is to pass a generator expression to the set
constructor:
self.layers = set(owner for f in self.fields for owner in f.owners)
(This will work all the way back to 2.4. Before that, there's no builtin set
, and no generator expressions, but you'd probably have bigger problems with, e.g., exceptions…)
Upvotes: 1