HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/test/__pycache__/test_scope.cpython-37.pyc
B

��g�N�@sFddlZddlZddlmZmZGdd�dej�ZedkrBe��dS)�N)�check_syntax_error�cpython_onlyc@sHeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zed-d.��Zd/d0�Zed1d2��Zd3d4�Zd5d6�Zd7d8�Zd9d:�Z d;d<�Z!d=d>�Z"d?d@�Z#dAdB�Z$dCdD�Z%dEdF�Z&dGdH�Z'dIdJ�Z(edKdL��Z)dMS)N�
ScopeTestscCs<dd�}|d�}|d�}|�|d�d�|�|d�d�dS)Ncs�fdd�}|S)Ncs�|S)N�)�y)�xr�+/usr/local/lib/python3.7/test/test_scope.py�addersz?ScopeTests.testSimpleNesting.<locals>.make_adder.<locals>.adderr)rr	r)rr�
make_addersz0ScopeTests.testSimpleNesting.<locals>.make_adder��
�����)�assertEqual)�selfr
�inc�plus10rrr�testSimpleNesting	s
zScopeTests.testSimpleNestingcCs<dd�}|d�}|d�}|�|d�d�|�|d�d�dS)Ncs�fdd�}|�S)Ncs�fdd�}|S)Ncs�|S)Nr)r)rrrr	szNScopeTests.testExtraNesting.<locals>.make_adder2.<locals>.extra.<locals>.adderr)r	)rrr�extrasz?ScopeTests.testExtraNesting.<locals>.make_adder2.<locals>.extrar)rrr)rr�make_adder2sz0ScopeTests.testExtraNesting.<locals>.make_adder2rrr
rr)r)rrrrrrr�testExtraNestings
zScopeTests.testExtraNestingcCs<dd�}|d�}|d�}|�|d�d�|�|d�d�dS)	Ncs�fdd�}�d�|S)Ncs�|S)Nr)r)rrrr	(szEScopeTests.testSimpleAndRebinding.<locals>.make_adder3.<locals>.adderrr)rr	r)rr�make_adder3'sz6ScopeTests.testSimpleAndRebinding.<locals>.make_adder3r�	rr
rr)r)rrrrrrr�testSimpleAndRebinding%s
z!ScopeTests.testSimpleAndRebindingcs>�fdd�}d�|�}|�|d�d�d�|�|d�d�dS)Ncs�fdd�}|�S)Ncs�fdd�}|�S)Ncs�fdd�}|S)Ncs�|S)Nr)r)�global_xrrr	8szbScopeTests.testNestingGlobalNoFree.<locals>.make_adder4.<locals>.nest.<locals>.nest.<locals>.adderr)r	)rrr�nest7szSScopeTests.testNestingGlobalNoFree.<locals>.make_adder4.<locals>.nest.<locals>.nestr)r)rrrr6szEScopeTests.testNestingGlobalNoFree.<locals>.make_adder4.<locals>.nestr)r)rrr�make_adder45sz7ScopeTests.testNestingGlobalNoFree.<locals>.make_adder4rr
rrr)r)rrr	r)rr�testNestingGlobalNoFree3s	z"ScopeTests.testNestingGlobalNoFreecCs<dd�}|d�}|d�}|�|d�d�|�|d�d�dS)NcsG�fdd�d�}|�S)NcseZdZ�fdd�ZdS)zFScopeTests.testNestingThroughClass.<locals>.make_adder5.<locals>.Addercs�|S)Nr)rr)rrr�__call__IszOScopeTests.testNestingThroughClass.<locals>.make_adder5.<locals>.Adder.__call__N)�__name__�
__module__�__qualname__rr)rrr�AdderHsr#r)rr#r)rr�make_adder5Gsz7ScopeTests.testNestingThroughClass.<locals>.make_adder5rrr
rr)r)rr$rrrrr�testNestingThroughClassEs
z"ScopeTests.testNestingThroughClasscCs<dd�}|d�}|d�}|�|d�d�|�|d�d�dS)NcSsdd�}|a|S)NcSst|S)N)�
global_nest_x)rrrrr	WszMScopeTests.testNestingPlusFreeRefToGlobal.<locals>.make_adder6.<locals>.adder)r&)rr	rrr�make_adder6Usz>ScopeTests.testNestingPlusFreeRefToGlobal.<locals>.make_adder6rr�rr)r)rr'rrrrr�testNestingPlusFreeRefToGlobalSs
z)ScopeTests.testNestingPlusFreeRefToGlobalcCs$dd�}|d�}|�|d�d�dS)NcSsdd�}|d�S)Ncsd��fdd�}|S)N�*cs�|S)Nr)�z)rrr�hgszEScopeTests.testNearestEnclosingScope.<locals>.f.<locals>.g.<locals>.hr)rr,r)rr�gesz:ScopeTests.testNearestEnclosingScope.<locals>.f.<locals>.gr
r)rr-rrr�fdsz/ScopeTests.testNearestEnclosingScope.<locals>.fr��/)r)rr.Z	test_funcrrr�testNearestEnclosingScopebsz$ScopeTests.testNearestEnclosingScopecs>dd���fdd�}|ddd�}|ddd	�}|�|�d
�dS)NcSs|S)Nr)rrrr�identityqsz9ScopeTests.testMixedFreevarsAndCellvars.<locals>.identitycs���fdd�}|S)Ncs&|�}����fdd�}|��|S)Ncs�����S)Nrr)�br2rr+rrr,wszHScopeTests.testMixedFreevarsAndCellvars.<locals>.f.<locals>.g.<locals>.hr)�ar3�cr,)r2rr+)r3rrr-usz=ScopeTests.testMixedFreevarsAndCellvars.<locals>.f.<locals>.gr)rrr+r-)r2)rr+rr.tsz2ScopeTests.testMixedFreevarsAndCellvars.<locals>.frr
����')r)rr.r-r,r)r2r�testMixedFreevarsAndCellvarsos
z'ScopeTests.testMixedFreevarsAndCellvarscs�dd�}|�}|�|��d�|�|��d�|�|��d�d�G�fdd�d�}|�}|�|��d�|�|��d�|�|��d�dS)Ncsd�G�fdd�d�}|�S)N�varcs0eZdZdd�Z�fdd�Zdd�Zdd�Zd	S)
z:ScopeTests.testFreeVarInMethod.<locals>.test.<locals>.TestcSsdS)N�methodr)rrrr�method_and_var�szIScopeTests.testFreeVarInMethod.<locals>.test.<locals>.Test.method_and_varcs�S)Nr)r)r=rr�test�sz?ScopeTests.testFreeVarInMethod.<locals>.test.<locals>.Test.testcSstd�S)N�global)�str)rrrr�
actual_global�szHScopeTests.testFreeVarInMethod.<locals>.test.<locals>.Test.actual_globalcSst|�S)N)r@)rrrrr@�sz>ScopeTests.testFreeVarInMethod.<locals>.test.<locals>.Test.strN)r r!r"r=r>rAr@r)r=rr�Test�srBr)rBr)r=rr>�s	z,ScopeTests.testFreeVarInMethod.<locals>.testr;r<r?cs0eZdZdd�Z�fdd�Zdd�Zdd�Zd	S)
z,ScopeTests.testFreeVarInMethod.<locals>.TestcSsdS)Nr<r)rrrrr=�sz;ScopeTests.testFreeVarInMethod.<locals>.Test.method_and_varcs�S)Nr)r)r=rrr>�sz1ScopeTests.testFreeVarInMethod.<locals>.Test.testcSstd�S)Nr?)r@)rrrrrA�sz:ScopeTests.testFreeVarInMethod.<locals>.Test.actual_globalcSst|�S)N)r@)rrrrr@�sz0ScopeTests.testFreeVarInMethod.<locals>.Test.strN)r r!r"r=r>rAr@r)r=rrrB�srB)rr>r=rA)rr>�trBr)r=r�testFreeVarInMethod�s
zScopeTests.testFreeVarInMethodcCs2dd�dd�}|�|dd�d�|�|�d�dS)N�)r4cs�fdd�}|�dS)Ncs�dS)Nr/rr)r4rr�bar�sz8ScopeTests.testCellIsKwonlyArg.<locals>.foo.<locals>.barr6r)r4rFr)r4r�foo�sz+ScopeTests.testCellIsKwonlyArg.<locals>.foor*�2�)r)rrGrrr�testCellIsKwonlyArg�szScopeTests.testCellIsKwonlyArgcCsdd�}|�|d�d�dS)Ncs(�fdd��|dkr�|�Std��dS)Ncs |dkrdS|�|d�SdS)Nrrr)�n)�factrrrL�sz1ScopeTests.testRecursion.<locals>.f.<locals>.factrzx must be >= 0)�
ValueError)rr)rLrr.�sz#ScopeTests.testRecursion.<locals>.fr8i�)r)rr.rrr�
testRecursion�szScopeTests.testRecursioncCs,t|d�t|d�t|d�t|d�dS)Nz�if 1:
            def unoptimized_clash1(strip):
                def f(s):
                    from sys import *
                    return getrefcount(s) # ambiguity: free or local
                return f
            z�if 1:
            def unoptimized_clash2():
                from sys import *
                def f(s):
                    return getrefcount(s) # ambiguity: global or local
                return f
            z�if 1:
            def unoptimized_clash2():
                from sys import *
                def g():
                    def f(s):
                        return getrefcount(s) # ambiguity: global or local
                    return f
            z�if 1:
            def f():
                def g():
                    from sys import *
                    return getrefcount # global or local?
            )r)rrrr�testUnoptimizedNamespaces�sz$ScopeTests.testUnoptimizedNamespacesc	s�dd�}|d�}|d�}|�|d�d�|�|d�d�dd�}|d�}|d�}|�|d�d�|�|d�d��fd	d�}d�|d�}|�|d�d
