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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
0a631b46
Commit
0a631b46
authored
Mar 21, 2016
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
discard empty substrings from the join-list of f-strings
parent
2fa17728
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
4 deletions
+17
-4
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+17
-4
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
0a631b46
...
@@ -349,10 +349,23 @@ class PostParse(ScopeTrackingTransform):
...
@@ -349,10 +349,23 @@ class PostParse(ScopeTrackingTransform):
return
node
return
node
def
visit_JoinedStrNode
(
self
,
node
):
def
visit_JoinedStrNode
(
self
,
node
):
if
len
(
node
.
values
)
==
1
:
"""
# this is not uncommon because f-string format specs are parsed into JoinedStrNodes
Clean up after the parser by wrapping the substrings in a ListNode and
return
node
.
values
[
0
]
discarding empty Unicode strings. Empty or single-value join lists are not
node
.
values
=
ExprNodes
.
ListNode
(
node
.
pos
,
args
=
node
.
values
)
uncommon because f-string format specs are always parsed into JoinedStrNodes.
"""
values
=
[]
for
value
in
node
.
values
:
if
isinstance
(
value
,
ExprNodes
.
UnicodeNode
)
and
not
value
.
value
:
continue
# ignore empty Unicode strings
values
.
append
(
value
)
if
not
values
:
node
=
ExprNodes
.
UnicodeNode
(
node
.
pos
,
value
=
EncodedString
(
''
))
elif
len
(
values
)
==
1
:
node
=
values
[
0
]
else
:
node
.
values
=
ExprNodes
.
ListNode
(
node
.
pos
,
args
=
values
)
self
.
visitchildren
(
node
)
self
.
visitchildren
(
node
)
return
node
return
node
...
...
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