summaryrefslogtreecommitdiff
path: root/Lib/test/pickletester.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2014-12-02 00:20:03 +0100
committerAntoine Pitrou <solipsis@pitrou.net>2014-12-02 00:20:03 +0100
commite46e1aeb145d9c607491706251d1e7dd73e0a836 (patch)
treec8ebcdf7df05bb8bb6f451b77fb15bac43245e3e /Lib/test/pickletester.py
parent10f0505d2e51ece507ddfdef2d4a77962227e341 (diff)
downloadcpython-e46e1aeb145d9c607491706251d1e7dd73e0a836.tar.gz
Fix uninitialized variable after #22676.
Diffstat (limited to 'Lib/test/pickletester.py')
-rw-r--r--Lib/test/pickletester.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py
index 5963175ddd..021adcc408 100644
--- a/Lib/test/pickletester.py
+++ b/Lib/test/pickletester.py
@@ -1636,6 +1636,27 @@ class AbstractPickleTests(unittest.TestCase):
unpickled = self.loads(self.dumps(method, proto))
self.assertEqual(method(*args), unpickled(*args))
+ def test_local_lookup_error(self):
+ # Test that whichmodule() errors out cleanly when looking up
+ # an assumed globally-reachable object fails.
+ def f():
+ pass
+ # Since the function is local, lookup will fail
+ for proto in range(0, pickle.HIGHEST_PROTOCOL + 1):
+ with self.assertRaises((AttributeError, pickle.PicklingError)):
+ pickletools.dis(self.dumps(f, proto))
+ # Same without a __module__ attribute (exercises a different path
+ # in _pickle.c).
+ del f.__module__
+ for proto in range(0, pickle.HIGHEST_PROTOCOL + 1):
+ with self.assertRaises((AttributeError, pickle.PicklingError)):
+ pickletools.dis(self.dumps(f, proto))
+ # Yet a different path.
+ f.__name__ = f.__qualname__
+ for proto in range(0, pickle.HIGHEST_PROTOCOL + 1):
+ with self.assertRaises((AttributeError, pickle.PicklingError)):
+ pickletools.dis(self.dumps(f, proto))
+
class BigmemPickleTests(unittest.TestCase):