�dd�}|ddd
�}|ddd
�}|�|�d�dS)Ncs�fdd�S)Ncs�|S)Nr)r)rrr�<lambda>��z:ScopeTests.testLambdas.<locals>.<lambda>.<locals>.<lambda>r)rr)rrrP�rQz(ScopeTests.testLambdas.<locals>.<lambda>rrr
r/�cs�fdd��S)Ncs�fdd�S)Ncs�|S)Nr)r)rrrrP�rQzLScopeTests.testLambdas.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>rr)rrrrP�rQz:ScopeTests.testLambdas.<locals>.<lambda>.<locals>.<lambda>r)rr)rrrP�rQcs�fdd�S)Ncs�|S)Nr)r)rrrrP�rQz:ScopeTests.testLambdas.<locals>.<lambda>.<locals>.<lambda>r)r)rrrrP�rQr6cs��fdd�S)Ncs���fdd�S)Ncs���S)Nrr)r3rr+rrrP�rQzLScopeTests.testLambdas.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>r)r4r3r5)rr+)r3rrP�rQz:ScopeTests.testLambdas.<locals>.<lambda>.<locals>.<lambda>r)rrr+r)rr+rrP�rQr7r8�)r)	r�f1rr�f2Zf3Zf8r-r,r)rr�testLambdas�s$zScopeTests.testLambdascCs,dd�}dd�}|�t|�|�t|�dS)Ncst���fdd�}d�dS)Ncs�S)Nrr)rrr�innersz@ScopeTests.testUnboundLocal.<locals>.errorInOuter.<locals>.innerr)�print)rWr)rr�errorInOuter�sz1ScopeTests.testUnboundLocal.<locals>.errorInOutercs�fdd�}|�d�dS)Ncs�S)Nrr)rrrrWsz@ScopeTests.testUnboundLocal.<locals>.errorInInner.<locals>.innerrr)rWr)rr�errorInInnersz1ScopeTests.testUnboundLocal.<locals>.errorInInner)�assertRaises�UnboundLocalError�	NameError)rrYrZrrr�testUnboundLocal�szScopeTests.testUnboundLocalcCs,dd�}dd�}|�t|�|�t|�dS)Ncsd��t���fdd�}dS)Nrcs�S)Nrr)rrrrWszIScopeTests.testUnboundLocal_AfterDel.<locals>.errorInOuter.<locals>.inner)rX)rWr)rrrYsz:ScopeTests.testUnboundLocal_AfterDel.<locals>.errorInOutercs�fdd�}d��|�dS)Ncs�S)Nrr)rrrrWszIScopeTests.testUnboundLocal_AfterDel.<locals>.errorInInner.<locals>.innerrr)rWr)rrrZsz:ScopeTests.testUnboundLocal_AfterDel.<locals>.errorInInner)r[r\r])rrYrZrrr�testUnboundLocal_AfterDelsz$ScopeTests.testUnboundLocal_AfterDelcCstdd|ji�dS)Naif 1:
            global_x = 1
            def f():
                global_x += 1
            try:
                f()
            except UnboundLocalError:
                pass
            else:
                fail('scope of global_x not correctly determined')
            �fail)�execr`)rrrr�testUnboundLocal_AugAssign#s
z%ScopeTests.testUnboundLocal_AugAssigncCsBdd�}|�|ddd��d�dd�}|�|d	d
��dd	�dS)Ncs�fdd�}|S)Ncs�S)Nrr)�lstrr�returner4szIScopeTests.testComplexDefinitions.<locals>.makeReturner.<locals>.returnerr)rcrdr)rcr�makeReturner3sz7ScopeTests.testComplexDefinitions.<locals>.makeReturnerrr
r6)rr
r6cs�fdd�}|S)Ncs�S)Nrr)�kwargsrrrd;szJScopeTests.testComplexDefinitions.<locals>.makeReturner2.<locals>.returnerr)rfrdr)rfr�
makeReturner2:sz8ScopeTests.testComplexDefinitions.<locals>.makeReturner2r()r4r4)r)rrergrrr�testComplexDefinitions1sz!ScopeTests.testComplexDefinitionscCstd�dS)Na;if 1:
            # I
            x = 7
            def f():
                x = 1
                def g():
                    global x
                    def i():
                        def h():
                            return x
                        return h()
                    return i()
                return g()
            self.assertEqual(f(), 7)
            self.assertEqual(x, 7)

            # II
            x = 7
            def f():
                x = 1
                def g():
                    x = 2
                    def i():
                        def h():
                            return x
                        return h()
                    return i()
                return g()
            self.assertEqual(f(), 2)
            self.assertEqual(x, 7)

            # III
            x = 7
            def f():
                x = 1
                def g():
                    global x
                    x = 2
                    def i():
                        def h():
                            return x
                        return h()
                    return i()
                return g()
            self.assertEqual(f(), 2)
            self.assertEqual(x, 2)

            # IV
            x = 7
            def f():
                x = 3
                def g():
                    global x
                    x = 2
                    def i():
                        def h():
                            return x
                        return h()
                    return i()
                return g()
            self.assertEqual(f(), 2)
            self.assertEqual(x, 2)

            # XXX what about global statements in class blocks?
            # do they affect methods?

            x = 12
            class Global:
                global x
                x = 13
                def set(self, val):
                    x = val
                def get(self):
                    return x

            g = Global()
            self.assertEqual(g.get(), 13)
            g.set(15)
            self.assertEqual(g.get(), 13)
            )ra)rrrr�testScopeOfGlobalStmtAsOz ScopeTests.testScopeOfGlobalStmtcsHG�fdd�d���fdd�}xtd�D]
}|�q(W|��jd�dS)Ncs(eZdZdZ�fdd�Z�fdd�ZdS)z!ScopeTests.testLeaks.<locals>.Foorcs�jd7_dS)Nr)�count)r)�Foorr�__init__�sz*ScopeTests.testLeaks.<locals>.Foo.__init__cs�jd8_dS)Nr)rj)r)rkrr�__del__�sz)ScopeTests.testLeaks.<locals>.Foo.__del__N)r r!r"rjrlrmr)rkrrrk�srkcs����fdd�}|�dS)Ncs�S)Nrr)rrrrU�sz,ScopeTests.testLeaks.<locals>.f1.<locals>.f2r)rU)rk)rrrT�sz ScopeTests.testLeaks.<locals>.f1�dr)�rangerrj)rrT�ir)rkr�	testLeaks�s
	
zScopeTests.testLeakscCstd�dS)Na�if 1:
            def test(x):
                class Foo:
                    global x
                    def __call__(self, y):
                        return x + y
                return Foo()

            x = 0
            self.assertEqual(test(6)(2), 8)
            x = -1
            self.assertEqual(test(3)(2), 5)

            looked_up_by_load_name = False
            class X:
                # Implicit globals inside classes are be looked up by LOAD_NAME, not
                # LOAD_GLOBAL.
                locals()['looked_up_by_load_name'] = True
                passed = looked_up_by_load_name

            self.assertTrue(X.passed)
            )ra)rrrr�testClassAndGlobal�szScopeTests.testClassAndGlobalcCs>dd�}|d�d�}|�d|�|d=|�|dddd��dS)	Ncs�fdd�}|S)Ncs"�fdd�}��}�d7�t�S)Ncs�|S)Nr)r+)rrrr,�sz>ScopeTests.testLocalsFunction.<locals>.f.<locals>.g.<locals>.hr6)�locals)rr,�w)r)rrr-�sz3ScopeTests.testLocalsFunction.<locals>.f.<locals>.gr)rr-r)rrr.�sz(ScopeTests.testLocalsFunction.<locals>.fr
r7r,�r8)rrrt)�assertInr)rr.�drrr�testLocalsFunction�s
	zScopeTests.testLocalsFunctioncCsHdd�}|�|d�jd�dd�}|d�j}|�d|�|�d|�dS)NcsG�fdd�d�}|S)Ncs"eZdZdZ�fdd�Ze�dS)z0ScopeTests.testLocalsClass.<locals>.f.<locals>.C�cs�S)Nr)r)rrr�m�sz2ScopeTests.testLocalsClass.<locals>.f.<locals>.C.mN)r r!r"rrzrsr)rrr�C�sr{r)rr{r)rrr.�sz%ScopeTests.testLocalsClass.<locals>.frrycsG�fdd�d�}|S)Ncs&eZdZ�Z�fdd�Zee��ZdS)z0ScopeTests.testLocalsClass.<locals>.f.<locals>.Ccs�S)Nr)r)rrrrz�sz2ScopeTests.testLocalsClass.<locals>.f.<locals>.C.mN)r r!r"rrz�listrsr+r)rrrr{�sr{r)rr{r)rrr.�srr)rrr+�assertNotInrv)rr.Zvarnamesrrr�testLocalsClass�s
zScopeTests.testLocalsClasscsNddl}|�|j|���|�dd��d�G�fdd�d�}|��d�dS)NrcSsdS)Nr)r4r3r5rrrrP�rQz6ScopeTests.testLocalsClass_WithTrace.<locals>.<lambda>rycseZdZ�fdd�ZdS)z/ScopeTests.testLocalsClass_WithTrace.<locals>.Ccs�S)Nr)r)rrrr.sz1ScopeTests.testLocalsClass_WithTrace.<locals>.C.fN)r r!r"r.r)rrrr{sr{)�sys�
addCleanup�settrace�gettracer)rrr{r)rr�testLocalsClass_WithTrace�sz$ScopeTests.testLocalsClass_WithTracecCs(dd�}|d��}|�|j|���dS)NcsG�fdd�d�}|S)NcseZdZ�fdd�Z�ZdS)z1ScopeTests.testBoundAndFree.<locals>.f.<locals>.Ccs�S)Nr)r)rrrrzsz3ScopeTests.testBoundAndFree.<locals>.f.<locals>.C.mN)r r!r"rzr4r)rrrr{
sr{r)rr{r)rrr.	sz&ScopeTests.testBoundAndFree.<locals>.fr6)rr4rz)rr.�instrrr�testBoundAndFrees
zScopeTests.testBoundAndFreecsnddl}�fdd��dd�}Gdd�d�}|�|j|���|���|d|d	�|�d�|�t|j�dS)
Nrcs�S)Nr)r4r3r5)�tracerrrr�sz7ScopeTests.testInteractionWithTraceFunc.<locals>.tracercs6|\}�|dkr2�dkr&d|j|f��fdd�SdS)Nr�z_%s__%scs
t|��S)N)�getattr)�obj)�desrrrPrQzNScopeTests.testInteractionWithTraceFunc.<locals>.adaptgetter.<locals>.<lambda>)r )�name�klass�getter�kindr)r�r�adaptgetters
z<ScopeTests.testInteractionWithTraceFunc.<locals>.adaptgetterc@seZdZdS)z:ScopeTests.testInteractionWithTraceFunc.<locals>.TestClassN)r r!r"rrrr�	TestClass!sr�rG)rr�)rr�r�r�r[�	TypeError)rrr�r�r)r�r�testInteractionWithTraceFuncs

z'ScopeTests.testInteractionWithTraceFunccCsTdd�}|d�}|�tt|j�yt|ji�Wntk
rDYnX|�d�dS)Ncs�fdd�S)Ncs�dS)Nrrr)rrrrP.rQz<ScopeTests.testEvalExecFreeVars.<locals>.f.<locals>.<lambda>r)rr)rrr.-sz*ScopeTests.testEvalExecFreeVars.<locals>.fr6z9exec should have failed, because code contained free vars)r[r��eval�__code__rar`)rr.r-rrr�testEvalExecFreeVars+szScopeTests.testEvalExecFreeVarscCs^ytt�Wntk
r Yn
Xtd�dd�}|�ytt�Wntk
rXYnXdS)Nzbad should not be definedcSsdd�dD�dS)NcSsg|]}|��D]}|�qqSr)�split)�.0�s�badrrr�
<listcomp>Dsz?ScopeTests.testListCompLocalVars.<locals>.x.<locals>.<listcomp>za brrrrrrCsz+ScopeTests.testListCompLocalVars.<locals>.x)rXr�r])rrrrr�testListCompLocalVars:sz ScopeTests.testListCompLocalVarscCsdd�}|d��dS)Ncs�fdd�}|S)Ncs�td�dS)Nzx + 1)r�r)rrrr-Osz1ScopeTests.testEvalFreeVars.<locals>.f.<locals>.gr)rr-r)rrr.Nsz&ScopeTests.testEvalFreeVars.<locals>.fr7r)rr.rrr�testEvalFreeVarsLszScopeTests.testEvalFreeVarscCsGdd�d�}dS)Nc@seZdZdd�ZdS)z+ScopeTests.testFreeingCell.<locals>.SpecialcSs
t�dS)N)Znestedcell_get)rrrrrmZsz3ScopeTests.testFreeingCell.<locals>.Special.__del__N)r r!r"rmrrrr�SpecialYsr�r)rr�rrr�testFreeingCellVszScopeTests.testFreeingCellcCsPdd�}|d�\}}|�|�d�|�|�d�|�|�d�|�|�d�dS)Ncs �fdd�}�fdd�}||fS)Ncs�d7��S)Nrrr)rrrr`sz7ScopeTests.testNonLocalFunction.<locals>.f.<locals>.inccs�d8��S)Nrrr)rrr�decdsz7ScopeTests.testNonLocalFunction.<locals>.f.<locals>.decr)rrr�r)rrr._sz*ScopeTests.testNonLocalFunction.<locals>.frrr
)r)rr.rr�rrr�testNonLocalFunction]szScopeTests.testNonLocalFunctioncCsTdd�}|d�}|�|��d�|�|��d�|�|��d�|�|��d�dS)NcsG�fdd�d�}|�S)Ncs$eZdZ�fdd�Z�fdd�ZdS)z3ScopeTests.testNonLocalMethod.<locals>.f.<locals>.ccs�d7��S)Nrr)r)rrrrssz7ScopeTests.testNonLocalMethod.<locals>.f.<locals>.c.inccs�d8��S)Nrr)r)rrrr�wsz7ScopeTests.testNonLocalMethod.<locals>.f.<locals>.c.decN)r r!r"rr�r)rrrr5rsr5r)rr5r)rrr.qs	z(ScopeTests.testNonLocalMethod.<locals>.frrr
)rrr�)rr.r5rrr�testNonLocalMethodpszScopeTests.testNonLocalMethodcCs8i}i}td||�|�d|d�|�d|d�dS)NaCif 1:
            def f():
                y = 1
                def g():
                    global y
                    return y
                def h():
                    return y + 1
                return g, h
            y = 9
            g, h = f()
            result9 = g()
            result2 = h()
            r
