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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
# Test the marshal module, stressing edge cases.
try:
import marshal
(lambda: 0).__code__
except (AttributeError, ImportError):
print("SKIP")
raise SystemExit
ftype = type(lambda: 0)
# Test a large function.
def large_function(arg0, arg1, arg2, arg3):
# Arguments.
print(arg0, arg1, arg2, arg3)
# Positive medium-sized integer (still a small-int though).
print(1234)
# Negative small-ish integer.
print(-20)
# More than 64 constant objects.
x = (0,)
x = (1,)
x = (2,)
x = (3,)
x = (4,)
x = (5,)
x = (6,)
x = (7,)
x = (8,)
x = (9,)
x = (10,)
x = (11,)
x = (12,)
x = (13,)
x = (14,)
x = (15,)
x = (16,)
x = (17,)
x = (18,)
x = (19,)
x = (20,)
x = (21,)
x = (22,)
x = (23,)
x = (24,)
x = (25,)
x = (26,)
x = (27,)
x = (28,)
x = (29,)
x = (30,)
x = (31,)
x = (32,)
x = (33,)
x = (34,)
x = (35,)
x = (36,)
x = (37,)
x = (38,)
x = (39,)
x = (40,)
x = (41,)
x = (42,)
x = (43,)
x = (44,)
x = (45,)
x = (46,)
x = (47,)
x = (48,)
x = (49,)
x = (50,)
x = (51,)
x = (52,)
x = (53,)
x = (54,)
x = (55,)
x = (56,)
x = (57,)
x = (58,)
x = (59,)
x = (60,)
x = (61,)
x = (62,)
x = (63,)
x = (64,)
# Small jump.
x = 0
while x < 2:
print("loop", x)
x += 1
# Large jump.
x = 0
while x < 2:
try:
try:
try:
print
except Exception as e:
print
finally:
print
except Exception as e:
print
finally:
print
except Exception as e:
print
finally:
print("loop", x)
x += 1
code = marshal.dumps(large_function.__code__)
ftype(marshal.loads(code), {"print": print})(0, 1, 2, 3)
|