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
71011e2c
Commit
71011e2c
authored
Apr 23, 2007
by
Nick Coghlan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow decorators and return annotations to be used together (fixes SF#1697248)
parent
4138bfec
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
2 deletions
+7
-2
Lib/test/test_grammar.py
Lib/test/test_grammar.py
+6
-1
Python/ast.c
Python/ast.c
+1
-1
No files found.
Lib/test/test_grammar.py
View file @
71011e2c
...
@@ -322,7 +322,12 @@ class GrammarTests(unittest.TestCase):
...
@@ -322,7 +322,12 @@ class GrammarTests(unittest.TestCase):
self
.
assertEquals
(
f
.
__annotations__
,
self
.
assertEquals
(
f
.
__annotations__
,
{
'b'
:
1
,
'c'
:
2
,
'e'
:
3
,
'g'
:
6
,
'h'
:
7
,
'j'
:
9
,
{
'b'
:
1
,
'c'
:
2
,
'e'
:
3
,
'g'
:
6
,
'h'
:
7
,
'j'
:
9
,
'k'
:
11
,
'return'
:
12
})
'k'
:
11
,
'return'
:
12
})
# Check for SF Bug #1697248 - mixing decorators and a return annotation
def
null
(
x
):
return
x
@
null
def
f
(
x
)
->
list
:
pass
self
.
assertEquals
(
f
.
__annotations__
,
{
'return'
:
list
})
# test MAKE_CLOSURE with a variety of oparg's
# test MAKE_CLOSURE with a variety of oparg's
closure
=
1
closure
=
1
def
f
():
return
closure
def
f
():
return
closure
...
...
Python/ast.c
View file @
71011e2c
...
@@ -983,7 +983,7 @@ ast_for_funcdef(struct compiling *c, const node *n)
...
@@ -983,7 +983,7 @@ ast_for_funcdef(struct compiling *c, const node *n)
REQ
(
n
,
funcdef
);
REQ
(
n
,
funcdef
);
if
(
NCH
(
n
)
==
6
)
{
/* decorators are present */
if
(
NCH
(
n
)
==
6
||
NCH
(
n
)
==
8
)
{
/* decorators are present */
decorator_seq
=
ast_for_decorators
(
c
,
CHILD
(
n
,
0
));
decorator_seq
=
ast_for_decorators
(
c
,
CHILD
(
n
,
0
));
if
(
!
decorator_seq
)
if
(
!
decorator_seq
)
return
NULL
;
return
NULL
;
...
...
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