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
73c958ac
Commit
73c958ac
authored
Jun 07, 2007
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disallow function calls like foo(None=1).
Backport from py3k rev. 55708 by Guido. (backport from rev. 55802)
parent
c98da3d8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
4 deletions
+12
-4
Lib/test/test_compile.py
Lib/test/test_compile.py
+3
-0
Python/ast.c
Python/ast.c
+9
-4
No files found.
Lib/test/test_compile.py
View file @
73c958ac
...
...
@@ -37,6 +37,9 @@ class TestSpecifics(unittest.TestCase):
def
test_syntax_error
(
self
):
self
.
assertRaises
(
SyntaxError
,
compile
,
"1+*3"
,
"filename"
,
"exec"
)
def
test_none_keyword_arg
(
self
):
self
.
assertRaises
(
SyntaxError
,
compile
,
"f(None=1)"
,
"<string>"
,
"exec"
)
def
test_duplicate_global_local
(
self
):
try
:
exec
'def f(a): global a; a = 1'
...
...
Python/ast.c
View file @
73c958ac
...
...
@@ -1855,13 +1855,18 @@ ast_for_call(struct compiling *c, const node *n, expr_ty func)
* then is very confusing.
*/
if
(
e
->
kind
==
Lambda_kind
)
{
ast_error
(
CHILD
(
ch
,
0
),
"lambda cannot contain assignment"
);
return
NULL
;
ast_error
(
CHILD
(
ch
,
0
),
"lambda cannot contain assignment"
);
return
NULL
;
}
else
if
(
e
->
kind
!=
Name_kind
)
{
ast_error
(
CHILD
(
ch
,
0
),
"keyword can't be an expression"
);
return
NULL
;
ast_error
(
CHILD
(
ch
,
0
),
"keyword can't be an expression"
);
return
NULL
;
}
key
=
e
->
v
.
Name
.
id
;
if
(
!
strcmp
(
PyString_AS_STRING
(
key
),
"None"
))
{
ast_error
(
CHILD
(
ch
,
0
),
"assignment to None"
);
return
NULL
;
}
e
=
ast_for_expr
(
c
,
CHILD
(
ch
,
2
));
if
(
!
e
)
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