Commit Graph

28668 Commits

Author SHA1 Message Date
Miss Islington (bot) dbde686a49
gh-97591: In `Exception.__setstate__()` acquire strong references before calling `tp_hash` slot (GH-97700)
(cherry picked from commit d639438609)

Co-authored-by: Ofey Chan <ofey206@gmail.com>
2022-10-01 21:19:57 -07:00
Miss Islington (bot) 3614bbb8eb
gh-90908: Document asyncio.Task.cancelling() and asyncio.Task.uncancel() (GH-95253)
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
(cherry picked from commit f00645d5db)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2022-10-01 11:10:04 -07:00
Miss Islington (bot) 3124618fd5
GH-97592: Fix crash in C remove_done_callback due to evil code (GH-97660)
Evil code could cause fut_callbacks to be cleared when PyObject_RichCompareBool is called.
(cherry picked from commit 63780f4599)

Co-authored-by: Guido van Rossum <guido@python.org>
2022-09-30 13:22:48 -07:00
Miss Islington (bot) f418842a5c
[3.11] gh-96357: Improve `typing.get_overloads` coverage (GH-96358) (#96371)
gh-96357: Improve `typing.get_overloads` coverage (GH-96358)
(cherry picked from commit 675e3470cc)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-09-28 18:06:21 -07:00
Miss Islington (bot) 7d60d10b63
gh-97616: list_resize() checks for integer overflow (GH-97617)
Fix multiplying a list by an integer (list *= int): detect the
integer overflow when the new allocated length is close to the
maximum size.  Issue reported by Jordan Limor.

list_resize() now checks for integer overflow before multiplying the
new allocated length by the list item size (sizeof(PyObject*)).
(cherry picked from commit a5f092f3c4)

Co-authored-by: Victor Stinner <vstinner@python.org>
2022-09-28 15:28:38 -07:00
Miss Islington (bot) f391b3c6ab
gh-96478: Fix new test when run in refleak mode (GH-96615)
./python.exe -m test -R : test.test_typing would fail, apparently
because the dictionary used in the @patch decorator was modified.
(cherry picked from commit f0d9136c69)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-09-27 07:50:36 -07:00
Miss Islington (bot) 9a9bf88898
gh-97545: Make Semaphore run faster. (GH-97549)
(cherry picked from commit 68c46ae68b)

Co-authored-by: Cyker Way <cykerway@gmail.com>
2022-09-26 17:00:53 -07:00
Miss Islington (bot) a4ff0eaaf0
gh-96848: Fix -X int_max_str_digits option parsing (GH-96988)
Fix command line parsing: reject "-X int_max_str_digits" option with
no value (invalid) when the PYTHONINTMAXSTRDIGITS environment
variable is set to a valid limit.
(cherry picked from commit 41351662bc)

Co-authored-by: Victor Stinner <vstinner@python.org>
2022-09-26 08:43:26 -07:00
Miss Islington (bot) 6daff06fc2
gh-94808: Coverage: Test uppercase string literal prefixes (GH-95925)
(cherry picked from commit f00383ec9b)

Co-authored-by: Michael Droettboom <mdboom@gmail.com>
2022-09-25 01:21:58 -07:00
Miss Islington (bot) a386d1341c
gh-96052: codeop: fix handling compiler warnings in incomplete input (GH-96132)
Previously codeop.compile_command() emitted compiler warnings (SyntaxWarning or
DeprecationWarning) and raised a SyntaxError for incomplete input containing
a potentially incorrect code. Now it always returns None for incomplete input
without emitting any warnings.
(cherry picked from commit 426d72e7dd)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-09-25 01:21:00 -07:00
Miss Islington (bot) 4d1de87042
gh-96959: Update HTTP links which are redirected to HTTPS (GH-96961)
(cherry picked from commit db39050396)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-09-25 01:20:45 -07:00
Miss Islington (bot) 6a646dd1ff
GH-96975: Skip incomplete frames in PyEval_GetFrame (GH-97018)
(cherry picked from commit 8fd2c3b75b)

Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
2022-09-22 10:17:53 -07:00
Miss Islington (bot) 773dbb9e3a
gh-90155: Fix bug in asyncio.Semaphore and strengthen FIFO guarantee (GH-93222)
The main problem was that an unluckily timed task cancellation could cause
the semaphore to be stuck. There were also doubts about strict FIFO ordering
of tasks allowed to pass.

The Semaphore implementation was rewritten to be more similar to Lock.
Many tests for edge cases (including cancellation) were added.
(cherry picked from commit 24e0379624)

Co-authored-by: Cyker Way <cykerway@gmail.com>
2022-09-22 09:58:35 -07:00
Łukasz Langa d35b9d0a60
[3.11] gh-96954: Add tests for unicodedata.name/lookup (GH-96955) (GH-96991)
They were undertested, and since GH-96954 might involve a
rewrite of this part of the code we want to ensure that
there won't be any behavioral change.

Co-authored-by: Carl Friedrich Bolz-Tereick <cfbolz@gmx.de>
(cherry picked from commit 5a32eeced2)

Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>
2022-09-21 16:07:07 +02:00
Miss Islington (bot) 46f791d263
gh-90808: add more examples to `test_sched.test_priority` (GH-31144)
(cherry picked from commit 57463d43dc)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-09-20 19:03:13 -07:00
Miss Islington (bot) e066c6a56b
gh-95950: Add a test for both `csv.Dialect` and `kwargs` (GH-95951)
(cherry picked from commit 1c01bd28a0)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-09-20 18:37:10 -07:00
Miss Islington (bot) 2a5e333736
gh-96478: Test `@overload` on C functions (GH-96479)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit f177f6f29b)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-09-20 18:36:23 -07:00
Miss Islington (bot) fd118a0850
gh-95591: [Enum] use `_FlagTests` base class (GH-96475)
(cherry picked from commit 9b58eaf98c)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-09-20 16:34:14 -07:00
Brandt Bucher 0e61d2b557
[3.11] GH-95921: Fix positions for some chained comparisons (GH-96968) (GH-96973)
(cherry picked from commit dfc73b5724)

