summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-11-25 16:34:19 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-11-25 16:34:19 (GMT)
commit670d78abc5b9a9780677c9f1d51dcd543b15e0f7 (patch)
tree2eb1e4c7490c55058e9c88d803f6d1ebd546c9ab /Lib
parent2cefc1efa2fc74da0ec1b79f75639b76ac8e6dfd (diff)
parentd28bb624d120466ba5ebdf5063286b2f309283ab (diff)
downloadcpython-670d78abc5b9a9780677c9f1d51dcd543b15e0f7.zip
cpython-670d78abc5b9a9780677c9f1d51dcd543b15e0f7.tar.gz
cpython-670d78abc5b9a9780677c9f1d51dcd543b15e0f7.tar.bz2
Issue #24097: Fixed crash in object.__reduce__() if slot name is freed inside
__getattr__. Original patch by Antoine Pitrou.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_descr.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index d096390..f5e4b02 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -5092,6 +5092,23 @@ class PicklingTests(unittest.TestCase):
objcopy2 = deepcopy(objcopy)
self._assert_is_copy(obj, objcopy2)
+ def test_issue24097(self):
+ # Slot name is freed inside __getattr__ and is later used.
+ class S(str): # Not interned
+ pass
+ class A:
+ __slotnames__ = [S('spam')]
+ def __getattr__(self, attr):
+ if attr == 'spam':
+ A.__slotnames__[:] = [S('spam')]
+ return 42
+ else:
+ raise AttributeError
+
+ import copyreg
+ expected = (copyreg.__newobj__, (A,), (None, {'spam': 42}), None, None)
+ self.assertEqual(A().__reduce__(2), expected) # Shouldn't crash
+
class SharedKeyTests(unittest.TestCase):