summaryrefslogtreecommitdiffstats
path: root/Misc
Commit message (Collapse)AuthorAgeFilesLines
* gh-95778: Correctly pre-check for int-to-str conversion (#96537)Mark Dickinson2022-09-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* no-issue: Fix typo in 3.11.0a7.rst (gh-96547)Ikko Ashimine2022-09-041-1/+1
| | | accross -> across
* gh-68163: Correct conversion of Rational instances to float (GH-25619)Sergey B Kirpichev2022-09-041-0/+1
| | | | | | | * gh-68163: Correct conversion of Rational instances to float Also document that numerator/denominator properties are instances of Integral. Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* gh-93884: Improve test coverage of `PyNumber_ToBase` (GH-93932)Charlie Zhao2022-09-041-0/+1
| | | | | | | Link to #93884 * Test with some large negative and positive values(out of range of a longlong,i.e.[-2\*\*63, 2\*\*63-1]) * Test with objects of non-int type Automerge-Triggered-By: GH:mdickinson
* gh-95778: CVE-2020-10735: Prevent DoS by very large int() (#96499)Gregory P. Smith2022-09-021-0/+14
| | | | | | | | | | | | | | | | 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.
* Allow whitespace around a slash in fraction string inputs (GH-96496)Raymond Hettinger2022-09-021-0/+2
|
* gh-93554: Conditional jump opcodes only jump forward (GH-96318)Irit Katriel2022-09-011-0/+16
|
* GH-96079 Fix missing field name for _AnnotatedAlias (#96080)Anh71me2022-08-311-0/+1
|
* gh-89258: Add a getChildren() method to logging.Logger. (GH-96444)Vinay Sajip2022-08-311-0/+2
| | | Co-authored-by: Éric <merwok@netwok.org>
* gh-95865: Speed up urllib.parse.quote_from_bytes() (GH-95872)Dennis Sweeney2022-08-311-0/+1
|
* gh-95149: Enhance `http.HTTPStatus` with properties that indicate the HTTP ↵Alexandru Mărășteanu2022-08-301-0/+2
| | | | status category (GH-95453)
* gh-95987: Fix `repr` of `Any` type subclasses (#96412)Nikita Sobolev2022-08-301-0/+1
|
* gh-96143: Allow Linux perf profiler to see Python calls (GH-96123)Pablo Galindo Salgado2022-08-301-0/+7
| | | | | | | :warning: :warning: Note for reviewers, hackers and fellow systems/low-level/compiler engineers :warning: :warning: 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.
* gh-96349: fix minor performance regression initializing threading.Event ↵Daniel Giger2022-08-301-0/+1
| | | | (gh-96350)
* gh-96385: Correctly raise error on `[*T, *V]` substitution (GH-96386)Nikita Sobolev2022-08-301-0/+3
|
* gh-95853: Improve WASM build script (GH-96389)Christian Heimes2022-08-301-0/+2
| | | | | | | - pre-build Emscripten ports and system libraries - check for broken EMSDK versions - use EMSDK's node for wasm32-emscripten - warn when PKG_CONFIG_PATH is set - add support level information
* gh-96320: WASI socket fixes (#96388)Christian Heimes2022-08-301-0/+2
| | | | | | | | * gh-96320: WASI socket fixes - ignore missing functions in ``socket.__repr__`` - bundle network files with assets * blurb
* GH-74116: Allow multiple drain waiters for asyncio.StreamWriter (GH-94705)Kumar Aditya2022-08-291-0/+1
|
* gh-94682: Build and test with OpenSSL 1.1.1q (gh-94683)Christian Heimes2022-08-291-0/+1
|
* gh-90814: Correct NEWS wording re. optional C11 features (GH-96309)Petr Viktorin2022-08-291-1/+2
| | | | | | | | | | | The previous wording of this entry suggests that CPython won't work if optional compiler features are enabled. That's not the case. The change is that we require C11 rather than C89. Note that PEP 7 does say "Python 3.11 and newer versions use C11 without optional features." It is correct there: that's not a guide for users who compile Python, but for CPython devs who must avoid the features.
* gh-69142: add %:z strftime format code (gh-95983)TW2022-08-281-0/+1
| | | | | | | | | | | | | | | | 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>
* gh-90467: StreamReaderProtocol - add strong reference to created task (#96323)Kirill2022-08-272-0/+4
|
* gh-95973: Add a new --with-dsymutil option to link debug information in ↵Pablo Galindo Salgado2022-08-271-0/+2
| | | | | macOS (GH-95974) Automerge-Triggered-By: GH:pablogsal
* GH-96172 fix unicodedata.east_asian_width being wrong on unassigned code ↵Carl Friedrich Bolz-Tereick2022-08-261-0/+3
| | | | points (#96207)
* gh-96269: Fix build dependency on AIX (GH-96304)Christian Heimes2022-08-261-0/+3
|
* gh-92445 Improve interaction between nargs="*" and choices() (GH-92565)Harry2022-08-251-0/+3
|
* gh-76728: Coerce DictReader and DictWriter fieldnames argument to a list ↵Sam Ezeh2022-08-251-0/+1
| | | | (GH-32225)
* GH-96237: Allow non-functions as reference-holder in frames. (GH-96238)Mark Shannon2022-08-251-0/+5
|
* gh-95243: Mitigate the race condition in testSockName (#96173)Ross Burton2022-08-251-0/+3
| | | | | | | | 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>
* GH-93503: Add thread-specific APIs to set profiling and tracing functions in ↵Pablo Galindo Salgado2022-08-241-0/+7
| | | | | | | | | | | | | | | | | 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
* GH-96179: Fix misleading example on the bisect documentation (GH-96228)prego2022-08-241-0/+1
| | | | The `movies[bisect(movies, 1960, key=by_year)]` will actually return only movies **after** 1960.
* gh-93678: add _testinternalcapi.optimize_cfg() and test utils for compiler ↵Irit Katriel2022-08-241-0/+1
| | | | optimization unit tests (GH-96007)
* GH-96145: Add AttrDict to JSON module for use with object_hook (#96146)Raymond Hettinger2022-08-231-0/+1
|
* gh-96175: add missing self._localName assignment in `xml.dom.minidom.Attr` ↵Kevin Kirsche2022-08-231-0/+1
| | | | | | | (#96176) X-Ref: https://github.com/python/typeshed/pull/8590#discussion_r951473977 Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* GH-96187: Prevent _PyCode_GetExtra to return garbage for negative indexes ↵Pablo Galindo Salgado2022-08-231-0/+2
| | | | (GH-96188)
* gh-96159: Fix significant performance degradation in logging.TimedRotat… ↵Duncan Grisby2022-08-231-0/+1
| | | | (GH-96182)
* gh-96046: Initialize ht_cached_keys in PyType_Ready() (GH-96047)Christian Heimes2022-08-221-0/+4
|
* gh-96098: Clearly link concurrent.futures from threading & multiprocessing ↵Nick Coghlan2022-08-211-0/+3
| | | | | | | docs (GH-96112) Clearly link concurrent.futures from threading & multiprocessing docs Also link directly to asyncio from the beginning of the threading docs.
* GH-96071: fix deadlock in PyGILState_Ensure (GH-96124)Kumar Aditya2022-08-191-0/+1
| | | Alternative of #96107
* gh-96125: Fix sys.thread_info.name on pthread platforms (GH-96126)Christian Heimes2022-08-191-0/+2
| | | Automerge-Triggered-By: GH:tiran
* GH-90997: Wrap yield from/await in a virtual try/except StopIteration (GH-96010)Brandt Bucher2022-08-191-0/+3
|
* gh-96019: Fix caching of decompositions in makeunicodedata (GH-96020)Carl Friedrich Bolz-Tereick2022-08-191-0/+3
|
* gh-95463: Remove backwards incompatible change regarding the ↵Pablo Galindo Salgado2022-08-181-0/+2
| | | | | _MASK_UTF_FILENAME flags in bpo-28080 (GH-96072) Automerge-Triggered-By: GH:pablogsal
* gh-90536: Add support for the BOLT post-link binary optimizer (gh-95908)Kevin Modzelewski2022-08-182-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add support for the BOLT post-link binary optimizer Using [bolt](https://github.com/llvm/llvm-project/tree/main/bolt) provides a fairly large speedup without any code or functionality changes. It provides roughly a 1% speedup on pyperformance, and a 4% improvement on the Pyston web macrobenchmarks. It is gated behind an `--enable-bolt` configure arg because not all toolchains and environments are supported. It has been tested on a Linux x86_64 toolchain, using llvm-bolt built from the LLVM 14.0.6 sources (their binary distribution of this version did not include bolt). Compared to [a previous attempt](https://github.com/faster-cpython/ideas/issues/224), this commit uses bolt's preferred "instrumentation" approach, as well as adds some non-PIE flags which enable much better optimizations from bolt. The effects of this change are a bit more dependent on CPU microarchitecture than other changes, since it optimizes i-cache behavior which seems to be a bit more variable between architectures. The 1%/4% numbers were collected on an Intel Skylake CPU, and on an AMD Zen 3 CPU I got a slightly larger speedup (2%/4%), and on a c6i.xlarge EC2 instance I got a slightly lower speedup (1%/3%). The low speedup on pyperformance is not entirely unexpected, because BOLT improves i-cache behavior, and the benchmarks in the pyperformance suite are small and tend to fit in i-cache. This change uses the existing pgo profiling task (`python -m test --pgo`), though I was able to measure about a 1% macrobenchmark improvement by using the macrobenchmarks as the training task. I personally think that both the PGO and BOLT tasks should be updated to use macrobenchmarks, but for the sake of splitting up the work this PR uses the existing pgo task. * Simplify the build flags * Add a NEWS entry * Update Makefile.pre.in Co-authored-by: Dong-hee Na <donghee.na92@gmail.com> * Update configure.ac Co-authored-by: Dong-hee Na <donghee.na92@gmail.com> * Add myself to ACKS * Add docs * Other review comments * fix tab/space issue * Make it more clear that --enable-bolt is experimental * Add link to bolt's github page Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
* GH-95861: Add support for Spearman's rank correlation coefficient (GH-95863)Raymond Hettinger2022-08-181-0/+2
|
* Correct news entry. (GH-96043)Mark Shannon2022-08-171-1/+1
|
* GH-95589: Dont crash when subclassing extension classes with multiple ↵Mark Shannon2022-08-171-0/+4
| | | | | | | 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.
* GH-93911: Specialize `LOAD_ATTR` for custom `__getattribute__` (GH-93988)Ken Jin2022-08-171-0/+1
|
* GH-95704: Don't suppress errors from tasks when TG is cancelled (#95761)Guido van Rossum2022-08-171-0/+2
| | | | | | | | | | | | | 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>
* gh-96005: Handle WASI ENOTCAPABLE in getpath (GH-96006)Christian Heimes2022-08-161-0/+4
| | | | | | - 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`.