def test_issue24097(self):
# Slot name is freed inside __getattr__ and is later used.
class S(str): # Not interned
pass
class A(object):
__slotnames__ = [S('spam')]
def __getattr__(self, attr):
if attr == 'spam':
A.__slotnames__[:] = [S('spam')]
return 42
else:
raise AttributeError
import copy_reg
expected = (copy_reg.__newobj__, (A,), ({}, {'spam': 42}), None, None)
self.assertEqual(A().__reduce__(2), expected)
评论列表
文章目录