Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
804c439c
Commit
804c439c
authored
May 11, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
let the parser detect '*a = ...' and provide a helpful error message
parent
0da3fcb6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
+16
-0
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+6
-0
tests/errors/extended_unpacking_notuple.pyx
tests/errors/extended_unpacking_notuple.pyx
+10
-0
No files found.
Cython/Compiler/Parsing.py
View file @
804c439c
...
...
@@ -1073,6 +1073,12 @@ def p_nonlocal_statement(s):
def
p_expression_or_assignment
(
s
):
expr_list
=
[
p_testlist_star_expr
(
s
)]
if
s
.
sy
==
'='
and
expr_list
[
0
].
is_starred
:
# This is a common enough error to make when learning Cython to let
# it fail as early as possible and give a very clear error message.
s
.
error
(
"a starred assignment target must be in a list or tuple"
" - maybe you meant to use an index assignment: var[0] = ..."
,
pos
=
expr_list
[
0
].
pos
)
while
s
.
sy
==
'='
:
s
.
next
()
if
s
.
sy
==
'yield'
:
...
...
tests/errors/extended_unpacking_notuple.pyx
0 → 100644
View file @
804c439c
# mode: error
# very common mistake for new users (handled early by the parser)
def
no_tuple_assignment
():
*
a
=
[
1
]
_ERRORS
=
u"""
6:4: a starred assignment target must be in a list or tuple - maybe you meant to use an index assignment: var[0] = ...
"""
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