Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
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
Boxiang Sun
Pyston
Commits
b2b06576
Commit
b2b06576
authored
Jul 07, 2014
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test the order of decorators and defaults evaluation
parent
fe918ed5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
0 deletions
+18
-0
src/core/cfg.cpp
src/core/cfg.cpp
+1
-0
test/tests/decorators.py
test/tests/decorators.py
+12
-0
test/tests/scoping_classes.py
test/tests/scoping_classes.py
+5
-0
No files found.
src/core/cfg.cpp
View file @
b2b06576
...
@@ -859,6 +859,7 @@ public:
...
@@ -859,6 +859,7 @@ public:
remapped
->
args
=
new
AST_arguments
();
remapped
->
args
=
new
AST_arguments
();
remapped
->
body
=
node
->
body
;
// hmm shouldnt have to copy this
remapped
->
body
=
node
->
body
;
// hmm shouldnt have to copy this
// Decorators are evaluated before the defaults:
for
(
auto
d
:
node
->
decorator_list
)
{
for
(
auto
d
:
node
->
decorator_list
)
{
remapped
->
decorator_list
.
push_back
(
remapExpr
(
d
));
remapped
->
decorator_list
.
push_back
(
remapExpr
(
d
));
}
}
...
...
test/tests/decorators.py
0 → 100644
View file @
b2b06576
# expected: fail
# - decorators
def
print_when_eval
(
x
,
msg
):
print
msg
return
x
# Test the order that decorators and function defaults get evaluated
@
print_when_eval
(
lambda
f
:
print_when_eval
(
f
,
"calling decorator"
),
"evaluating decorator"
)
def
f
(
x
=
print_when_eval
(
1
,
"evaluating default"
)):
pass
# Result: looks like it's decorator first, then defaults, then the decorator is called.
test/tests/scoping_classes.py
View file @
b2b06576
...
@@ -43,6 +43,11 @@ def wrapper():
...
@@ -43,6 +43,11 @@ def wrapper():
print
X
,
Y
# "1 1"
print
X
,
Y
# "1 1"
print
"done with classdef"
print
"done with classdef"
print
hasattr
(
C
,
'X'
)
print
hasattr
(
C
,
'Y'
)
print
hasattr
(
C
,
'Z'
)
print
hasattr
(
C
,
'W'
)
return
C
return
C
wrapper
()().
f
()
wrapper
()().
f
()
...
...
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