Skip to content

Pickle is not working for scapy.compat.NamedTuple on python < 3.7 #3126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
polybassa opened this issue Mar 8, 2021 · 1 comment
Closed
Labels

Comments

@polybassa
Copy link
Contributor

This issue is already discussed in #3113.

Here is a patch to add a suitable test-case, since I'll close #3113.
#3113 is not a ready PR and I have no idea how to modify namedtuple, to fix this issue.

cat 0001-Add-pickle-test-for-PacketList.patch

From 27026f286c76dadf29aa2ae108d4edc7977895c0 Mon Sep 17 00:00:00 2001
From: Nils Weiss <[email protected]>
Date: Wed, 24 Feb 2021 10:15:50 +0100
Subject: [PATCH] Add pickle test for PacketList

---
 test/regression.uts | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/test/regression.uts b/test/regression.uts
index 22326e00..6fe86608 100644
--- a/test/regression.uts
+++ b/test/regression.uts
@@ -4224,6 +4224,22 @@ srl, rl = pl.sr(lookahead=None)
 assert len(srl) == 1
 assert len(rl) == 7
 
+= pickle test
+import pickle
+import io
+
+srl, rl = PacketList([Raw(b"1"), Raw(b"1"), Raw(b"2"), Raw(b"3"), Raw(b"4"), Raw(b"3"), Raw(b"1"), Raw(b"1"), Raw(b"4")]).sr()
+assert len(srl) == 4
+
+f = io.BytesIO()
+
+pickle.dump(srl, f)
+
+unp = pickle.loads(f.getvalue())
+
+assert len(unp) == len(srl)
+assert all(bytes(a[0]) == bytes(b[0]) for a, b in zip(unp, srl))
+
 = plot()
 
 import mock
-- 
2.30.0
@gpotter2 gpotter2 added the bug label Mar 11, 2021
@gpotter2
Copy link
Member

fixed in #3113

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants