Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
b8903fbf
Commit
b8903fbf
authored
Oct 17, 2001
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test utility to look for bad stacksize calculations.
parent
138d90eb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
+43
-0
Tools/compiler/stacktest.py
Tools/compiler/stacktest.py
+43
-0
No files found.
Tools/compiler/stacktest.py
0 → 100644
View file @
b8903fbf
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
:])
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment