mengzurui / dpkt

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

Pickle Error Slots #71

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Read in a pcap file with IPv4 frames
2. Create ethernet object dpkt.ethernet.Ethernet(eth)
3. Try to pickle it "pickle.dump(eth_cls,file)"

What is the expected output? What do you see instead?
I expect that the data be pickled. Output is this 

TypeError: a class that defines __slots__ without defining __getstate__ cannot 
be pickled

What version of the product are you using? On what operating system?
dpkt version 1.7 on windows Vista with Python 2.6

Please provide any additional information below.
I tried removing the __slots__ attribute from the _MetaPacket class in the dpkt 
module and adding the dynamically attributes to the dictionary directly which 
did allow me to pickle the class. However this then cause the actual data frame 
to be stored twice in the __dict__ which increases the size. I am sure they is 
a better way to accomplish this but I am unfamailar with how meta classes work 
and didn't want to break anything. 

Original issue reported on code.google.com by menyl...@gmail.com on 18 Apr 2011 at 9:26