summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pickle.py
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2013-07-01 13:17:45 (GMT)
committerChristian Heimes <christian@cheimes.de>2013-07-01 13:17:45 (GMT)
commita24b4d260beafb5b45450ff46d7740bea8eaa4a9 (patch)
tree377a84158bbfeeb2b38e6714b40fb460a56f8310 /Lib/test/test_pickle.py
parent8a0b7756e28f9374a8a316ca9a81613cc6b6e022 (diff)
downloadcpython-a24b4d260beafb5b45450ff46d7740bea8eaa4a9.zip
cpython-a24b4d260beafb5b45450ff46d7740bea8eaa4a9.tar.gz
cpython-a24b4d260beafb5b45450ff46d7740bea8eaa4a9.tar.bz2
Issue #18339: Negative ints keys in unpickler.memo dict no longer cause a
segfault inside the _pickle C extension.
Diffstat (limited to 'Lib/test/test_pickle.py')
-rw-r--r--Lib/test/test_pickle.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_pickle.py b/Lib/test/test_pickle.py
index f52d4bd..e96fe52 100644
--- a/Lib/test/test_pickle.py
+++ b/Lib/test/test_pickle.py
@@ -115,6 +115,13 @@ if has_c_implementation:
pickler_class = _pickle.Pickler
unpickler_class = _pickle.Unpickler
+ def test_issue18339(self):
+ unpickler = self.unpickler_class(io.BytesIO())
+ self.assertRaises(TypeError, setattr, unpickler, "memo", object)
+ # used to cause a segfault
+ self.assertRaises(ValueError, setattr, unpickler, "memo", {-1: None})
+ unpickler.memo = {1: None}
+
class CDispatchTableTests(AbstractDispatchTableTests):
pickler_class = pickle.Pickler
def get_dispatch_table(self):