Lysandros Nikolaou
9a4b38f66b
bpo-40267: Fix message when last input character produces a SyntaxError (GH-19521)
...
When there is a SyntaxError after reading the last input character from
the tokenizer and if no newline follows it, the error message used to be
`unexpected EOF while parsing`, which is wrong.
2020-04-15 11:22:10 -07:00
Pablo Galindo
70c188eee0
Add double quote cases to invalid prefix tests (GH-19489)
2020-04-13 02:47:35 +01:00
Lysandros Nikolaou
41d5b94af4
bpo-40246: Report a better error message for invalid string prefixes (GH-19476)
2020-04-12 19:21:00 +01:00
Gregory P. Smith
b4be87a04a
bpo-32912: Revert SyntaxWarning on invalid escape sequences. (GH-15195)
...
DeprecationWarning will continue to be emitted for invalid escape
sequences in string and bytes literals just as it did in 3.7.
SyntaxWarning may be emitted in the future. But per mailing list
discussion, we don't yet know when because we haven't settled on how to
do so in a non-disruptive manner.
(Applies 4c5b6bac24
to the master branch).
(This is https://github.com/python/cpython/pull/15142 for master/3.9)
https://bugs.python.org/issue32912
Automerge-Triggered-By: @gpshead
2019-08-10 00:19:07 -07:00
Min ho Kim
96e12d5f4f
Fix typos in docs, comments and test assert messages ( #14872 )
2019-07-21 16:12:33 -04:00
Eric V. Smith
6f6ff8a565
bpo-37050: Remove expr_text from FormattedValue ast node, use Constant node instead (GH-13597)
...
When using the "=" debug functionality of f-strings, use another Constant node (or a merged constant node) instead of adding expr_text to the FormattedValue node.
2019-05-27 15:31:52 -04:00
Pablo Galindo
26f55c29f2
bpo-36817: Do not decrement reference for expr_text on fstring = parsing failure (GH-13256)
2019-05-12 01:43:04 +01:00
Eric V. Smith
9a4135e939
bpo-36817: Add f-string debugging using '='. (GH-13123)
...
If a "=" is specified a the end of an f-string expression, the f-string will evaluate to the text of the expression, followed by '=', followed by the repr of the value of the expression.
2019-05-08 16:28:48 -04:00
Anthony Sottile
995d9b9297
bpo-16806: Fix `lineno` and `col_offset` for multi-line string tokens (GH-10021)
2019-01-13 13:05:13 +09:00
Serhiy Storchaka
58159ef856
bpo-35494: Improve syntax error messages for unbalanced parentheses in f-string. (GH-11161)
2019-01-12 09:46:50 +02:00
Serhiy Storchaka
94cf308ee2
bpo-33306: Improve SyntaxError messages for unbalanced parentheses. (GH-6516)
2018-12-17 17:34:14 +02:00
Serhiy Storchaka
6543912c90
bpo-32912: Replace a DeprecationWarning with a SyntaxWarning (GH-9652)
...
for invalid escape sequences in string and bytes literals.
2018-10-19 17:42:06 +03:00
Serhiy Storchaka
3f22811fef
bpo-32892: Use ast.Constant instead of specific constant AST types. (GH-9445)
2018-09-27 17:42:37 +03:00
Łukasz Langa
e7c566caf1
bpo-30465: Fix lineno and col_offset in fstring AST nodes ( #1800 )
...
For f-string ast nodes, fix the line and columns so that tools such as flake8 can identify them correctly.
2017-09-06 17:27:58 -07:00
ericvsmith
11e97f2f80
bpo-30682: Removed a too-strict assertion that failed for certain f-strings. ( #2232 )
...
This caused a segfault on eval("f'\\\n'") and eval("f'\\\r'") in debug build.
2017-06-16 13:19:32 +03:00
Serhiy Storchaka
2e9cd5825c
bpo-30529: Fix errors for invalid whitespaces in f-string subexpressions. ( #1888 )
...
'invalid character in identifier' now is raised instead of
'f-string: empty expression not allowed' if a subexpression contains
only whitespaces and they are not accepted by Python parser.
2017-06-08 23:43:54 +03:00
Serhiy Storchaka
0cd7a3f196
bpo-29104: Fixed parsing backslashes in f-strings. ( #490 )
2017-05-25 13:33:55 +03:00
Serhiy Storchaka
4cc30ae313
Issue #28739 : f-string expressions no longer accepted as docstrings and
...
by ast.literal_eval() even if they do not include subexpressions.
2016-12-11 19:37:19 +02:00
Eric V. Smith
9b88fdf4f0
Fixed issue #28633 : segfault when concatenating bytes literal and f-string.
2016-11-07 17:54:01 -05:00
Jason R. Coombs
1c92a76a69
Update test_no_escapes_for_braces to clarify behavior with a docstring and expressions that clearly are not evaluated.
2016-11-06 11:25:54 -05:00
Jason R. Coombs
da25abf712
Additionally show that a backslash-escaped opening brace is treated as a literal and thus triggers the single closing brace error, clarifying #28590 .
2016-11-06 11:14:48 -05:00
Jason R. Coombs
45cab8ccdd
Add an additional test with a newline, one that's very similar to test_parens_in_expressions, but because the newline is not a literal newline, but a backslash en, this error is triggered.
2016-11-06 11:01:08 -05:00
Serhiy Storchaka
13c8f3266a
Update the f-string test broken in issue #28385 .
2016-10-31 08:13:00 +02:00
Eric V. Smith
35a24c5a43
Add another f-string comment test, to make sure # are being caught in the right place.
2016-09-11 19:01:22 -04:00
Eric V. Smith
09835dcdbb
Make an f-string error message more exact and consistent.
2016-09-11 18:58:20 -04:00
Eric V. Smith
451d0e38fc
Issue 27948: Allow backslashes in the literal string portion of f-strings, but not in the expressions. Also, require expressions to begin and end with literal curly braces.
2016-09-09 21:56:20 -04:00
Eric V. Smith
6a4efce7a5
Closes issue 27921: Disallow backslashes anywhere in f-strings. This is a temporary restriction. In 3.6 beta 2, the plan is to again allow backslashes in the string parts of f-strings, but disallow them in the expression parts.
2016-09-03 09:18:34 -04:00
Martin Panter
263893c261
Issue #27626 : Further spelling fixes for 3.6
2016-07-28 01:25:31 +00:00
Eric V. Smith
135d5f49f6
Fix issue 26287: While handling FORMAT_VALUE opcode, the top of stack was being corrupted if an error occurred in PyObject_Format().
2016-02-05 18:23:08 -05:00
Eric V. Smith
b2080f6554
f-strings: More tests for empty expressions along with missing closing braces.
2015-09-23 10:24:43 -04:00
Eric V. Smith
548c4d3178
Added more f-string test for empty expressions.
2015-09-23 08:00:01 -04:00
Eric V. Smith
1d44c41b0c
Move f-string compilation of the expression earlier, before the conversion character and format_spec are checked. This allows for error messages that more closely match what a user would expect.
2015-09-23 07:49:00 -04:00
Eric V. Smith
235a6f0984
Issue #24965 : Implement PEP 498 "Literal String Interpolation". Documentation is still needed, I'll open an issue for that.
2015-09-19 14:51:32 -04:00