Automerge-Triggered-By: GH:brandtbucher
2022-09-20 14:56:38 -07:00
Miss Islington (bot) 32d80decbf
GH-96864: Check for error between line and opcode events (GH-96880)
(cherry picked from commit c10e33ac11)

Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
2022-09-20 10:49:01 -07:00
Miss Islington (bot) d39fce0f03
Fix ResourceWarning in test.test_frame (GH-96831)
(cherry picked from commit 303bd88047)

Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
2022-09-16 17:03:57 -07:00
Christian Heimes bc337a7766
[3.11] gh-96005: Handle WASI ENOTCAPABLE in getpath (GH-96006) (GH-96034) (GH-96038)
- On WASI `ENOTCAPABLE` is now mapped to `PermissionError`.
- The `errno` modules exposes the new error number.
- `getpath.py` now ignores `PermissionError` when it cannot open landmark
  files `pybuilddir.txt` and `pyenv.cfg`.
2022-09-13 13:00:45 +02:00
Christian Heimes 4958820032
[3.11] gh-95853: Add script to automate WASM build (GH-95828, GH-95985, GH-96045, GH-96389, GH-96744) (GH-96749)
Automate WASM build with a new Python script. The script provides
several build profiles with configure flags for Emscripten flavors
and WASI. The script can detect and use Emscripten SDK and WASI SDK from
default locations or env vars.

``configure`` now detects Node arguments and creates HOSTRUNNER
arguments for Node 16. It also sets correct arguments for
``wasm64-emscripten``.
2022-09-13 12:06:39 +02:00
Miss Islington (bot) fecda02eb6
gh-96710: Make the test timing more lenient for the int/str DoS regression test. (GH-96717)
A regression would still absolutely fail and even a flaky pass isn't
harmful as it'd fail most of the time across our N system test runs.

