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
a7ee59b3
Commit
a7ee59b3
authored
Jul 04, 2010
by
Mark Dickinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #9128: Validate class decorator syntax correctly in parser module.
parent
96c4df45
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
8 deletions
+18
-8
Lib/test/test_parser.py
Lib/test/test_parser.py
+8
-0
Misc/NEWS
Misc/NEWS
+1
-0
Modules/parsermodule.c
Modules/parsermodule.c
+9
-8
No files found.
Lib/test/test_parser.py
View file @
a7ee59b3
...
...
@@ -180,6 +180,14 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
def
test_class_defs
(
self
):
self
.
check_suite
(
"class foo():pass"
)
self
.
check_suite
(
"@class_decorator
\
n
"
"class foo():pass"
)
self
.
check_suite
(
"@class_decorator(arg)
\
n
"
"class foo():pass"
)
self
.
check_suite
(
"@decorator1
\
n
"
"@decorator2
\
n
"
"class foo():pass"
)
def
test_import_from_statement
(
self
):
self
.
check_suite
(
"from sys.path import *"
)
...
...
Misc/NEWS
View file @
a7ee59b3
...
...
@@ -16,6 +16,7 @@ Core and Builtins
Library
-------
- Issue #9128: Fix validation of class decorators in parser module.
Extension Modules
-----------------
...
...
Modules/parsermodule.c
View file @
a7ee59b3
...
...
@@ -2682,14 +2682,15 @@ validate_funcdef(node *tree)
static
int
validate_decorated
(
node
*
tree
)
{
int
nch
=
NCH
(
tree
);
int
ok
=
(
validate_ntype
(
tree
,
decorated
)
&&
(
nch
==
2
)
&&
validate_decorators
(
RCHILD
(
tree
,
-
2
))
&&
(
validate_funcdef
(
RCHILD
(
tree
,
-
1
))
||
validate_class
(
RCHILD
(
tree
,
-
1
)))
);
return
ok
;
int
nch
=
NCH
(
tree
);
int
ok
=
(
validate_ntype
(
tree
,
decorated
)
&&
(
nch
==
2
)
&&
validate_decorators
(
RCHILD
(
tree
,
-
2
)));
if
(
TYPE
(
RCHILD
(
tree
,
-
1
))
==
funcdef
)
ok
=
ok
&&
validate_funcdef
(
RCHILD
(
tree
,
-
1
));
else
ok
=
ok
&&
validate_class
(
RCHILD
(
tree
,
-
1
));
return
ok
;
}
static
int
...
...
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