Miss Islington (bot)
d357f71f46
gh-96678: Fix UB of null pointer arithmetic (GH-96782)
...
Automerge-Triggered-By: GH:pablogsal
(cherry picked from commit 81e36f350b )
Co-authored-by: Matthias Görgens <matthias.goergens@gmail.com>
2022-09-13 08:03:51 -07:00
Miss Islington (bot)
b6af933716
gh-96611: Fix error message for invalid UTF-8 in mid-multiline string (GH-96623)
...
(cherry picked from commit 05692c67c5 )
Co-authored-by: Michael Droettboom <mdboom@gmail.com>
2022-09-06 16:36:03 -07:00
Gregory P. Smith
8f0fa4bd10
[3.10] gh-95778: CVE-2020-10735: Prevent DoS by very large int() ( #96501 )
...
Integer to and from text conversions via CPython's bignum `int` type is not safe against denial of service attacks due to malicious input. Very large input strings with hundred thousands of digits can consume several CPU seconds.
This PR comes fresh from a pile of work done in our private PSRT security response team repo.
This backports https://github.com/python/cpython/pull/96499 aka 511ca94520
Signed-off-by: Christian Heimes [Red Hat] <christian@python.org>
Tons-of-polishing-up-by: Gregory P. Smith [Google] <greg@krypto.org>
Reviews via the private PSRT repo via many others (see the NEWS entry in the PR).
<!-- gh-issue-number: gh-95778 -->
* Issue: gh-95778
<!-- /gh-issue-number -->
I wrote up [a one pager for the release managers](https://docs.google.com/document/d/1KjuF_aXlzPUxTK4BMgezGJ2Pn7uevfX7g0_mvgHlL7Y/edit# ).
2022-09-02 09:51:49 -07:00
Shantanu
9fbc81760e
[3.10] gh-94996: Disallow lambda pos only params with feature_version < (3, 8) (GH-95934) (GH-95938)
...
(cherry picked from commit a965db37f2 )
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Automerge-Triggered-By: GH:lysnikolaou
2022-08-12 12:47:07 -07:00
Shantanu
a92c2d6eb5
[3.10] gh-94996: Disallow parsing pos only params with feature_version < (3, 8) (GH-95935)
...
(cherry picked from commit b5e3ea2862 )
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Automerge-Triggered-By: GH:lysnikolaou
2022-08-12 12:03:44 -07:00
Christian Heimes
2a6b67f1c5
[3.10] gh-95876: Fix format string in pegen error location code (GH-95877 (GH-95901)
...
(cherry picked from commit b4c857d0fd )
Co-authored-by: Christian Heimes <christian@python.org>
2022-08-11 12:41:35 -07:00
Miss Islington (bot)
4513e4aba8
gh-95355: Check tokens[0] after allocating memory (GH-95356)
...
GH-95355
Automerge-Triggered-By: GH:pablogsal
(cherry picked from commit b946f529ef )
Co-authored-by: Honglin Zhu <zhuhonglin.zhl@alibaba-inc.com>
2022-07-28 03:45:01 -07:00
Shantanu
906b345ddd
[3.10] gh-94949: Disallow parsing parenthesised ctx mgr with old feature_version (GH-94950) ( #94990 )
...
(cherry picked from commit 0daba82221 )
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2022-07-19 07:24:48 +01:00
Shantanu
dda9198021
[3.10] gh-94947: Disallow parsing walrus with feature_version < (3, 8) (GH-94948) ( #94969 )
...
* gh-94947: Disallow parsing walrus with feature_version < (3, 8)
* oops, commit the parser
* 📜 🤖 Added by blurb_it.
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>.
(cherry picked from commit ae0be5a53b )
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2022-07-18 20:43:23 +01:00
Miss Islington (bot)
964431eaeb
gh-94869: Fix the location in some expressions for multi-line f-string ast nodes (GH-94895) ( #94911 )
...
(cherry picked from commit 2e9da8e352 )
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2022-07-16 22:06:33 +01:00
Pablo Galindo Salgado
697e78ca05
[3.10] gh-94360: Fix a tokenizer crash when reading encoded files with syntax errors from stdin (GH-94386) (GH-94574)
...
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
(cherry picked from commit 36fcde61ba )
2022-07-05 20:14:28 +02:00
wookie184
0ae7284a23
[3.10] gh-94192: Fix error for dictionary literals with invalid expression as value. (GH-94304) ( #94344 )
...
Co-authored-by: wookie184 <wookie1840@gmail.com>
2022-06-27 19:21:42 +01:00
Pablo Galindo Salgado
05cae26572
[3.10] gh-92858: Improve error message for some suites with syntax error before ':' (GH-92894). ( #94183 )
...
(cherry picked from commit 2fc83ac3af )
Co-authored-by: wookie184 <wookie1840@gmail.com>
Co-authored-by: wookie184 <wookie1840@gmail.com>
2022-06-23 18:37:53 +01:00
Pablo Galindo Salgado
8f36c735b2
[3.10] gh-93671: Avoid exponential backtracking in deeply nested sequence patterns in match statements (GH-93680) ( #93690 )
...
Co-authored-by: Łukasz Langa <lukasz@langa.pl>.
(cherry picked from commit 53a8b17895 )
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2022-06-10 19:34:15 +01:00
Miss Islington (bot)
855be47a02
gh-93418: Fix an assert when an f-string expression is followed by an '=', but no closing brace. (gh-93419) (gh-93423)
...
(cherry picked from commit ee70c70aa9 )
Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
2022-06-01 21:04:43 -04:00
Matthieu Dartiailh
94609e3192
[3.10] Backport bpo-47212 (GH-32302) to Python 3.10 (GH-32334)
...
(cherry picked from commit aa0f056a00 )
# Conflicts:
# Grammar/python.gram
# Parser/action_helpers.c
Automerge-Triggered-By: GH:pablogsal
2022-04-05 09:21:49 -07:00
Pablo Galindo Salgado
27ee431834
[3.10] bpo-47117: Don't crash if we fail to decode characters when the tokenizer buffers are uninitialized (GH-32129) (GH-32130)
...
Automerge-Triggered-By: GH:pablogsal.
(cherry picked from commit 26cca8067b )
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2022-03-26 18:26:05 +00:00
Miss Islington (bot)
f20ac2ed07
bpo-46820: Fix a SyntaxError in a numeric literal followed by "not in" (GH-31479) (GH-31493)
...
Fix parsing a numeric literal immediately (without spaces) followed by
"not in" keywords, like in "1not in x". Now the parser only emits
a warning, not a syntax error.
(cherry picked from commit 090e5c4b94 )
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-02-22 12:00:50 +02:00
Miss Islington (bot)
3d407b9311
bpo-46762: Fix an assert failure in f-strings where > or < is the last character if the f-string is missing a trailing right brace. (GH-31365)
...
(cherry picked from commit ffd9f8ff84 )
Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
2022-02-16 03:16:05 -08:00
Pablo Galindo Salgado
14284b0e71
[3.10] Allow the parser to avoid nested processing of invalid rules (GH-31252). (GH-31257)
...
(cherry picked from commit 390459de6d )
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2022-02-10 14:38:31 +00:00
Pablo Galindo Salgado
9b23f8f78f
[3.10] bpo-46707: Avoid potential exponential backtracking in some syntax errors (GH-31241). (GH-31242)
...
(cherry picked from commit b71dc71905 )
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2022-02-10 03:54:47 +00:00
Pablo Galindo Salgado
5b58db7529
[3.10] bpo-46521: Fix codeop to use a new partial-input mode of the parser (GH-31010). (GH-31213)
...
(cherry picked from commit 69e10976b2 )
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2022-02-08 12:25:15 +00:00
Miss Islington (bot)
91e8889044
bpo-14916: use specified tokenizer fd for file input (GH-31006)
...
@pablogsal, sorry i failed to rebase to main, so i recreated https://github.com/python/cpython/pull/22190GH-issuecomment-1024633392
> PyRun_InteractiveOne\*() functions allow to explicitily set fd instead of stdin.
but stdin was hardcoded in readline call.
> This patch does not fix target file for prompt unlike original bpo one : prompt fd is unrelated to tokenizer source which could be read only. It is more of a bugfix regarding the docs : actual documentation say "prompt the user" so one would expect prompt to go on stdout not a file for both PyRun_InteractiveOne\*() and PyRun_InteractiveLoop\*().
Automerge-Triggered-By: GH:pablogsal
(cherry picked from commit 89b13042fc )
Co-authored-by: Paul m. p. P <mail.peny@free.fr>
2022-02-03 15:32:22 -08:00
Pablo Galindo Salgado
3fc8b74ace
[3.10] bpo-46091: Correctly calculate indentation levels for whitespace lines with continuation characters (GH-30130). (GH-30898)
...
(cherry picked from commit a0efc0c196 )
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2022-01-25 22:33:57 +00:00
Miss Islington (bot)
894e8c1348
bpo-46503: Prevent an assert from firing when parsing some invalid \N sequences in f-strings. (GH-30865) (GH-30866)
...
* bpo-46503: Prevent an assert from firing. Also fix one nearby tiny PEP-7 nit.
* Added blurb.
(cherry picked from commit 0daf72194b )
Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
2022-01-24 22:13:11 -05:00
Pablo Galindo Salgado
633db1c4eb
[3.10] bpo-46240: Correct the error for unclosed parentheses when the tokenizer is not finished (GH-30378). (GH-30819)
...
(cherry picked from commit 70f415fb8b )
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2022-01-23 03:10:37 +00:00
Miss Islington (bot)
1fb1f5d8bd
[3.10] bpo-46339: Fix crash in the parser when computing error text for multi-line f-strings (GH-30529) (GH-30542)
...
* bpo-46339: Fix crash in the parser when computing error text for multi-line f-strings (GH-30529)
Automerge-Triggered-By: GH:pablogsal
(cherry picked from commit cedec19be8 )
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* Fix interactive mode
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2022-01-20 13:05:10 +00:00
Miss Islington (bot)
19a85501ce
bpo-46237: Fix the line number of tokenizer errors inside f-strings (GH-30463)
...
(cherry picked from commit 6fa8b2ceee )
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2022-01-11 08:33:08 -08:00
Miss Islington (bot)
bea3f42bb7
bpo-46289: Make conversion of FormattedValue not optional on ASDL (GH-30467)
...
Automerge-Triggered-By: GH:isidentical
(cherry picked from commit d382f7ee0b )
Co-authored-by: Batuhan Taskaya <batuhan@python.org>
2022-01-07 14:30:18 -08:00
Miss Islington (bot)
576e38f9db
bpo-42918: Improve built-in function compile() in mode 'single' (GH-29934) (GH-30040)
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit 28179aac79 )
Co-authored-by: Weipeng Hong <hongweichen8888@sina.com>
2021-12-27 17:15:44 +01:00
Pablo Galindo Salgado
dc73199a21
[3.10] bpo-46110: Add a recursion check to avoid stack overflow in the PEG parser (GH-30177) (GH-30214)
...
Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>.
(cherry picked from commit e9898bf153 )
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2021-12-20 16:23:37 +00:00
Miss Islington (bot)
94483f1e3c
bpo-46054: Fix parsing error when parsing non-utf8 characters in source files (GH-30068) (GH-30069)
...
(cherry picked from commit 4325a766f5 )
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2021-12-12 16:52:49 +00:00
Pablo Galindo Salgado
c521412003
[3.10] bpo-46004: Fix error location for loops with invalid targets (GH-29959). (GH-29961)
...
(cherry picked from commit 1c7a1c3be0 )
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2021-12-07 15:23:33 +00:00
Victor Stinner
b6defde2af
bpo-45866: pegen strips directory of "generated from" header (GH-29777) (GH-29792)
...
"make regen-all" now produces the same output when run from a
directory other than the source tree: when building Python out of the
source tree.
(cherry picked from commit 253b7a0a9f )
2021-11-26 16:38:50 +01:00
Pablo Galindo Salgado
c72311d917
[3.10] bpo-45727: Only trigger the 'did you forgot a comma' error suggestion if inside parentheses. (GH-29767)
...
Backport of GH-29757
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
2021-11-25 01:01:40 +00:00
Pablo Galindo Salgado
07cf66fd03
[3.10] Ensure the str member of the tokenizer is always initialised (GH-29681). (GH-29683)
...
(cherry picked from commit 4f006a789a )
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2021-11-21 04:15:22 +00:00
Miss Islington (bot)
a427eb862f
bpo-45494: Fix error location in EOF tokenizer errors (GH-29108)
...
(cherry picked from commit 79ff0d1687 )
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2021-11-20 09:59:34 -08:00
Pablo Galindo Salgado
511ee1c0fa
[3.10] bpo-45727: Make the syntax error for missing comma more consistent (GH-29427) (GH-29647)
...
(cherry picked from commit 546cefcda7 )
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2021-11-20 17:39:17 +00:00
Łukasz Langa
904af3de2b
[3.10] bpo-45848: Allow the parser to get error lines from encoded files (GH-29646) (GH-29661)
...
(cherry picked from commit fdcc46d955 )
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2021-11-20 16:34:56 +01:00
Miss Islington (bot)
b455df59a8
bpo-45820: Fix a segfault when the parser fails without reading any input (GH-29580)
...
(cherry picked from commit df4ae55e66 )
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2021-11-17 15:43:14 -08:00
Pablo Galindo Salgado
e3aa9fd77b
[3.10] bpo-45822: Respect PEP 263's coding cookies in the parser even if flags are not provided (GH-29582) (GH-29586)
...
(cherry picked from commit da20d7401d )
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2021-11-18 00:17:18 +01:00
Pablo Galindo Salgado
5618c81e13
[3.10] bpo-45716: Improve the error message when using True/False/None as keywords in a call (GH-29413). (GH-29428)
...
(cherry picked from commit e2d65630f3 )
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2021-11-16 22:31:16 +00:00
Miss Islington (bot)
bf26a6da7a
bpo-45738: Fix computation of error location for invalid continuation (GH-29550)
...
characters in the parser
(cherry picked from commit 25835c518a )
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2021-11-13 17:30:03 -08:00
Pablo Galindo Salgado
0e34a5918c
[3.10] bpo-44257: fix "assigment_expr" typo + regenerate the grammar, and remove unused imports (GH-29393) (GH-29395)
...
Co-authored-by: Wim Glenn <wglenn@jumptrading.com>.
(cherry picked from commit 762173c670 )
Co-authored-by: wim glenn <wim.glenn@gmail.com>
2021-11-05 00:19:27 +01:00
Miss Islington (bot)
d8ca47c943
bpo-45562: Ensure all tokenizer debug messages are printed to stderr (GH-29270)
...
(cherry picked from commit cdc7a58277 )
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2021-10-29 10:21:15 -07:00
Miss Islington (bot)
038f452308
bpo-45562: Print tokenizer debug messages to stderr (GH-29250) (GH-29252)
...
(cherry picked from commit 10bbd41ba8 )
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2021-10-27 22:45:43 +01:00
Miss Islington (bot)
cadf06eab7
bpo-45574: fix warning about print_escape being unused (GH-29172) ( #29176 )
...
It used to be like this:
<img width="1232" alt="Снимок экрана 2021-10-22 в 23 07 40" src="https://user-images.githubusercontent.com/4660275/138516608-fef6ec01-a96a-40f4-81ef-52265b0f536b.png ">
Quick `grep` tells that it is just used in one place under `Py_DEBUG`: https://github.com/python/cpython/blame/f6e8b80d20159596cf641305bad3a833bedd2f4f/Parser/tokenizer.cGH-L1047-L1051
<img width="752" alt="Снимок экрана 2021-10-22 в 23 08 09" src="https://user-images.githubusercontent.com/4660275/138516684-ea503136-1e92-48a5-95bb-419e190d5866.png ">
I am not sure, but it also looks like a private thing, it should not affect other users.
Automerge-Triggered-By: GH:pablogsal
(cherry picked from commit 4bc5473a42 )
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2021-10-23 14:35:48 +01:00
Miss Islington (bot)
ae78ffdc93
bpo-45562: Only show debug output from the parser in debug builds (GH-29140) ( #29149 )
...
(cherry picked from commit 86dfb55d2e )
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2021-10-22 11:14:47 +01:00
Łukasz Langa
5c9cab595e
[3.10] bpo-45494: Fix parser crash when reporting errors involving invalid continuation characters (GH-28993) (GH-29070)
...
There are two errors that this commit fixes:
* The parser was not correctly computing the offset and the string
source for E_LINECONT errors due to the incorrect usage of strtok().
* The parser was not correctly unwinding the call stack when a tokenizer
exception happened in rules involving optionals ('?', [...]) as we
always make them return valid results by using the comma operator. We
need to check first if we don't have an error before continuing..
(cherry picked from commit a106343f63 )
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2021-10-19 22:31:18 +02:00
Miss Islington (bot)
0bff4ccbfd
[3.10] bpo-45461: Fix IncrementalDecoder and StreamReader in the "unicode-escape" codec (GH-28939) (GH-28943)
...
They support now splitting escape sequences between input chunks.
Add the third parameter "final" in codecs.unicode_escape_decode().
It is True by default to match the former behavior.
(cherry picked from commit c96d1546b1 )
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2021-10-14 20:02:20 +03:00