Windows has a low resolution timer and CI systems are prone to odd
timing so this just gives more leeway to avoid flakiness.
(cherry picked from commit 11e3548fd1)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2022-09-09 13:17:04 -07:00
Mark Shannon 5586da65e2
[3.11] GH-96636: Remove all uses of NOTRACE_DISPATCH (GH-96643) (#96688)
Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
(cherry picked from commit aa3b4cf779)
2022-09-09 09:24:44 -07:00
Miss Islington (bot) 99919d4e8a
gh-96352: Set AttributeError context in _PyObject_GenericGetAttrWithDict (GH-96353)
(cherry picked from commit b9634ac776)

Co-authored-by: philg314 <110174000+philg314@users.noreply.github.com>
2022-09-08 04:43:52 -07:00
Miss Islington (bot) 0c443c2315
GH-94808: Test __build_class__ inside non-dict __builtins__ (GH-95932) (#96004)
(cherry picked from commit 3adb4d864b)

Co-authored-by: Michael Droettboom <mdboom@gmail.com>

Co-authored-by: Michael Droettboom <mdboom@gmail.com>
2022-09-08 12:17:18 +01:00
Miss Islington (bot) ae819ca6fd
[3.11] gh-68163: Correct conversion of Rational instances to float (GH-25619) (#96556)
Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2022-09-08 12:03:53 +01:00
Miss Islington (bot) ffafa9b91d
gh-96268: Fix loading invalid UTF-8 (GH-96270)
This makes tokenizer.c:valid_utf8 match stringlib/codecs.h:decode_utf8.

It also fixes an off-by-one error introduced in 3.10 for the line number when the tokenizer reports bad UTF8.
(cherry picked from commit 8bc356a7dd)

Co-authored-by: Michael Droettboom <mdboom@gmail.com>
2022-09-07 14:49:17 -07:00
Miss Islington (bot) 295f510f5a
gh-94808: Improve coverage of _PyBytes_FormatEx (GH-95895)
There were two specific areas not covered:

- %(name) syntax
- %*s syntax

Automerge-Triggered-By: GH:iritkatriel
(cherry picked from commit dde15f5879)

Co-authored-by: Michael Droettboom <mdboom@gmail.com>
2022-09-07 05:18:33 -07:00
Miss Islington (bot) bb0dab5c48
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:40:17 -07:00
Mark Shannon 26dc4dfac3
[3.11] GH-96612: Skip incomplete frames in tracemalloc traces. (GH-96613) (#96617)
(cherry picked from commit 95e271b226)

Co-authored-by: Mark Shannon <mark@hotpy.org>
2022-09-06 18:42:41 +01:00
Batuhan Taskaya a0848d169b
[3.11] gh-92986: Fix ast.unparse when ImportFrom.level is None (GH-92992) (GH-96593)
This doesn't happen naturally, but is allowed by the ASDL and compiler.
We don't want to change ASDL for backward compatibility reasons
(GH-57645, GH-92987)
(cherry picked from commit 200c9a8da0)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2022-09-06 13:23:26 +03:00
Miss Islington (bot) 08d8058b79
gh-96559: Fixes Windows launcher handling of defaults using old-style tags, and adds What's New section (GH-96595)
(cherry picked from commit 80a9bd2e94)

Co-authored-by: Steve Dower <steve.dower@python.org>
2022-09-05 15:13:24 -07:00
Miss Islington (bot) 8a776d1d51
gh-95778: Correctly pre-check for int-to-str conversion (GH-96537)
Converting a large enough `int` to a decimal string raises `ValueError` as expected. However, the raise comes _after_ the quadratic-time base-conversion algorithm has run to completion. For effective DOS prevention, we need some kind of check before entering the quadratic-time loop. Oops! =)

The quick fix: essentially we catch _most_ values that exceed the threshold up front. Those that slip through will still be on the small side (read: sufficiently fast), and will get caught by the existing check so that the limit remains exact.

The justification for the current check. The C code check is:
```c
max_str_digits / (3 * PyLong_SHIFT) <= (size_a - 11) / 10
```

In GitHub markdown math-speak, writing $M$ for `max_str_digits`, $L$ for `PyLong_SHIFT` and $s$ for `size_a`, that check is:
$$\left\lfloor\frac{M}{3L}\right\rfloor \le \left\lfloor\frac{s - 11}{10}\right\rfloor$$

From this it follows that
$$\frac{M}{3L} < \frac{s-1}{10}$$
hence that
$$\frac{L(s-1)}{M} > \frac{10}{3} > \log_2(10).$$
So
$$2^{L(s-1)} > 10^M.$$
But our input integer $a$ satisfies $|a| \ge 2^{L(s-1)}$, so $|a|$ is larger than $10^M$. This shows that we don't accidentally capture anything _below_ the intended limit in the check.

<!-- gh-issue-number: gh-95778 -->
* Issue: gh-95778
<!-- /gh-issue-number -->

Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
(cherry picked from commit b126196838)

Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
2022-09-04 09:45:02 -07:00
Vinay Sajip f255820626
[3.11] gh-90195: Unset logger disabled flag when configuring it. (GH-96530) (GH-96532) 2022-09-03 15:10:50 +01:00
Gregory P. Smith f8b71da9aa
[3.11] gh-95778: CVE-2020-10735: Prevent DoS by very large int() (#96500)
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:48:57 -07:00
Ethan Furman 8f58db2279
[3.11] [Enum] fix check in _test_simple_enum (GH-96435)
The builtin `property` is not a callable, so was failing the check in
`_test_simple_enum` causing a match failure; this adds `property` to the
bypass list.

Co-authored-by: Alexandru Mărășteanu <alexei@users.noreply.github.com>
2022-08-30 12:39:03 -07:00
Miss Islington (bot) 2e9f29e6a6
GH-74116: Allow multiple drain waiters for asyncio.StreamWriter (GH-94705) (#96395)
(cherry picked from commit e5b2453e61)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-08-30 12:00:21 +01:00
Miss Islington (bot) 16d8948c31
gh-96385: Correctly raise error on `[*T, *V]` substitution (GH-96386) (#96407)
(cherry picked from commit 75177358a6)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-08-30 11:58:54 +01:00
Miss Islington (bot) 103f26f282
[3.11] gh-89047: Fix msecs computation so you never end up with 1000 msecs. (GH-96340) (GH-96341) 2022-08-27 15:09:54 +01:00
Miss Islington (bot) acd7841aa4
Port regression test for issue GH-93592 (GH-96208) (GH-96313) 2022-08-26 16:02:36 +01:00
Miss Islington (bot) 915ee9ed43
gh-95243: Mitigate the race condition in testSockName (GH-96173)
find_unused_port() has an inherent race condition, but we can't use
bind_port() as that uses .getsockname() which this test is exercising.

Try binding to unused ports a few times before failing.

Signed-off-by: Ross Burton <ross.burton@arm.com>
(cherry picked from commit df11012697)

Co-authored-by: Ross Burton <ross.burton@arm.com>
2022-08-24 19:03:29 -07:00
Miss Islington (bot) c01fc9d30a
[3.11] gh-96189: Fix test_invalid_utf8 on a number of build bots (GH-96190) (#96218)
Co-authored-by: Michael Droettboom <mdboom@gmail.com>
2022-08-23 23:28:44 +01:00
Miss Islington (bot) d7eea0f1ca
gh-96175: add missing self._localName assignment in `xml.dom.minidom.Attr` (GH-96176)
X-Ref: https://github.com/python/typeshed/pull/8590GH-discussion_r951473977

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
(cherry picked from commit 58f6953d6d)

Co-authored-by: Kevin Kirsche <Kev.Kirsche+GitHub@gmail.com>
2022-08-23 10:18:19 -07:00
Miss Islington (bot) 0aed1e71f3
GH-96071: add regression test for GH-96071 (GH-96137)
Automerge-Triggered-By: GH:ericsnowcurrently
(cherry picked from commit 079baee196)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-08-23 08:37:19 -07:00
Miss Islington (bot) 4f7f83b5bd
gh-96076: Change test_launcher to use non-admin location for py.ini (GH-96091)
Patch authored by Eryksun.
(cherry picked from commit 216ccacda1)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2022-08-22 09:49:34 -07:00
Miss Islington (bot) 27f390bc30
gh-96125: Fix sys.thread_info.name on pthread platforms (GH-96126) (#96128)
Automerge-Triggered-By: GH:tiran
(cherry picked from commit 822955c166)

Co-authored-by: Christian Heimes <christian@python.org>

Co-authored-by: Christian Heimes <christian@python.org>
2022-08-21 17:37:15 +01:00
Miss Islington (bot) 1b9b4856c8
[3.11] gh-95913: make the new internal classes pdb.ModuleTarget/ScriptTarget private (GH-96053) (#96063)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2022-08-18 14:39:16 +01:00
Miss Islington (bot) 36c114ab11
GH-95704: Don't suppress errors from tasks when TG is cancelled (GH-95761)
When a task catches CancelledError and raises some other error,
the other error should not silently be suppressed.

Any scenario where a task crashes in cleanup upon cancellation
will now result in an ExceptionGroup wrapping the crash(es)
instead of propagating CancelledError and ignoring the side errors.

NOTE: This represents a change in behavior (hence the need to
change several tests).  But it is only an edge case.

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
(cherry picked from commit f51f54f39d)

Co-authored-by: Guido van Rossum <guido@python.org>
2022-08-17 10:04:59 -07:00