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
5b94f357
Commit
5b94f357
authored
Jul 29, 2019
by
Anthony Sottile
Committed by
Pablo Galindo
Jul 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix `SyntaxError` indicator printing too many spaces for multi-line strings (GH-14433)
parent
e1b90024
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
0 deletions
+17
-0
Lib/test/test_cmd_line_script.py
Lib/test/test_cmd_line_script.py
+14
-0
Misc/NEWS.d/next/Core and Builtins/2019-06-27-15-01-14.bpo-37433.amNGqr.rst
...ore and Builtins/2019-06-27-15-01-14.bpo-37433.amNGqr.rst
+1
-0
Parser/tokenizer.c
Parser/tokenizer.c
+2
-0
No files found.
Lib/test/test_cmd_line_script.py
View file @
5b94f357
...
...
@@ -613,6 +613,20 @@ class CmdLineTest(unittest.TestCase):
self
.
assertNotIn
(
"
\
f
"
,
text
)
self
.
assertIn
(
"
\
n
1 + 1 = 2
\
n
^"
,
text
)
def
test_syntaxerror_multi_line_fstring
(
self
):
script
=
'foo = f"""{}
\
n
foo"""
\
n
'
with
support
.
temp_dir
()
as
script_dir
:
script_name
=
_make_test_script
(
script_dir
,
'script'
,
script
)
exitcode
,
stdout
,
stderr
=
assert_python_failure
(
script_name
)
self
.
assertEqual
(
stderr
.
splitlines
()[
-
3
:],
[
b' foo = f"""{}'
,
b' ^'
,
b'SyntaxError: f-string: empty expression not allowed'
,
],
)
def
test_consistent_sys_path_for_direct_execution
(
self
):
# This test case ensures that the following all give the same
# sys.path configuration:
...
...
Misc/NEWS.d/next/Core and Builtins/2019-06-27-15-01-14.bpo-37433.amNGqr.rst
0 → 100644
View file @
5b94f357
Fix ``SyntaxError`` indicator printing too many spaces for multi-line strings - by Anthony Sottile.
Parser/tokenizer.c
View file @
5b94f357
...
...
@@ -956,6 +956,7 @@ tok_nextc(struct tok_state *tok)
while
(
!
done
)
{
Py_ssize_t
curstart
=
tok
->
start
==
NULL
?
-
1
:
tok
->
start
-
tok
->
buf
;
Py_ssize_t
cur_multi_line_start
=
tok
->
multi_line_start
-
tok
->
buf
;
Py_ssize_t
curvalid
=
tok
->
inp
-
tok
->
buf
;
Py_ssize_t
newsize
=
curvalid
+
BUFSIZ
;
char
*
newbuf
=
tok
->
buf
;
...
...
@@ -968,6 +969,7 @@ tok_nextc(struct tok_state *tok)
}
tok
->
buf
=
newbuf
;
tok
->
cur
=
tok
->
buf
+
cur
;
tok
->
multi_line_start
=
tok
->
buf
+
cur_multi_line_start
;
tok
->
line_start
=
tok
->
cur
;
tok
->
inp
=
tok
->
buf
+
curvalid
;
tok
->
end
=
tok
->
buf
+
newsize
;
...
...
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