Commit graph

28803 commits

Author SHA1 Message Date
Gregory P. Smith 511ca94520
gh-95778: CVE-2020-10735: Prevent DoS by very large int() (#96499)
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.

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#). Much of that text wound up in the Issue. Backports PRs already exist. See the issue for links.
2022-09-02 09:35:08 -07:00
Raymond Hettinger 656167db81
Allow whitespace around a slash in fraction string inputs (GH-96496) 2022-09-02 11:10:58 -05:00
Irit Katriel 4c72517cad
gh-93554: Conditional jump opcodes only jump forward (GH-96318) 2022-09-01 21:36:47 +01:00
Irit Katriel 894cafd9a5
gh-93678: apply remove_redundant_jumps in optimize_cfg (GH-96274) 2022-09-01 11:03:52 +01:00
Gregory P. Smith e93d1bda77
gh-96143: subprocess API %s/universal_newlines=/text=/g. (GH-96468)
minor missed test cleanup to use the modern API from the big review.

Automerge-Triggered-By: GH:gpshead
2022-09-01 02:47:40 -07:00
Anh71me 0cd33e11fe
GH-96079 Fix missing field name for _AnnotatedAlias (#96080) 2022-08-31 16:02:24 -07:00
Vinay Sajip 29f1b0bb1f
gh-89258: Add a getChildren() method to logging.Logger. (GH-96444)
Co-authored-by: Éric <merwok@netwok.org>
2022-08-31 10:50:29 +01:00
Filip Łajszczak 02dbb362d3
gh-96408: Test set operation on items dict view. (GH-96438) 2022-08-30 17:43:23 -05:00
Pablo Galindo Salgado f49dd54b72
gh-96143: Add some comments and minor fixes missed in the original PR (#96433)
* gh-96132: Add some comments and minor fixes missed in the original PR

* Update Doc/using/cmdline.rst

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 19:37:22 +01:00
Alexandru Mărășteanu 0ed778835d
gh-95149: Enhance http.HTTPStatus with properties that indicate the HTTP status category (GH-95453) 2022-08-30 11:11:44 -07:00
Nikita Sobolev 4217393aee
gh-95987: Fix repr of Any type subclasses (#96412) 2022-08-30 10:36:16 -07:00
Pablo Galindo Salgado 6d791a9736
gh-96143: Allow Linux perf profiler to see Python calls (GH-96123)
⚠️  ⚠️ Note for reviewers, hackers and fellow systems/low-level/compiler engineers ⚠️ ⚠️ 

If you have a lot of experience with this kind of shenanigans and want to improve the **first** version, **please make a PR against my branch** or **reach out by email** or **suggest code changes directly on GitHub**. 

If you have any **refinements or optimizations** please, wait until the first version is merged before starting hacking or proposing those so we can keep this PR productive.
2022-08-30 10:11:18 -07:00
Nikita Sobolev 75177358a6
gh-96385: Correctly raise error on [*T, *V] substitution (GH-96386) 2022-08-30 10:34:55 +03:00
Kumar Aditya e5b2453e61
GH-74116: Allow multiple drain waiters for asyncio.StreamWriter (GH-94705) 2022-08-29 11:31:11 -07:00
Nikita Sobolev 675e3470cc
gh-96357: Improve typing.get_overloads coverage (#96358) 2022-08-28 17:45:24 -07:00
Nikita Sobolev 1c01bd28a0
gh-95950: Add a test for both csv.Dialect and kwargs (#95951) 2022-08-28 17:43:32 -07:00
TW 023c51d9d8
gh-69142: add %:z strftime format code (gh-95983)
datetime.isoformat generates the tzoffset with colons, but there
was no format code to make strftime output the same format.

for simplicity and consistency the %:z formatting behaves mostly
as %z, with the exception of adding colons. this includes the
dynamic behaviour of adding seconds and microseconds only when
needed (when not 0).

this fixes the still open "generate" part of this issue:

https://github.com/python/cpython/issues/69142

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-08-28 14:27:42 -07:00
Vinay Sajip 6fbd889d6e
gh-89047: Fix msecs computation so you never end up with 1000 msecs. (GH-96340) 2022-08-27 13:33:24 +01:00
Irit Katriel ccf94a6289
gh-96280: suppress deprecation warning in test_importlib (GH-96281) 2022-08-26 22:44:33 +01:00
Carl Friedrich Bolz-Tereick 9c197bc8bf
GH-96172 fix unicodedata.east_asian_width being wrong on unassigned code points (#96207) 2022-08-26 19:29:39 +03:00
Kristján Valur Jónsson 771eff21a0
Port regression test for issue GH-93592 (GH-96208) 2022-08-26 15:07:31 +01:00
Irit Katriel 1e743616ac
gh-96276: suppress SyntaxWarning in test_compile (GH-96277) 2022-08-25 22:23:06 +01:00
Michael Droettboom ce1e73fbfd
gh-96272: Replace test_source_encoding's test_pep263 with test_import_encoded_module from test_imp (GH-96275)
Editors don't agree that `test_source_encoding.py` was valid koi8-r, making it
hard to edit that file without the editor breaking it in some way (see gh-96272).

Only one test actually relied on the koi8-r encoding and it was a duplicate of a
test from the deprecated `imp` module's `test_imp`, so here we replace
`test_pep263` with `test_import_encoded_module` stolen from `test_imp` and
set `test_source_encoding.py`'s encoding to utf-8 to make editing it easier
going forward.
2022-08-25 14:19:16 -05:00
Harry ad7340e8c5
gh-92445 Improve interaction between nargs="*" and choices() (GH-92565) 2022-08-25 06:18:38 -05:00
Sam Ezeh cd492d43a2
gh-76728: Coerce DictReader and DictWriter fieldnames argument to a list (GH-32225) 2022-08-25 05:13:24 -05:00
Ross Burton df11012697
gh-95243: Mitigate the race condition in testSockName (#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>
2022-08-24 18:37:18 -07:00
Pablo Galindo Salgado e34c82abeb
GH-93503: Add thread-specific APIs to set profiling and tracing functions in the C-API (#93504)
* gh-93503: Add APIs to set profiling and tracing functions in all threads in the C-API

* Use a separate API

* Fix NEWS entry

* Add locks around the loop

* Document ignoring exceptions

* Use the new APIs in the sys module

* Update docs
2022-08-24 23:21:39 +01:00
Serhiy Storchaka 4de06e3cc0
gh-96021: Explicitly close the IsolatedAsyncioTestCase runner in tests (GH-96135)
Tests for IsolatedAsyncioTestCase.debug() rely on the runner be closed
in __del__. It makes tests depending on the GC an unreliable on other
implementations. It is better to close the runner explicitly even if
currently there is no a public API for this.
2022-08-24 15:07:20 +03:00
Irit Katriel 420f39f457
gh-93678: add _testinternalcapi.optimize_cfg() and test utils for compiler optimization unit tests (GH-96007) 2022-08-24 11:02:53 +01:00
Raymond Hettinger 1f0eafa844
GH-96145: Add AttrDict to JSON module for use with object_hook (#96146) 2022-08-23 16:22:00 -05:00
Michael Droettboom 054328f0dd
gh-96189: Fix test_invalid_utf8 on a number of build bots (GH-96190)
The clearing of the temporary directory is not working on some platforms and
leaving behind files.

This has been updated to use the pattern in test_cmd_line.py [1] using the
special TESTFN rather than a test directory.

[1] https://github.com/python/cpython/blob/main/Lib/test/test_cmd_line.py#L559
2022-08-23 13:52:55 -07:00
Kevin Kirsche 58f6953d6d
gh-96175: add missing self._localName assignment in xml.dom.minidom.Attr (#96176)
X-Ref: https://github.com/python/typeshed/pull/8590#discussion_r951473977

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-08-23 09:16:02 -07:00
Jeong YunWon ba7d4b9dc1
gh-96197: Add del sys.breakpointhook behavior test (gh-96198) 2022-08-23 17:58:38 +09:00
Kumar Aditya 079baee196
GH-96071: add regression test for #96071 (GH-96137)
Automerge-Triggered-By: GH:ericsnowcurrently
2022-08-22 11:40:23 -07:00
Terry Jan Reedy 216ccacda1
gh-96076: Change test_launcher to use non-admin location for py.ini (GH-96091)
Patch authored by Eryksun.
2022-08-22 17:23:27 +01:00
Christian Heimes 822955c166
gh-96125: Fix sys.thread_info.name on pthread platforms (GH-96126)
Automerge-Triggered-By: GH:tiran
2022-08-19 12:41:25 -07:00
Brandt Bucher 5bfb3c372b
GH-90997: Wrap yield from/await in a virtual try/except StopIteration (GH-96010) 2022-08-19 12:33:44 -07:00
Raymond Hettinger 29c8f80760
GH-95861: Add support for Spearman's rank correlation coefficient (GH-95863) 2022-08-18 13:48:27 -05:00
Dong-hee Na 157aef79b0
gh-95813: Improve HTMLParser from the view of inheritance (#95874)
* gh-95813: Improve HTMLParser from the view of inheritance

* gh-95813: Add unittest

* Address code review
2022-08-18 13:16:33 +02:00
Irit Katriel 1a720c6003
gh-95913: make the new internal classes pdb.ModuleTarget/ScriptTarget private (GH-96053) 2022-08-18 11:16:07 +01:00
Mark Shannon b73e3b6d4a
GH-95589: Dont crash when subclassing extension classes with multiple inheritance (GH-96028)
* Treat tp_weakref and tp_dictoffset like other opaque slots for multiple inheritance.

* Document Py_TPFLAGS_MANAGED_DICT and Py_TPFLAGS_MANAGED_WEAKREF in what's new.
2022-08-17 12:50:53 +01:00
Petr Viktorin 0f2b469ce1
gh-95991: Add some infrastructure for testing Limited API in _testcapi (GH-95992)
- Limited API needs to be enabled per source file
- Some builds don't support Limited API, so Limited API tests must be skipped on those builds
  (currently this is `Py_TRACE_REFS`, but that may change.)
- `Py_LIMITED_API` must be defined before `<Python.h>` is included.

This puts the hoop-jumping in `testcapi/parts.h`, so individual
test files can be relatively simple. (Currently that's only
`vectorcall_limited.c`, imagine more.)
2022-08-17 13:48:43 +02:00
Christian Heimes da0aa518bf
gh-96005: FreeBSD has ENOTCAPABLE, too (GH-96034) 2022-08-17 07:24:53 +02:00
Guido van Rossum f51f54f39d
GH-95704: Don't suppress errors from tasks when TG is cancelled (#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>
2022-08-16 18:23:06 -07:00
Michael Droettboom f215d7cac9
gh-94823: Improve coverage in tokenizer.c:valid_utf8 (GH-94856)
When loading a source file from disk, there is a separate UTF-8 validator
distinct from the one in `unicode_decode_utf8`. This exercises that code path
with the same set of invalid inputs as we use for testing the "other" UTF-8
decoder.
2022-08-16 08:54:13 -07:00
Kumar Aditya 9d515997f9
GH-95736: fix IsolatedAsyncioTestCase to initialize Runner before calling setup functions (#95898) 2022-08-16 08:52:06 -07:00
Mark Shannon 5a8c15819c
GH-95245: Move weakreflist into the pre-header. (GH-95996) 2022-08-16 13:57:18 +01:00
Michael Droettboom 3adb4d864b
GH-94808: Test __build_class__ inside non-dict __builtins__ (GH-95932) 2022-08-15 10:39:06 -07:00
Kumar Aditya 914f6367a0
GH-95899: fix asyncio.Runner to call set_event_loop only once (#95900) 2022-08-15 10:02:47 -07:00
Mark Shannon 3ef3c6306d
GH-95707: Fix uses of Py_TPFLAGS_MANAGED_DICT (GH-95854)
* Make sure that tp_dictoffset is correct with Py_TPFLAGS_MANAGED_DICT is set.

* Avoid traversing managed dict twice when subclassing class with Py_TPFLAGS_MANAGED_DICT set.
2022-08-15 12:29:27 +01:00