FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python/Tools/compiler/stacktest.py at master · java66liu/python · GitHub
java66liu
/
python
Public
forked from
glix/python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
python
/
Tools
/
compiler
/
stacktest.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
43 lines (39 loc) · 1.19 KB
Breadcrumbs
python
/
Tools
/
compiler
/
stacktest.py
Copy path
File metadata and controls
43 lines (39 loc) · 1.19 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import
compiler
import
dis
import
types
def
extract_code_objects
(
co
):
l
=
[
co
]
for
const
in
co
.
co_consts
:
if
type
(
const
)
==
types
.
CodeType
:
l
.
append
(
const
)
return
l
def
compare
(
a
,
b
):
if
not
(
a
.
co_name
==
"?"
or
a
.
co_name
.
startswith
(
'<lambda'
)):
assert
a
.
co_name
==
b
.
co_name
, (
a
,
b
)
if
a
.
co_stacksize
!=
b
.
co_stacksize
:
print
"stack mismatch %s: %d vs. %d"
%
(
a
.
co_name
,
a
.
co_stacksize
,
b
.
co_stacksize
)
if
a
.
co_stacksize
>
b
.
co_stacksize
:
print
"good code"
dis
.
dis
(
a
)
print
"bad code"
dis
.
dis
(
b
)
assert
0
def
main
(
files
):
for
file
in
files
:
print
file
buf
=
open
(
file
).
read
()
try
:
co1
=
compile
(
buf
,
file
,
"exec"
)
except
SyntaxError
:
print
"skipped"
continue
co2
=
compiler
.
compile
(
buf
,
file
,
"exec"
)
co1l
=
extract_code_objects
(
co1
)
co2l
=
extract_code_objects
(
co2
)
for
a
,
b
in
zip
(
co1l
,
co2l
):
compare
(
a
,
b
)
if
__name__
==
"__main__"
:
import
sys
main
(
sys
.
argv
[
1
:])
Back
|
FazBrowse Home
|
New Git URL