Zresult2rZresult9)rar)rZlocal_nsZ	global_nsrrr�#testGlobalInParallelNestedFunctions�s
z.ScopeTests.testGlobalInParallelNestedFunctionscCs4dd�}|d�}|�|��d�|�d|jj�dS)NcsG�fdd�d�}|�S)Ncs eZdZ�d7��fdd�ZdS)z2ScopeTests.testNonLocalClass.<locals>.f.<locals>.crcs�S)Nr)r)rrr�get�sz6ScopeTests.testNonLocalClass.<locals>.f.<locals>.c.getN)r r!r"r�r)rrrr5�sr5r)rr5r)rrr.�sz'ScopeTests.testNonLocalClass.<locals>.frrr)rr�r}�	__class__�__dict__)rr.r5rrr�testNonLocalClass�szScopeTests.testNonLocalClasscCs2dd�}|d�}|�t|d��dddddg�dS)	Ncs�fdd�}|S)Nc3s$xt|�D]}�d7��Vq
WdS)Nr)ro)rrp)rrrr-�sz6ScopeTests.testNonLocalGenerator.<locals>.f.<locals>.gr)rr-r)rrr.�sz+ScopeTests.testNonLocalGenerator.<locals>.frr/rr
r6r7)rr|)rr.r-rrr�testNonLocalGenerator�sz ScopeTests.testNonLocalGeneratorcCs(dd�}|d�}|�}|�|�d�dS)Ncs�fdd�}|S)Ncs�d8��fdd�}|S)Nr
cs�d7��S)Nr7rr)rrrr,�sz>ScopeTests.testNestedNonLocal.<locals>.f.<locals>.g.<locals>.hr)r,)rrrr-�sz3ScopeTests.testNestedNonLocal.<locals>.f.<locals>.gr)rr-r)rrr.�sz(ScopeTests.testNestedNonLocal.<locals>.frr6)r)rr.r-r,rrr�testNestedNonLocal�szScopeTests.testNestedNonLocalcCsdd�}dd�}dS)NcSsdS)Nr)r4rrr�top�sz/ScopeTests.testTopIsNotSignificant.<locals>.topcSsdS)Nrrrrrr3�sz-ScopeTests.testTopIsNotSignificant.<locals>.br)rr�r3rrr�testTopIsNotSignificant�sz"ScopeTests.testTopIsNotSignificantcsRd�G�fdd�d�}|�|jd�Gdd�d�}|�t|d��|��d�dS)Nr*cseZdZde�d<�ZdS)z8ScopeTests.testClassNamespaceOverridesClosure.<locals>.X�+rN)r r!r"rsrr)rrr�X�s
r�r�c@seZdZde�d<[dS)z8ScopeTests.testClassNamespaceOverridesClosure.<locals>.Xr�rN)r r!r"rsrrrrrr��s
r)rrZassertFalse�hasattr)rr�r)rr�"testClassNamespaceOverridesClosure�sz-ScopeTests.testClassNamespaceOverridesClosurecCs8Gdd�d�}|�}|��t�|�}~|�|��dS)Nc@seZdZdd�ZdS)z'ScopeTests.testCellLeak.<locals>.Testerc
s>yddWn(tk
r4}z
|�_Wdd}~XYnXd�dS)Nrr)�	Exception�exc)rr�r)rr�dig�s
z+ScopeTests.testCellLeak.<locals>.Tester.digN)r r!r"r�rrrr�Tester�sr�)r��weakref�refZassertIsNone)rr�Ztesterr�rrr�testCellLeak�s
	
zScopeTests.testCellLeakN)*r r!r"rrrrr%r)r1r:rDrJrNrOrVr^r_rbrhrirqrrrxr~rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrsL

%"T!



r�__main__)	Zunittestr�Ztest.supportrrZTestCaserr �mainrrrr�<module>sv