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
Xavier Thompson
cython
Commits
09ca6dab
Commit
09ca6dab
authored
Apr 30, 2019
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Exclude tuples with starred expressions from the %-formatting optimisation.
Closes GH-2939.
parent
f4f6d1eb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+4
-0
tests/run/pep448_extended_unpacking.pyx
tests/run/pep448_extended_unpacking.pyx
+18
-0
No files found.
Cython/Compiler/Optimize.py
View file @
09ca6dab
...
@@ -4322,6 +4322,9 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
...
@@ -4322,6 +4322,9 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
warning
(
pos
,
"Too few arguments for format placeholders"
,
level
=
1
)
warning
(
pos
,
"Too few arguments for format placeholders"
,
level
=
1
)
can_be_optimised
=
False
can_be_optimised
=
False
break
break
if
arg
.
is_starred
:
can_be_optimised
=
False
break
if
format_type
in
u'asrfdoxX'
:
if
format_type
in
u'asrfdoxX'
:
format_spec
=
s
[
1
:]
format_spec
=
s
[
1
:]
if
format_type
in
u'doxX'
and
u'.'
in
format_spec
:
if
format_type
in
u'doxX'
and
u'.'
in
format_spec
:
...
@@ -4339,6 +4342,7 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
...
@@ -4339,6 +4342,7 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
else
:
else
:
# keep it simple for now ...
# keep it simple for now ...
can_be_optimised
=
False
can_be_optimised
=
False
break
if
not
can_be_optimised
:
if
not
can_be_optimised
:
# Print all warnings we can find before finally giving up here.
# Print all warnings we can find before finally giving up here.
...
...
tests/run/pep448_extended_unpacking.pyx
View file @
09ca6dab
# mode: run
# tag: all_language_levels
cimport
cython
cimport
cython
...
@@ -144,6 +146,22 @@ def unpack_tuple_keep_originals(a, b, c):
...
@@ -144,6 +146,22 @@ def unpack_tuple_keep_originals(a, b, c):
return
(
*
a
,
*
b
,
2
,
*
c
)
return
(
*
a
,
*
b
,
2
,
*
c
)
def
unpack_tuple_in_string_formatting
(
a
,
*
args
):
"""
>>> print(unpack_tuple_in_string_formatting(1, 2))
1 2
>>> print(unpack_tuple_in_string_formatting(1, 'x'))
1 'x'
>>> unpack_tuple_in_string_formatting(1) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...format...
>>> unpack_tuple_in_string_formatting(1, 2, 3) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...format...
"""
return
"%s %r"
%
(
a
,
*
args
)
#### lists
#### lists
...
...
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