tzh
2024-08-22 c7d0944258c7d0943aa7b2211498fd612971ce27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
O\¬Qc@s”dZddlZddlZddlZd„Zd„Zdejfd„ƒYZdejfd„ƒYZdd    „Z
e d
kre
ƒndS( sÃThis module includes tests of the code object representation.
 
>>> def f(x):
...     def g(y):
...         return x + y
...     return g
...
 
>>> dump(f.func_code)
name: f
argcount: 1
names: ()
varnames: ('x', 'g')
cellvars: ('x',)
freevars: ()
nlocals: 2
flags: 3
consts: ('None', '<code object g>')
 
>>> dump(f(4).func_code)
name: g
argcount: 1
names: ()
varnames: ('y',)
cellvars: ()
freevars: ('x',)
nlocals: 1
flags: 19
consts: ('None',)
 
>>> def h(x, y):
...     a = x + y
...     b = x - y
...     c = a * b
...     return c
...
>>> dump(h.func_code)
name: h
argcount: 2
names: ()
varnames: ('x', 'y', 'a', 'b', 'c')
cellvars: ()
freevars: ()
nlocals: 5
flags: 67
consts: ('None',)
 
>>> def attrs(obj):
...     print obj.attr1
...     print obj.attr2
...     print obj.attr3
 
>>> dump(attrs.func_code)
name: attrs
argcount: 1
names: ('attr1', 'attr2', 'attr3')
varnames: ('obj',)
cellvars: ()
freevars: ()
nlocals: 1
flags: 67
consts: ('None',)
 
>>> def optimize_away():
...     'doc string'
...     'not a docstring'
...     53
...     53L
 
>>> dump(optimize_away.func_code)
name: optimize_away
argcount: 0
names: ()
varnames: ()
cellvars: ()
freevars: ()
nlocals: 0
flags: 67
consts: ("'doc string'", 'None')
 
iÿÿÿÿNccsDx=|D]5}t|ƒ}|jdƒr7d|jVq|VqWdS(s.Yield a doctest-safe sequence of object reprs.s <code objects<code object %s>N(treprt
startswithtco_name(tttelttr((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_code.pytconstsXs
  cCsaxBddddddddgD]"}d    |t|d
|ƒfGHqWd Gtt|jƒƒGHd S( s1Print out a text representation of a code object.tnametargcounttnamestvarnamestcellvarstfreevarstnlocalstflagss%s: %stco_sconsts:N(tgetattrttupleRt    co_consts(tcotattr((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_code.pytdumpas tCodeTestcBseZd„ZRS(cCsRtjdddƒ}|j|jdƒ|j|jdƒ|j|jdƒdS(Ntfilenametfuncnamei(t    _testcapit code_newemptyt assertEqualt co_filenameRtco_firstlineno(tselfR((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_code.pyt test_newemptyks(t__name__t
__module__R(((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_code.pyRistCodeWeakRefTestcBseZd„ZRS(csi}deƒ|U|d}~eˆ_‡fd†}ej|j|ƒ}ˆje|ƒƒƒ~ˆje|ƒƒƒˆjˆjƒdS(Ns def f(): passtfcs tˆ_dS(N(tTruetcalled(tcode(R(sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_code.pytcallback}s(    tglobalstFalseR%tweakreftreft__code__t
assertTruetboolt assertFalse(Rt    namespaceR#R'tcoderef((RsV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_code.pyt
test_basicts 
    (R R!R2(((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_code.pyR"rscCsDddlm}m}ddlm}|||ƒ|ttƒdS(Niÿÿÿÿ(t run_doctestt run_unittest(t    test_code(ttest.test_supportR3R4ttestR5RR"(tverboseR3R4R5((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_code.pyt    test_main‹s t__main__( t__doc__tunittestR*RRRtTestCaseRR"tNoneR9R (((sV/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_code.pyt<module>Qs