test_descr.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号