Pablo Galindo
bd2728b1e8
bpo-42806: Fix ast locations of f-strings inside parentheses (GH-24067)
2021-01-03 01:11:41 +00:00
han-solo
749ed85e44
Fixed mistake in test for f-string error description (GH-22036) (GH-22059)
2020-09-02 04:56:37 -04:00
han-solo
0d6aa7f0ee
bpo-41681: Fix for `f-string/str.format` error description when using 2 `,` in format specifier (GH-22036)
...
* Fixed `f-string/str.format` error description when using two `,` in format specifier.
Co-authored-by: millefalcon <hanish0019@hmail.com>
2020-09-01 10:34:29 -04:00
Hai Shi
a089d21df1
bpo-40275: Use new test.support helper submodules in tests (GH-21315)
2020-07-06 11:15:08 +02:00
Lysandros Nikolaou
2e0a920e9e
bpo-41084: Adjust message when an f-string expression causes a SyntaxError (GH-21084)
...
Prefix the error message with `fstring: `, when parsing an f-string expression throws a `SyntaxError`.
2020-06-26 12:24:05 +01:00
Serhiy Storchaka
700cfa8c90
bpo-41069: Make TESTFN and the CWD for tests containing non-ascii characters. (GH-21035)
2020-06-25 17:56:31 +03:00
Pablo Galindo
1ed83adb0e
bpo-40939: Remove the old parser (GH-20768)
...
This commit removes the old parser, the deprecated parser module, the old parser compatibility flags and environment variables and all associated support code and documentation.
2020-06-11 17:30:46 +01:00
Pablo Galindo
972ab03276
bpo-40904: Fix segfault in the new parser with f-string containing yield statements with no value (GH-20701)
2020-06-08 01:47:37 +01:00
Lysandros Nikolaou
f7b1e46156
bpo-38964: Print correct filename on a SyntaxError in an fstring (GH-20399)
...
When a `SyntaxError` in the expression part of a fstring is found,
the filename attribute of the `SyntaxError` is always `<fstring>`.
With this commit, it gets changed to always have the name of the file
the fstring resides in.
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2020-05-26 01:32:18 +01:00
Serhiy Storchaka
74ea6b5a75
bpo-40593: Improve syntax errors for invalid characters in source code. (GH-20033)
2020-05-12 12:42:04 +03:00
Lysandros Nikolaou
846d8b28ab
bpo-40246: Revert reporting of invalid string prefixes (GH-19888)
...
Due to backwards compatibility concerns regarding keywords immediately followed by a string without whitespace between them (like in `bg="#d00" if clear else"#fca"`) will fail to parse,
commit 41d5b94af4
has to be reverted.
2020-05-04 12:32:18 +01:00
Victor Stinner
b1e11c31c5
bpo-40443: Remove unused imports in tests (GH-19804)
2020-04-30 02:21:30 +02:00
Lysandros Nikolaou
37af21b667
bpo-40334: Fix shifting of nested f-strings in the new parser (GH-19771)
...
`JoinedStr`s and `FormattedValue also needs to be shifted, in order to correctly compute the location information of nested f-strings.
2020-04-29 01:43:50 +01:00
Victor Stinner
1def7754b7
bpo-40334: Rename PyConfig.use_peg to _use_peg_parser (GH-19670)
...
* Rename PyConfig.use_peg to _use_peg_parser
* Document PyConfig._use_peg_parser and mark it a deprecated
* Mark -X oldparser option and PYTHONOLDPARSER env var as deprecated
in the documentation.
* Add use_old_parser() and skip_if_new_parser() to test.support
* Remove sys.flags.use_peg: use_old_parser() uses
_testinternalcapi.get_configs() instead.
* Enhance test_embed tests
* subprocess._args_from_interpreter_flags() copies -X oldparser
2020-04-23 03:03:24 +02:00
Pablo Galindo
c5fc156852
bpo-40334: PEP 617 implementation: New PEG parser for CPython (GH-19503)
...
Co-authored-by: Guido van Rossum <guido@python.org>
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
2020-04-22 23:29:27 +01:00
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