test_scope.py 文件源码

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

项目:zippy 作者: securesystemslab 项目源码 文件源码
def testLocalsClass_WithTrace(self):
        # Issue23728: after the trace function returns, the locals()
        # dictionary is used to update all variables, this used to
        # include free variables. But in class statements, free
        # variables are not inserted...
        import sys
        sys.settrace(lambda a,b,c:None)
        try:
            x = 12

            class C:
                def f(self):
                    return x

            self.assertEqual(x, 12) # Used to raise UnboundLocalError
        finally:
            sys.settrace(None)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号