Commit Graph

54831 Commits

Author SHA1 Message Date
Mark Shannon d87e7f3529
GH-127682: Only call `__iter__` once in generator expressions. (GH-132351) 2025-04-11 09:37:22 +01:00
Jelle Zijlstra 07b8d3117f
gh-132261: Store annotations at hidden internal keys in the class dict (#132345) 2025-04-10 21:13:26 -07:00
Barney Gale 66cdb2bd8a
GH-123599: `url2pathname()`: handle authority section in file URL (#126844)
In `urllib.request.url2pathname()`, if the authority resolves to the
current host, discard it. If an authority is present but resolves somewhere
else, then on Windows we return a UNC path (as before), and on other
platforms we raise `URLError`.

Affects `pathlib.Path.from_uri()` in the same way.

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-04-10 19:58:04 +00:00
Stan Ulbrych a214db0c54
gh-132307: Remove unnecessary check in `asyncio/base_events.py` (#132324) 2025-04-10 15:41:32 +00:00
Tomas R. 4d58c8cb24
gh-130320: gettext: Test fallback translations (GH-130321) 2025-04-10 14:56:21 +03:00
sobolevn fcf2d07228
gh-132316: Require `socket` and `GITHUB_TOKEN` env to use `GitHubArtifactDatabase` (#132348)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-04-10 14:30:58 +03:00
Tomas R. b6760b7fa5
gh-130453: pygettext: Allow specifying multiple keywords with the same function name (GH-131380) 2025-04-10 11:06:40 +00:00
Neil Schemenauer d687900f98
gh-128384: Use a context variable for warnings.catch_warnings (gh-130010)
Make `warnings.catch_warnings()` use a context variable for holding
the warning filtering state if the `sys.flags.context_aware_warnings`
flag is set to true.  This makes using the context manager thread-safe in
multi-threaded programs.

Add the `sys.flags.thread_inherit_context` flag.  If true, starting a new
thread with `threading.Thread` will use a copy of the context
from the caller of `Thread.start()`.

Both these flags are set to true by default for the free-threaded build
and false for the default build.

Move the Python implementation of warnings.py into _py_warnings.py.

Make _contextvars a builtin module.

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-04-09 16:18:54 -07:00
Brandt Bucher 20926c73b5
GH-131798: Remove JIT guards for dict, frozenset, list, set, and tuple (GH-132289) 2025-04-09 14:32:21 -07:00
sobolevn 254110356d
gh-132285: Fix that `__annotate__` is not deleted when `__annotations__` is deleted (#132286) 2025-04-09 10:36:08 -07:00
Serhiy Storchaka 3feac7a093
gh-131434: Improve error reporting for incorrect format in strptime() (GH-131568)
In particularly, fix regression in detecting stray % at the end of the
format string.
2025-04-09 13:26:50 +03:00
Serhiy Storchaka 7ebbd27144
gh-130631: Make join_header_words() more similar to the original Perl version (GH-130632)
* Always quote strings with non-ASCII characters.
* Allow some non-separator and non-control characters (like "." or "-")
  be unquoted.
* Always quote strings that end with "\n".
* Use the fullmatch() method for clarity and optimization.
2025-04-09 11:08:04 +03:00
Serhiy Storchaka f5f1ac84b3
gh-112068: C API: Add support of nullable arguments in PyArg_Parse (GH-121303) 2025-04-08 22:08:00 +03:00
Tian Gao ab64130b57
gh-132250: Clear error in lsprof callback when method descriptor raises an excep… (#132251) 2025-04-08 13:36:47 -04:00
Nadeshiko Manju d753d8aed7
GH-131798: Narrow the result of _CONTAINS_OP_DICT to bool in the JIT (GH-132269)
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
2025-04-08 09:12:09 -07:00
Tomas R. 71009cb835
GH-131798: Narrow the result type of _BINARY_OP_SUBSCR_STR_INT to str in the JIT (GH-132153) 2025-04-08 08:22:54 -07:00
Duprat 933c6653cb
gh-132063: ensure that `ProcessPoolExecutor` does not swallow falsey exceptions (#132129) 2025-04-08 15:11:13 +00:00
Hugo van Kemenade c5e856a5dc Merge branch 'main' of https://github.com/python/cpython 2025-04-08 17:08:21 +03:00
Bénédikt Tran f5a7037c32
gh-93096: fix `test_mimetypes.test_invocation_error` tests on iOS ARM64 (#132266) 2025-04-08 15:03:43 +02:00
Serhiy Storchaka 0e4cf9ce7c
gh-50333: Deprecate support of non-tuple sequences in PyArg_ParseTuple() (GH-128374)
Non-tuple sequences are deprecated as argument for the "(items)" format unit
in PyArg_ParseTuple() and other argument parsing functions if items contains
format units which store borrowed buffer or reference (e.g. "s" and "O").

str and bytearray are no longer accepted as valid sequences.
2025-04-08 14:26:32 +03:00
Hugo van Kemenade 29af6cee02 Python 3.14.0a7 2025-04-08 14:20:51 +03:00
Serhiy Storchaka 0f04f2456a
gh-117779: Fix reading duplicated entries in zipfile by name (GH-129254) 2025-04-08 13:56:42 +03:00
Peter Bierma ac3c439cdf
gh-131998: Fix `NULL` dereference when using an unbound method descriptor in a specialized code path (#132000)
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Mark Shannon <mark@hotpy.org>
2025-04-08 10:31:43 +00:00
Bénédikt Tran 3eda146035
gh-74598: add `fnmatch.filterfalse` for excluding names matching a patern (#121185) 2025-04-08 10:11:25 +00:00
Adam Turner ee3657209b
gh-118761: Optimise import time for ``string`` (#132037)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-04-08 10:05:48 +00:00
Bénédikt Tran 53908bd790
gh-93096: fix `test_mimetypes.test_guess_type_conflicting_with_mimetypes` (#131408) 2025-04-08 09:08:59 +00:00
Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్ రెడ్డి) 403886c28d
gh-132021: Add bool type to the list of allowed JSON key types (#132048)
Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
2025-04-08 11:25:46 +03:00
sobolevn f7305a06c7
gh-115942: Add `locked` to several multiprocessing locks (#115944)
Co-authored-by: mpage <mpage@cs.stanford.edu>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-04-08 11:14:12 +03:00
Emma Smith 6cd1d6c6b1
gh-84481: Make ZipFile.data_offset more robust (#132178) 2025-04-08 10:43:14 +03:00
Inada Naoki e2b35ee229
enum: remove unused function (#132044) 2025-04-08 09:23:48 +09:00
sobolevn bc5233b6a5
gh-130775: Allow negative locations in `ast` (#130795)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-04-07 19:35:17 +03:00
sobolevn 3980718710
gh-132171: Fix `_interpreters.run_string` crash on string subclass (#132173) 2025-04-07 14:59:44 +03:00
btwood 895d983b5c
gh-61456: Add Thai language codec aliases (#15079)
Adding aliases for Thai language support. The current code page is an implementation of the windows code page.
This will alias '874', 'ms874', and 'windows_874' to cp874, adding Thai language support for those users.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-04-07 13:06:32 +02:00
Vincent Fazio 4c5dcc6d82
gh-129204: Add _PYTHON_SUBPROCESS_USE_POSIX_SPAWN environment knob (GH-132184)
* Add _PYTHON_SUBPROCESS_USE_POSIX_SPAWN environment knob

Add support for disabling the use of `posix_spawn` via a variable in
the process environment.

While it was previously possible to toggle this by modifying the value
of `subprocess._USE_POSIX_SPAWN`, this required either patching CPython
or modifying it within the interpreter instance which is not always
possible, such as when running applications or scripts not under a
user's control.

Signed-off-by: Vincent Fazio <vfazio@gmail.com>

* fixup NEWS entry

---------

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
2025-04-06 20:53:02 -07:00
Brian Schubert e2476398ee
gh-132168: Add `__class_getitem__` to `ctypes.py_object` (#132169) 2025-04-06 22:05:19 +01:00
Emma Smith 0788948dcb
gh-84481: Add ZipFile.data_offset attribute (#132165)
* Add ZipFile.data_offset attribute

This attribute provides the offset to zip data from the start of the file, when available.

* Add blurb-it

* Try fixing class ref in NEWS
2025-04-06 13:51:42 -07:00
Tomas R. a693eaa710
gh-132121: Always escape non-printable characters in pygettext (GH-132122) 2025-04-06 23:15:17 +03:00
Xuehai Pan 7bb1e1a236
gh-132159: Do not shadow user arguments in generated `__new__` by `@warnings.deprecated` (#132160) 2025-04-06 16:37:37 +00:00
sobolevn c0661df42a
gh-132011: Fix crash on invalid `CALL_LIST_APPEND` deoptimization (#132018)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-04-06 19:10:39 +03:00
Semyon Moroz f247e1d04c
gh-131178: Add tests for `pickle` command-line interface (#131275)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-04-06 11:50:32 -04:00
Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్ రెడ్డి) 0a10b45dd1
Docs: Replace dead hyperlink for CGI environment variables (#132137) 2025-04-06 10:12:48 +02:00
Tomas R. 85bc489b64
GH-131798: Narrow the result of _CONTAINS_OP_SET to bool in the JIT (GH-132057) 2025-04-05 15:56:01 -07:00
Stan Ulbrych ad6a032ceb
gh-131852: Filter out POT-Creation-Date in msgfmt (GH-131880)
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
2025-04-05 22:38:39 +03:00
Adam Turner 1755157207
GH-118761: Expose more core interpreter types in ``_types`` (#132103)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-04-05 18:11:07 +00:00
Serhiy Storchaka ef70f02925
Skip a test for Bluetooth HCI socket (added in GH-132023) if it fails (GH-132072) 2025-04-05 16:41:57 +03:00
Semyon Moroz 37bc3865c8
gh-85162: Add `HTTPSServer` to `http.server` to serve files over HTTPS (#129607)
The `http.server` module now supports serving over HTTPS using the `http.server.HTTPSServer` class.
This functionality is also exposed by the command-line interface (`python -m http.server`) through the
`--tls-cert`, `--tls-key` and `--tls-password-file` options.
2025-04-05 08:49:48 +00:00
Ageev Maxim 05557788f3
gh-131015: Add test for bytes formatting errors (#131881)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-04-05 10:30:16 +02:00
Jelle Zijlstra ac14d4a23f
gh-129463, gh-128593: Simplify ForwardRef (#129465) 2025-04-05 04:36:34 +00:00
Adam Turner 231a50fa9a
gh-109599: Expose `CapsuleType` via the `_types` module (#131969) 2025-04-04 23:37:41 +01:00
Victorien ac3a7bfecc
Fix typo in `template_replace()` test helper docstring (#132094) 2025-04-04 17:38:09 +00:00
Bénédikt Tran 0a97427ee5
gh-99108: Implement HACL* HMAC (#130157)
A new extension module, `_hmac`, now exposes the HACL* HMAC (formally verified) implementation.

The HACL* implementation is used as a fallback implementation when the OpenSSL implementation of HMAC
is not available or disabled. For now, only named hash algorithms are recognized and SIMD support provided
by HACL* for the BLAKE2 hash functions is not yet used.
2025-04-04 19:04:00 +02:00
Jelle Zijlstra 305be5fb1a
gh-118761: Lazily import annotationlib in typing (#132060)
annotationlib is used quite a few times in typing.py, but I think the
usages are just rare enough that this makes sense.

The import would get triggered by:
- Using get_type_hints(), evaluate_forward_ref(), and similar introspection
  functions
- Using a string annotation anywhere that goes through _type_convert (e.g.,
  "Final['x']" will trigger an annotationlib import in order to access the
  ForwardRef class).
- Creating a TypedDict or NamedTuple (unless it's empty or PEP 563 is on).

Lots of programs will want to use typing without any of these, so the tradeoff
seems worth it.
2025-04-04 08:57:10 -07:00
Bénédikt Tran 04bc681e7c
gh-131938: Update exception message for `Element.remove()` when an element is not found (#131972)
The exception message for `xml.etree.ElementTree.Element.remove` when an element is not found
has been updated from "list.remove(x): x not in list" to "Element.remove(x): element not found".
2025-04-04 15:04:07 +00:00
Jelle Zijlstra 255eb375a7
gh-118761: Defer import of functools in annotationlib (#132059) 2025-04-04 06:42:22 -07:00
Tomas R. a126cefc17
gh-130655: Add a test for corrupt `.mo` files in `gettext` (#131911) 2025-04-04 13:26:59 +00:00
Tomas R. 16a6270aa6
gh-130655: Add a test for bad magic numbers in `.mo` files parsed by `gettext` (#131909) 2025-04-04 13:26:15 +00:00
Tomasz Pytel 891c61c1fa
gh-128632: fix segfault on nested __classdict__ type param (#128744) 2025-04-04 06:23:35 -07:00
Jelle Zijlstra d1db43c139
gh-105499: Defer "import warnings" in typing (#132061)
A bunch of other warnings in typing.py were already deferred, but
I added a few non-lazy ones.
2025-04-04 06:19:42 -07:00
Victor Stinner 37d47d4965
gh-125434: Display thread name in faulthandler (#132016) 2025-04-04 12:24:41 +00:00
Serhiy Storchaka 2ccd6aae4d
Add tests for Bluetooth RFCOMM, HCI and SCO (GH-132023) 2025-04-04 14:33:09 +03:00
Filipe Laíns 🇵🇸 6ab4acecf9
GH-131770: increase assumed WASI stack size to 131072 (wasi-sdk default) (#131844)
e9524a0980/libc-top-half/musl/src/internal/pthread_impl.h (L220)

Signed-off-by: Filipe Laíns <lains@riseup.net>
2025-04-04 09:34:02 +01:00
Itamar Oren b6c92ec419
gh-132038: Make perf version check in test_perf_profiler more robust (#132039)
Should work also if the version string includes a commit hash, like `perf version 6.12.9.g242e6068fd5c`
2025-04-03 18:37:08 +01:00
Jelle Zijlstra 5518c2ae09
gh-128661: Remove DeprecationWarning in evaluate_forward_ref (#128930)
It doesn't make sense to use a deprecation for evaluate_forward_ref,
as it is a new function in Python 3.14 and doesn't have compatibility
guarantees.

I considered making it throw an error if type_params it not passed and
there is no owner. However, I think this is too unfriendly for users. The
case where this param is really needed is fairly esoteric and I don't think
this case is worth the pain of forcing users to write "type_params=()".
2025-04-03 09:52:17 -07:00
Pablo Galindo Salgado 943cc1431e
gh-131591: Implement PEP 768 (#131937)
Co-authored-by: Ivona Stojanovic <stojanovic.i@hotmail.com>
Co-authored-by: Matt Wozniski <godlygeek@gmail.com>
2025-04-03 16:20:01 +01:00
Adam Turner b3e3cc054c
Remove deferred ``typing`` import in ``annotationlib`` (#132034) 2025-04-02 20:30:31 -07:00
Tian Gao 6bd9689426
gh-60115: Support frozen modules for linecache.getline() (#131638) 2025-04-02 19:50:01 -04:00
Jelle Zijlstra 06822bfbf6
gh-118761: Fix star-import of ast (#132025)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-04-02 18:15:05 +00:00
Victor Stinner 643dd5107c
gh-111178: Skip test_perf_profiler on function sanitizer (#132020)
Add 'function' parameter to check_sanitizer() of test.support.
2025-04-02 18:46:10 +02:00
Adam Turner f20f02e6b5
gh-118761: Optimise import time for ast (#131953) 2025-04-02 17:22:15 +01:00
Mark Shannon ad053d8d6a
GH-131498: Cases generator: Parse down to C statement level. (GH-131948)
* Parse down to statement level in the cases generator

* Add handling for #if macros, treating them much like normal ifs.
2025-04-02 16:31:59 +01:00
Jakub Kulík e8085319eb
gh-59705: Fix solaris detection in test_threading.test_set_name() (#132012) 2025-04-02 16:34:43 +02:00
Thomas Grainger b0f77c4d25
gh-131888: fix ResourceWarning in test_ftplib (#131889) 2025-04-02 14:30:19 +02:00
sobolevn ab2a3dda1d
gh-132002: Fix crash of `ContextVar` on unhashable `str` subtype (#132003) 2025-04-02 14:48:47 +03:00
Tomas R. 87d9983994
gh-130197: pygettext: Test the --escape option (GH-131902) 2025-04-02 11:46:54 +03:00
Filipe Laíns 🇵🇸 e7980ba233
GH-128055: fix test_sysconfigdata_json outside the builddir (#128070) 2025-04-02 05:44:43 +00:00
Brandt Bucher 1a9d4a1fb3
GH-131798: Allow the JIT to remove more int/float/str guards (GH-131800) 2025-04-01 15:10:15 -07:00
Pablo Galindo Salgado c2ac662f28
gh-131831: Implement PEP 758 – Allow except and except* expressions without parentheses (#131833) 2025-04-01 19:04:56 +00:00
mpage 053c285f6b
gh-130704: Strength reduce `LOAD_FAST{_LOAD_FAST}` (#130708)
Optimize `LOAD_FAST` opcodes into faster versions that load borrowed references onto the operand stack when we can prove that the lifetime of the local outlives the lifetime of the temporary that is loaded onto the stack.
2025-04-01 10:18:42 -07:00
Will Childs-Klein 3b3720f1a2
gh-131736: only apply `security_level` workaround in `test_ssl` for security levels greater than 1 (#131739) 2025-04-01 09:58:47 +02:00
Adam Turner 51e0f2b06c
gh-107369: Optimise ``textwrap.indent()`` (#131923)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-03-31 18:31:39 +01:00
Peter Bierma 511d3440a0
gh-131936: Strengthen check in `_suggestions._generate_suggestions` (#131945) 2025-03-31 19:30:29 +02:00
Jelle Zijlstra 0f511d8b44
gh-105499: typing: Remove an unused function (#131946)
Leftover from #105511 I believe. GitHub code search found no usages other
than copies of typing.py and lists of stdlib functions.
2025-03-31 10:27:03 -07:00
Lukas Geiger 0147be09d5
gh-131525: Remove `_HashedSeq` wrapper from `lru_cache` (gh-131922) 2025-03-31 08:23:41 -05:00
Mark Shannon c535a132e4
GH-131498: Another refactoring of the code generator (GH-131827)
* Rename 'defined' attribute to 'in_local' to more accurately reflect how it is used

* Make death of variables explicit even for array variables.

* Convert in_memory from boolean to stack offset

* Don't apply liveness analyis to optimizer generated code

* Add 'out' parameter to stack.pop
2025-03-31 13:52:48 +01:00
Bénédikt Tran ba11f45dd9
gh-130843: expose 48-bit timestamp for UUIDv7 (#131838) 2025-03-31 14:32:54 +02:00
Bénédikt Tran bab1398a47
gh-126033: fix UAF in `xml.etree.ElementTree.Element.remove` when concurrent mutations happen (#126124) 2025-03-31 12:31:26 +02:00
Bénédikt Tran c57623c221
gh-126037: fix UAF in `xml.etree.ElementTree.Element.find*` when concurrent mutations happen (#127964)
We fix a use-after-free in the `find`, `findtext` and `findall` methods of `xml.etree.ElementTree.Element`
objects that can be triggered when the tag to find implements an `__eq__` method that mutates the
element being queried.
2025-03-31 12:26:52 +02:00
Adam Turner 6aa88a2cb3
gh-130167: Optimise ``textwrap.dedent()`` (#131919)
Co-authored-by: Marius Juston <marius.juston@hotmail.fr>
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-03-31 00:35:12 +00:00
Amit Lavon 685fd74f81
GH-131798: Remove type checks for _TO_BOOL_STR (GH-131816) 2025-03-30 16:07:25 -07:00
Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్ రెడ్డి) c432d0147b
gh-127794: Validate email header names according to RFC 5322 (#127820)
`email.message.Message` objects now validate header names specified via `__setitem__`
or `add_header` according to RFC 5322, §2.2 [1].

In particular, callers should expect a ValueError to be raised for invalid header names.

[1]: https://datatracker.ietf.org/doc/html/rfc5322#section-2.2

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: R. David Murray <rdmurray@bitdance.com>
2025-03-30 12:29:29 +00:00
Semyon Moroz 55150a79ca
gh-131178: Update help message for `timeit` CLI (#131326) 2025-03-30 14:19:38 +03:00
Kumar Aditya eaffc34d3c
gh-127945: mark `TestLocalization` as thread unsafe in ctypes (#131899) 2025-03-30 11:08:42 +00:00
Jelle Zijlstra 425f60b9eb
gh-130924: Do not create cells for usages of names in local annotations (#131843) 2025-03-29 21:15:48 +00:00
Serhiy Storchaka c6b1a07343
gh-131853: Fix test_msgfmt on big-endian platforms (GH-131879)
Use a generated .mo file instead of a checked in one.
2025-03-29 19:14:37 +02:00
Stan Ulbrych fccf9ab33d
gh-131853: Test binary header in msgfmt generated file (GH-131854) 2025-03-29 14:27:50 +02:00
Will Childs-Klein be2d2181e6
gh-131050: skip `test_dh_params` when TLS library lacks FFDHE ciphersuites (#131051)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-03-29 10:31:48 +00:00
Totosuki a5949986d6
gh-127541: Update os.walk example (GH-127765)
Update os.walk example to be more modern, skip `__pycache__` dirs rather than `CVS` dirs.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-03-28 23:25:13 -07:00
Steve Dower d260631be0
gh-131423: Update to OpenSSL 3.0.16. (GH-131839)
The bin tag is 3.0.16.1 because we rebuilt without uplink support to fix gh-131804.
This PR also prevents making calls that are now unsafe without uplink, and updates
the tests to property interpret these failures as unsupported.
2025-03-28 15:07:57 +00:00
Thomas Grainger adb67ed7e4
gh-131807: fix ResourceWarning in test_ucn.py (#131808)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-03-28 15:55:40 +01:00
alexey semenyuk 27d1443897
Use `assert*` comparison methods in `test_timer_comparison` (#129513) 2025-03-28 14:25:13 +00:00
Bartosz Sławecki a6cf8275f8
gh-117174: Adapt `test_multiple_statements_fail_early` to new REPL behavior (follow-up gh-131065) (#131836)
Adapt test to new REPL behavior (follow-up gh-117174)
2025-03-28 15:09:31 +01:00
Kumar Aditya 9752661491
gh-128002: run all asyncio tests with tsan CI (#131797) 2025-03-28 19:30:36 +05:30
Irit Katriel 2c8f329dc6
gh-131738: optimize builtin any/all/tuple calls with a generator expression arg (#131737) 2025-03-28 10:35:20 +00:00
Yan Yanchii 674dbf3b3a
gh-126835: Refine constant folding tests in `test_peepholer.py::TestTranforms` (#131826) 2025-03-28 10:10:22 +00:00
Victorien af2afd7c22
gh-119180: Use equality when comparing against `annotationlib.Format` (#131755) 2025-03-27 21:56:09 -07:00
Thomas Grainger 8a00c9a4d2
gh-128770: raise warnings as errors in test suite - except for test_socket which still logs warnings, and internal test warnings that are now logged (#128973)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-03-27 21:06:52 +02:00
Wulian233 a096a41b92
gh-128438: Use `EnvironmentVarGuard` for `datetimetester.py` to manage environment varibales (#130002) 2025-03-27 18:07:09 +02:00
Semyon Moroz 9b83670f0f
gh-131178: Add tests for `tokenize` command-line interface (#131274) 2025-03-27 18:04:16 +02:00
Michael Droettboom 8614f86b71
gh-131525: Cache the result of tuple_hash (#131529)
* gh-131525: Cache the result of tuple_hash

* Fix debug builds

* Add blurb

* Fix formatting

* Pre-compute empty tuple singleton

* Mostly set the cache within tuple_alloc

* Fixes for TSAN

* Pre-compute empty tuple singleton

* Fix for 32-bit platforms

* Assert that op != NULL in _PyTuple_RESET_HASH_CACHE

* Use FT_ATOMIC_STORE_SSIZE_RELAXED macro

* Update Include/internal/pycore_tuple.h

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

* Fix alignment

* atomic load

* Update Objects/tupleobject.c

Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
2025-03-27 09:57:06 -04:00
Semyon Moroz cf5e438c02
gh-118761: Always lazy import `re` in `locale` (#129860) 2025-03-27 15:47:08 +02:00
Victor Stinner 9ef9d687ff
gh-131712: Build _suggestions extension on Windows (#131759)
Add a test checking that the '_suggestions' extension is available.
2025-03-27 09:53:39 +01:00
Simon Legner 52b5eb95b7
gh-131236: allow to generate multiple UUIDs at once via CLI (#131218)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-03-26 22:49:28 +02:00
Sam Gross 67fbfb42bd
gh-131586: Avoid refcount contention in some "special" calls (#131588)
In the free threaded build, the `_PyObject_LookupSpecial()` call can lead to
reference count contention on the returned function object becuase it
doesn't use stackrefs. Refactor some of the callers to use
`_PyObject_MaybeCallSpecialNoArgs`, which uses stackrefs internally.

This fixes the scaling bottleneck in the "lookup_special" microbenchmark
in `ftscalingbench.py`. However, the are still some uses of
`_PyObject_LookupSpecial()` that need to be addressed in future PRs.
2025-03-26 14:38:47 -04:00
Sam Gross 3d4ac1a2c2
gh-123358: Use `_PyStackRef` in `LOAD_DEREF` (gh-130064)
Concurrent accesses from multiple threads to the same `cell` object did not
scale well in the free-threaded build. Use `_PyStackRef` and optimistically
avoid locking to improve scaling.

With the locks around cell reads gone, some of the free threading tests were
prone to starvation: the readers were able to run in a tight loop and the
writer threads weren't scheduled frequently enough to make timely progress.
Adjust the tests to avoid this.

Co-authored-by: Donghee Na <donghee.na@python.org>
2025-03-26 12:08:20 -04:00
Mark Shannon 1b8bb1ed0c
GH-131729: Code-gen better liveness analysis (GH-131732)
* Rename 'defined' attribute to 'in_local' to more accurately reflect how it is used

* Make death of variables explicit even for array variables.

* Convert in_memory from boolean to stack offset

* Don't apply liveness analysis to optimizer generated code

* Fix RETURN_VALUE in optimizer
2025-03-26 15:21:35 +00:00
Thomas Grainger 2d83891dfd
gh-131649: fix test_string_literals SyntaxWarning (#131650) 2025-03-26 15:01:18 +01:00
Jelle Zijlstra 898e6b395e
gh-130881: Handle conditionally defined annotations (#130935) 2025-03-26 03:48:19 +00:00
Peter Bierma 90b82f2b61
gh-129900: Fix `SystemExit` return codes when the REPL is started from the command line (#129901) 2025-03-25 19:48:46 +00:00
Thomas Grainger 8ada7a9e14
gh-131647: fix 'sys.path_hooks is empty' warning in test_importlib (#131648) 2025-03-25 18:16:15 +01:00
Thomas Grainger 6fb5f7f4d9
gh-131707: fix unawaited coroutine warning in test_coroutines.Corouti… (#131708)
gh-131707: fix unawaited coroutine warning in test_coroutines.CoroutineTest.test_17
2025-03-25 08:29:51 +00:00
Bénédikt Tran 1393bd3548
gh-131666: mark `anext_awaitable.close` as a `METH_NOARGS` instead of `METH_VARARGS` (#131671) 2025-03-25 09:03:22 +05:30
Sam Gross a123245986
gh-131677: Fix flaky test_lru_cache_threaded3 (gh-131679)
The call to `with self.subTest(...)` was not thread-safe.
2025-03-24 16:41:50 -04:00
Ageev Maxim 7c3692fe27
gh-130928: Fix error message during bytes formatting for the `'i'` flag (#130967) 2025-03-24 22:07:03 +03:00
sobolevn 929afd1d6e
gh-131670: Fix crash in `anext()` when `__anext__` is sync and raises (#131682)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-03-24 19:00:48 +00:00
Barney Gale d372472896
GH-128520: pathlib ABCs: tighten up argument types (#131621)
In `JoinablePath.full_match()` and `ReadablePath.glob()`, accept a `str`
pattern argument rather than `JoinablePath | str`.

In `ReadablePath.copy()` and `copy_into()`, accept a `WritablePath` target
argument rather than `WritablePath | str`.
2025-03-24 15:39:08 +00:00
Barney Gale d716ea34cb
GH-128520: pathlib ABCs: validate `magic_open()` arguments (#131617)
When `pathlib._os.magic_open()` is called to open a path in binary mode,
raise `ValueError` if any of the *encoding*, *errors* or *newline*
arguments are given. This matches the `open()` built-in.
2025-03-24 15:13:18 +00:00
Barney Gale fbfb0e1f6e
GH-128520: pathlib ABCs: reject empty pattern in `ReadablePath.glob()` (#127343)
For compatibility with `Path.glob()`, raise `ValueError` if an empty
pattern is given to `ReadablePath.glob()`.
2025-03-24 15:12:29 +00:00
Victor Stinner b3319fe42f
gh-111178: Skip tests which require deep stack if UBsan (#131669)
If Python is built with Undefined Behavior sanitizer, skip
test_repr_deep() of test_userdict and test_lru_recursion() of
test_functools.
2025-03-24 15:33:56 +01:00
Petr Viktorin 0e53038ea8
gh-128715: Expose ctypes.CField, with info attributes (GH-128950)
- Restore max field size to sys.maxsize, as in Python 3.13 & below
- PyCField: Split out bit/byte sizes/offsets.
- Expose CField's size/offset data to Python code
- Add generic checks for all the test structs/unions, using the newly exposed attrs
2025-03-24 14:18:34 +01:00
Thomas Grainger 71ce4acb25
gh-131645: fix ResourceWarnings in `test_asyncio.test_events` (#131646) 2025-03-24 12:38:33 +00:00
Irit Katriel 64906bb223
gh-130080: do not fold match case constants in unoptimized AST (#131577) 2025-03-23 13:50:14 +00:00
Nybblista f3bf304c27
gh-131357: Add a set of asserts to test.test_capi.test_bytearray (#131554)
add a set of asserts to test.test_capi.test_bytearray

1. Assert empty bytearray object for PyByteArray_Check.
2. Assert empty bytearray object for PyByteArray_CheckExact.
3. Assert 0-size bytearray object for PyByteArray_Size.
4. Assert empty bytearray object for PyByteArray_AsString.
5. Assert concatenation of the bytearray object with itself for PyByteArray_Concat.
2025-03-23 10:20:40 +03:00
Sam Gross 18249d9383
gh-131566: Skip `test_tracemalloc_track_race` under TSAN (gh-131567)
The test has data race when setting the global "raw" memory allocator.
2025-03-22 11:46:36 -04:00
Barney Gale cf9d1a4b6b
GH-128520: pathlib ABCs: allow tests to be run externally (#131315)
Adjust the tests for the `pathlib.types` module so that they can be run
against the `pathlib-abc` PyPI package, which is a backport of the module
for older Python versions.

Specifically, we add a `.support.is_pypi` switch that is false in the
stdlib and true in the pathlib-abc package. This controls which package
we import, and whether or not we run tests against `PurePath` and `Path`.

For compatibility with older Python versions, we stop using
`zipfile.ZipFile.mkdir()` and `zipfile.ZipInfo._for_archive()`.
2025-03-21 22:18:20 +00:00
Sam Gross 56d0f9af14
gh-117657: Skip some tests when running with TSAN (gh-131555)
The subinterpreter tests have data races (see gh-129824).

TSAN attempts to intercept some of the fatal signals, which can lead to
bogus reports. We could possibly handle these via TSAN_OPTIONS, but it's
simpler to just skip those tests -- they're not multithreaded anyways.
2025-03-21 15:16:08 -04:00
Savannah Ostrowski b92ee14b80
GH-130415: Optimize constant comparison in JIT builds (GH-131489) 2025-03-21 11:23:12 -07:00
Irit Katriel 3e2cceaa87
gh-131233: remove return-in-finally in multiprocessing/connection.py (#131416) 2025-03-21 18:05:47 +00:00
Łukasz Langa 4cc82ffa37
gh-131507: Refactor screen and cursor position calculations (GH-131547)
This is based off #131509.
2025-03-21 18:27:35 +01:00
Łukasz Langa 5d8e981c84
gh-131507: Clean up tests and type checking for `_pyrepl` (#131509) 2025-03-21 15:48:10 +01:00
Mark Shannon d3f6063af1
GH-131513: Cases generator: Allow dead inputs to be reassigned (GH-131515) 2025-03-21 11:38:17 +00:00
Stan Ulbrych e0fda794fa
gh-70647: Raise a more informative error for when date is out of range (GH-131335)
More informative error messages mean less debugging what went wrong.
2025-03-20 20:47:09 -07:00
Tian Gao e3564689a5
gh-120144: Disable the CALL event when possible to achieve zero overhead pdb (#131390) 2025-03-20 20:31:55 -04:00
Sam Gross 844765b20f
gh-131269: Minor optimization in random.py (#131270) 2025-03-20 17:10:33 -05:00
dgpb c83efa7a66
gh-131435: random.randint optimization (gh-131436) 2025-03-20 17:07:28 -05:00
Thomas Grainger ce79274e9f
gh-131492, gh-131461: handle exceptions in GzipFile constructor while owning resources (#131462)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-03-20 17:06:21 +00:00
luccabb f53e7de6a8
gh-88887: Cleanup `multiprocessing.resource_tracker.ResourceTracker` upon deletion (#130429)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-03-20 17:44:37 +01:00
AN Long 00a9844888
gh-131453: Add additional constants to winsound module (GH-131454) 2025-03-20 16:35:52 +00:00
Irit Katriel 749e24b48f
gh-130080: fix warnings in tests (#131471) 2025-03-20 16:11:04 +00:00
Mark Shannon 7ebd71ee14
GH-131498: Remove conditional stack effects (GH-131499)
* Adds some missing #includes
2025-03-20 15:39:38 +00:00
Adam Turner 443c0cd17c
gh-127833: Use `productionlist` nodes to implement the `grammar-snippet` directive (#130376)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Blaise Pabon <blaise@gmail.com>
2025-03-20 15:35:20 +00:00
Mark Shannon 83d54fa876
GH-130296: Remove `_PyOpcode_max_stack_effect` as it is no longer used (GH-131493) 2025-03-20 11:42:54 +00:00
Nybblista 2433cc79d7
gh-131441: Add a set of asserts to test.test_capi.test_list (#131442) 2025-03-20 10:12:15 +00:00
Barney Gale f141e8ec2a
GH-123599: Deprecate duplicate `pathname2url()` implementation (#127380)
Call `urllib.request.pathname2url()` from `pathlib.Path.as_uri()`, and
deprecate the duplicate implementation in `PurePath`.

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-03-20 00:54:36 +00:00
Tomasz Pytel a8cb5e4a43
gh-129598: ast: allow multi stmts for ast single with ';' (#129620) 2025-03-19 15:29:40 -07:00
Barney Gale 63b5aed06e
GH-123599: Remove duplicate `url2pathname()` implementation (#127237)
Call `urllib.request.url2pathname()` from `pathlib.Path.from_uri()` rather
than re-implementing it. This paves the way for solving the main issue
(ignoring local authorities and rejecting non-local ones) in urllib, not
pathlib.
2025-03-19 21:08:32 +00:00
Yan Yanchii 75103d975c
gh-126835: Move constant tuple folding from ast_opt to CFG (#130769) 2025-03-19 20:59:55 +00:00
Barney Gale 8abfaba5a6
GH-125866: Deprecate `nturl2path` module (#131432)
Deprecate the `nturl2path` module. Its functionality is merged into
`urllib.request`.

Add `tests.test_nturl2path` to exercise `nturl2path`, as it's no longer
covered by `test_urllib`.
2025-03-19 19:33:01 +00:00
Steve Dower 63a638c43f
gh-91349: Replace zlib with zlib-ng in Windows build (GH-131438) 2025-03-19 19:03:25 +00:00
Adam Turner c1a02f9101
GH-121970: Extract `pydoc_topics` into a new extension (#131256) 2025-03-19 18:35:11 +00:00
R. David Murray 6146295a5b
gh-90548: Make musl test skips smarter (fixes Alpine errors) (#131313)
* Make musl test skips smarter (fixes Alpine errors)

A relatively small number of tests fail when the underlying c library is
provided by musl.  This was originally reported in bpo-46390 by
Christian Heimes.  Among other changes, these tests were marked for
skipping in gh-31947/ef1327e3 as part of bpo-40280 (emscripten support),
but the skips were conditioned on the *platform* being emscripten (or
wasi, skips for which ere added in 9b50585e02).

In gh-131071 Victor Stinner added a linked_to_musl function to enable
skipping a test in test_math that fails under musl, like it does on a
number of other platforms.  This check can successfully detect that
python is running under musl on Alpine, which was the original problem
report in bpo-46390.

This PR replaces Victor's solution with an enhancement to
platform.libc_ver that does the check more cheaply, and also gets the
version number.  The latter is important because the math test being
skipped is due to a bug in musl that has been fixed, but as of this
checkin date has not yet been released.  When it is, the test skip can
be fixed to check for the minimum needed version.

The enhanced version of linked_to_musl is also used to do the skips of
the other tests that generically fail under musl, as opposed to
emscripten or wasi only failures.  This will allow these tests to be
skipped automatically on Alpine.

This PR does *not* enhance libc_ver to support emscripten and wasi, as
I'm not familiar with those platforms; instead it returns a version
triple of (0, 0, 0) for those platforms.  This means the musl tests will
be skipped regardless of musl version, so ideally someone will add
support to libc_ver for these platforms.

* Platform tests and bug fixes.

In adding tests for the new platform code I found a bug in the old code:
if a valid version is passed for version and it is greater than the
version found for an so *and* there is no glibc version, then the
version from the argument was returned.  The code changes here fix
that.

* Add support docs, including for some preexisting is_xxx's.

* Add news item about libc_ver enhancement.

* Prettify platform re expression using re.VERBOSE.
2025-03-19 13:05:09 -04:00
Furkan Onder 8ad4646c67
gh-131263: Skip test_timerfd_negative on NetBSD to prevent system freeze (#131431) 2025-03-19 11:24:09 +00:00
Stan Ulbrych 3118693a1a
gh-130655: Add tests for `gettext.find()` (GH-130691)
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
2025-03-19 11:52:03 +01:00
Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్ రెడ్డి) 7558980a18
GH-131358: Add encoding alias cseuckr for euc_kr (#131370)
* Add encoding alias cseuckr for euc_kr

* Update Misc/NEWS.d/next/Library/2025-03-17-21-35-53.gh-issue-131358.YVZ6yo.rst

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-03-19 18:29:20 +09:00
Russell Keith-Magee b754aeedfb
gh-121468: Ensure PDB cleans up event loop policies after using asyncio. (#131388)
Adds teardown logic, plus a change to asyncio.run usage, to avoid warnings when
running the test suite single process.
2025-03-19 08:33:31 +08:00
Barney Gale d783d7b51d
GH-126367: `url2pathname()`: handle NTFS alternate data streams (#131428)
Adjust `url2pathname()` to decode embedded colon characters in Windows
URIs, rather than bailing out with an `OSError`.
2025-03-18 23:37:12 +00:00
Malcolm Smith 01b5abbc53
gh-124666: Improve thread cleanup in test_android (#131427)
Ensures that failures in test setup don't result in dangling threads.
2025-03-19 06:30:22 +08:00
Daniel Pope c1b42db9e4
gh-130914: Make graphlib.TopologicalSorter.prepare() idempotent (#131317)
Closes #130914: Make graphlib.TopologicalSorter.prepare() idempotent

Relax the rules so that `.prepare()` can be called multiple times, provided that no work has been passed out by `.get_ready()` yet.
2025-03-18 16:28:00 -05:00
Bénédikt Tran 8cb57dc367
gh-131402: add HMAC-SHA3 NIST test cases (#131407)
Add NIST [1] tests for `HMAC-SHA-3/{224,256,384,512}`.

[1]: https://csrc.nist.gov/Projects/cryptographic-standards-and-guidelines/example-values
2025-03-18 13:57:15 +01:00
Irit Katriel 83479c2175
gh-130080: fix warnings in tests (#131400) 2025-03-18 12:33:46 +00:00
Mike Edmunds 295b53df2a
gh-121284: Fix email address header folding with parsed encoded-word (GH-122754)
Email generators using email.policy.default may convert an RFC 2047
encoded-word to unencoded form during header refolding. In a structured
header, this could allow 'specials' chars outside a quoted-string,
leading to invalid address headers and enabling spoofing. This change
ensures a parsed encoded-word that contains specials is kept as an
encoded-word while the header is refolded.

[Better fix from @bitdancer.]

---------

Co-authored-by: R David Murray <rdmurray@bitdance.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-03-18 12:07:17 +01:00
Kumar Aditya ab6333f7f5
gh-128002: fix tsan race in closing socket in `test_sslproto` (#131399) 2025-03-18 16:20:47 +05:30
Max Bachmann 3453b5c1d6
gh-114917: add support for AI_NUMERICSERV in getaddrinfo emulation (#114918) 2025-03-18 11:26:51 +01:00
Kumar Aditya b0a4f6599a
gh-128002: fix tsan race in closing socket in `test_ssl` (#131397) 2025-03-18 15:41:43 +05:30
Tian Gao a936af924e
gh-120144: Make it possible to use `sys.monitoring` for bdb and make it default for pdb (#124533) 2025-03-17 18:34:37 -04:00
Irit Katriel ffc2f1dd1c
gh-130080: implement PEP 765 (#130087) 2025-03-17 20:48:54 +00:00
Kumar Aditya 94f4d87aeb
gh-131325: fix sendfile fallback implementation to drain data after writing to transport (#131376) 2025-03-18 00:52:57 +05:30
R. David Murray a09c2b2ba6
Fix test_pyrepl.TestDumbTerminal if PYTHON_BASIC_REPL set. (#131332)
Most of the tests that care already adjust PYTHON_BASIC_REPL as needed,
but this one doesn't, and it fails if the developer has the variable set.
2025-03-17 18:56:21 +01:00
Mark Shannon 9881fc5483
GH-125174: Make immortality "sticky" (GH-131355)
* Use a higher threshold for immortality for INCREF than DECREF
2025-03-17 17:22:35 +00:00
Tomasz Pytel 863d54cbaf
gh-126895: Fix readline module in free-threaded build (#131208)
The underlying readline library is not thread-safe so this adds `@critical_section` to functions that use it.
2025-03-17 11:57:11 -04:00
Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్ రెడ్డి) 80e00ecc39
gh-129843: fix pure Python implementation of `warnings.warn_explicit` (#129848)
The pure Python implementation of `warnings.warn_explicit` constructs a `WarningMessage`
with an incorrect source (it incorrectly sets the WarningMessage's line to the given `source`).
2025-03-17 10:49:53 +00:00
Bénédikt Tran de8890f5ab
gh-130149: cleanup refactorization of `test_hmac.py` (#131318)
New features:

* refactor `hashlib_helper.requires_hashdigest` in prevision of a future
  `hashlib_helper.requires_builtin_hashdigest` for built-in hashes only
* add `hashlib_helper.requires_openssl_hashdigest` to request OpenSSL
   hashes, assuming that `_hashlib` exists.

Refactoring:

* split hmac.copy() test by implementation
* update how algorithms are discovered for RFC test cases
* simplify how OpenSSL hash digests are requested
* refactor hexdigest tests for RFC test vectors
* typo fix: `assert_hmac_hexdigest_by_new` -> `assert_hmac_hexdigest_by_name`

Improvements:

* strengthen contract on `hmac_new_by_name` and `hmac_digest_by_name`
* rename mixin classes to better match their responsibility
2025-03-17 11:10:03 +01:00
Semyon Moroz 85c04f80fd
gh-93096: Update and document `pickletools` CLI (#131273) 2025-03-17 09:36:30 +00:00
Nybblista 3ae67ba97e
gh-131339: test PyBytes_Size for a zero-size bytes object (#131340) 2025-03-17 11:38:37 +03:00
Hood Chatham cf288e3c25
gh-127146: Update test skips for Emscripten 4.0.2 (#129474)
Updates test skips to reflect capabilities of Emscripten 4.0.2.
2025-03-17 06:02:27 +08:00
Tomas R. d07e9ebbe8
gh-131306: Remove unused code related to `BINARY_SUBSCR` (#131307) 2025-03-16 16:37:29 +00:00
Bénédikt Tran 9b6cef0f5d
gh-131254: ensure that `BROWSER` is not set for `test_webbrowser` on macOS (#131276) 2025-03-16 15:39:30 +01:00
Bénédikt Tran 3185e3115c
gh-131277: allow `EnvironmentVarGuard` to unset more than one environment variable at once (#131280)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-03-16 14:09:33 +01:00
Barney Gale 563ab5cefe
GH-130614: pathlib ABCs: improve support for receiving path metadata (#131259)
In the private pathlib ABCs, replace `_WritablePath._write_info()` with
`_WritablePath._copy_from()`. This provides the target path object with
more control over the copying process, including support for querying and
setting metadata *before* the path is created.

Adjust `_ReadablePath.copy()` so that it forwards its keyword arguments to
`_WritablePath._copy_from()` of the target path object. This allows us to
remove the unimplemented *preserve_metadata* argument in the ABC method,
making it a `Path` exclusive.
2025-03-16 06:11:20 +00:00
Yan Yanchii 55815a6474
gh-130480: Move duplicate `LOAD_SMALL_INT` optimization from codegen to CFG (#130481) 2025-03-14 21:23:27 +00:00
Tian Gao 26511993e6
gh-121468: Fix the doctest failure for asyncio test on pdb (#131258) 2025-03-14 16:23:21 -04:00
Barney Gale 633942e348
GH-130614: pathlib ABCs: delete vestigial `test_pathlib_abc` module (#131215)
Remove the `test.test_pathlib.test_pathlib_abc` test module, which was
hollowed out in previous commits. Its few remaining tests are most relevant
to `PurePath` and `Path`, so we move them into `test_pathlib`.
2025-03-14 20:04:07 +00:00
Tian Gao 27fc62cf4f
gh-121468: Add current asyncio task as a convenience variable in pdb (#124367) 2025-03-14 14:46:26 -04:00
Hugo van Kemenade 77b2c933ca Python 3.14.0a6 2025-03-14 17:05:02 +02:00
Hugo van Kemenade ca1bedc9a4
gh-121970: Revert "GH-121970: Extract ``pydoc_topics`` into a new extension (#129116)" (#131245)
Lint / lint (push) Failing after 5m2s Details
mypy / Run mypy on ${{ matrix.target }} (Lib/_pyrepl) (push) Failing after 31s Details
mypy / Run mypy on ${{ matrix.target }} (Lib/test/libregrtest) (push) Failing after 32s Details
mypy / Run mypy on ${{ matrix.target }} (Tools/cases_generator) (push) Successful in 11s Details
mypy / Run mypy on ${{ matrix.target }} (Tools/build) (push) Successful in 4m39s Details
Tests / Change detection (push) Failing after 26m43s Details
Tests / Docs (push) Has been skipped Details
Tests / Check if Autoconf files are up to date (push) Has been skipped Details
Tests / Check if generated files are up to date (push) Has been skipped Details
Tests / Windows ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (Win32, false, windows-latest) (push) Has been skipped Details
Tests / Windows ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (arm64, false, windows-latest) (push) Has been skipped Details
Tests / Windows ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (arm64, true, windows-latest) (push) Has been skipped Details
Tests / Windows ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (x64, false, windows-latest) (push) Has been skipped Details
Tests / Windows ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (x64, true, windows-latest) (push) Has been skipped Details
Tests / Windows MSI${{ '' }} (arm64) (push) Has been skipped Details
Tests / Windows MSI${{ '' }} (x64) (push) Has been skipped Details
Tests / Windows MSI${{ '' }} (x86) (push) Has been skipped Details
Tests / macOS ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (false, ${{ github.repository_owner != 'python' }}, ghcr.io/cirruslabs/macos-runner:sonoma) (push) Has been skipped Details
Tests / macOS ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (false, ${{ github.repository_owner != 'python' }}, macos-13) (push) Has been skipped Details
Tests / macOS ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (false, ${{ github.repository_owner != 'python' }}, macos-14) (push) Has been skipped Details
Tests / macOS ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (true, ${{ github.repository_owner != 'python' }}, ghcr.io/cirruslabs/macos-runner:sonoma) (push) Has been skipped Details
Tests / macOS ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (true, ${{ github.repository_owner != 'python' }}, macos-14) (push) Has been skipped Details
Tests / Ubuntu ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} ${{ fromJSON(matrix.bolt) && '(bolt)' || '' }} (false, false, ubuntu-24.04) (push) Has been skipped Details
Tests / Ubuntu ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} ${{ fromJSON(matrix.bolt) && '(bolt)' || '' }} (false, false, ubuntu-24.04-arm) (push) Has been skipped Details
Tests / Ubuntu ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} ${{ fromJSON(matrix.bolt) && '(bolt)' || '' }} (false, true, ubuntu-24.04) (push) Has been skipped Details
Tests / Ubuntu ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} ${{ fromJSON(matrix.bolt) && '(bolt)' || '' }} (false, true, ubuntu-24.04-arm) (push) Has been skipped Details
Tests / Ubuntu ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} ${{ fromJSON(matrix.bolt) && '(bolt)' || '' }} (true, false, ubuntu-24.04) (push) Has been skipped Details
Tests / Ubuntu SSL tests with OpenSSL (3.0.15, ubuntu-24.04) (push) Has been skipped Details
Tests / Ubuntu SSL tests with OpenSSL (3.1.7, ubuntu-24.04) (push) Has been skipped Details
Tests / Ubuntu SSL tests with OpenSSL (3.2.3, ubuntu-24.04) (push) Has been skipped Details
Tests / Ubuntu SSL tests with OpenSSL (3.3.2, ubuntu-24.04) (push) Has been skipped Details
Tests / Ubuntu SSL tests with OpenSSL (3.4.0, ubuntu-24.04) (push) Has been skipped Details
Tests / WASI (push) Has been skipped Details
Tests / Hypothesis tests on Ubuntu (push) Has been skipped Details
Tests / Address sanitizer (ubuntu-24.04) (push) Has been skipped Details
Tests / Thread sanitizer ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (false) (push) Has been skipped Details
Tests / Thread sanitizer ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} (true) (push) Has been skipped Details
Tests / Cross build Linux (push) Has been skipped Details
Tests / CIFuzz (address) (push) Has been skipped Details
Tests / CIFuzz (memory) (push) Has been skipped Details
Tests / CIFuzz (undefined) (push) Has been skipped Details
Tests / All required checks pass (push) Has been skipped Details
mypy / Run mypy on ${{ matrix.target }} (Tools/clinic) (push) Failing after 31s Details
mypy / Run mypy on ${{ matrix.target }} (Tools/peg_generator) (push) Failing after 32s Details
mypy / Run mypy on ${{ matrix.target }} (Tools/jit) (push) Failing after 5m3s Details
mypy / Run mypy on ${{ matrix.target }} (Tools/wasm) (push) Failing after 31s Details
Mark stale pull requests / stale (push) Has been skipped Details
Revert "GH-121970: Extract ``pydoc_topics`` into a new extension (#129116)"

This reverts commit 01bcf13a1c.
2025-03-14 16:25:56 +02:00
donBarbos f9d0531a8d
gh-93096: Update and document `pickle` CLI (#131097)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-03-14 14:15:35 +01:00
sobolevn fc07f863ee
gh-131234: Improve `test_popen` with more asserts (#131235) 2025-03-14 11:38:31 +00:00
Mark Shannon 2250ab6a13
GH-125174 Revert: Make immortality "sticky" (GH-131184)" (#131230)
Revert "GH-125174: Make immortality "sticky" (GH-131184)"

This reverts commit 3a91ee9724.
2025-03-14 13:13:47 +02:00
Wulian233 7fd61607cd
gh-131204: Fix `difflib.HtmlDiff` may not use monospaced font (#131221)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-03-14 10:45:33 +00:00
sobolevn f6c24a5c89
gh-131219: Improve tests in `test_lzma.py` by adding more asserts (#131220) 2025-03-14 10:16:50 +00:00
Min RK 96492785b2
gh-128540: lookup default webbrowser on macOS (#130535)
Ensure web browser is launched by `webbrowser.open` on macOS, even for `file://` URLs.
2025-03-14 02:51:15 -04:00
Grigory Bukovsky 1121c80fda
gh-131196: Improve perfomance of `UUID.hex` and `UUID.__str__` by ~10% (#131197)
Results before and after the fix:

```
hex
before: 0.021755493999989994
after:  0.01465080400066654 

str
before: 0.06381790500017814
after:  0.05134949700004654
```

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-03-14 01:57:38 +03:00
Barney Gale 45c2ef48ca
GH-130614: pathlib ABCs: parametrize test suite for path copying (#131168)
Test copying from `Path` and `ReadableZipPath` (types of `_ReadablePath`)
to `Path` and `WritableZipPath` (types of `_WritablePath`).
2025-03-13 21:56:59 +00:00
sobolevn 1a8e5742cd
Remove `print` from `test_monitoring.py` (#131200) 2025-03-13 22:54:17 +03:00
Pieter Eendebak ec46a55d63
gh-121464: Make concurrent iteration over enumerate safe under free-threading (#125734) 2025-03-14 00:14:05 +05:30
Tomas R. 7ea6e88eb4
gh-85012: Properly reset msgctxt when compiling messages with msgfmt (GH-130525)
Add also human-readable snapshots for tests.
2025-03-13 20:40:40 +02:00
Tomasz Pytel c5abded099
gh-130382: add missing `_PyReftracerTrack` to ceval `Py_DECREF` (#130689) 2025-03-13 12:31:49 -04:00
Mark Shannon 3a91ee9724
GH-125174: Make immortality "sticky" (GH-131184) 2025-03-13 16:10:13 +00:00
Victor Stinner 10cbd1fe88
gh-130947: Add again PySequence_Fast() to the limited C API (#130948)
Add again PySequence_Fast() to the limited C API.

Add unit tests.
2025-03-13 13:00:57 +01:00
donBarbos 3a189af4b2
gh-93096: Remove CLI interface for `difflib` (#131099) 2025-03-13 13:22:16 +02:00
Oleg Iarygin 328f8b8856
gh-93096: Make `mimetypes` CLI tool public (#93097)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-03-13 13:19:22 +02:00
Chris Eibl 119bcfad9c
gh-129149: Add fast path for medium-sized integers in `PyLong_FromSsize_t()` (#129301)
The implementation of `PyLong_FromLong()`, `PyLong_FromLongLong()` and `PyLong_FromSsize_t()`
are now handled by a common macro `PYLONG_FROM_INT` which contains fast paths depending on the
size of the integer to convert. Consequently, `PyLong_FromSsize_t()` for medium-sized integers is faster
by roughly 25%.

---------

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2025-03-13 12:06:56 +01:00
Enzo Bonnal a005835f69
gh-74028: add `buffersize` parameter to `concurrent.futures.Executor.map` for lazier behavior (#125663)
`concurrent.futures.Executor.map` now supports limiting the number of submitted
tasks whose results have not yet been yielded via the new `buffersize` parameter.

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-03-13 11:57:53 +01:00
Cody Maloney 93089c0736
gh-130806: Emit ResourceWarning if GzipFile unclosed (#130905)
This may indicate accidental data loss.

Ways to make sure all data is written:
1. Use the [file-like object](https://docs.python.org/3/glossary.html#term-file-object) as a [“With Statement Context Manager”](https://docs.python.org/3/reference/datamodel.html#context-managers).
   - All objects which [inherit](https://docs.python.org/3/tutorial/classes.html#inheritance) from [IOBase](https://docs.python.org/3/library/io.html#io.IOBase) support this.
   - [`BufferedIOBase`](https://docs.python.org/3/library/io.html#io.BufferedIOBase), [`BufferedWriter`](https://docs.python.org/3/library/io.html#io.BufferedWriter), and [`GzipFile`](https://docs.python.org/3/library/gzip.html#gzip.GzipFile) all support this.
   - Ensures `.close()` is called in both exception and regular cases.

2. Ensure [`.close()`](https://docs.python.org/3/library/io.html#io.IOBase.close) is always called which flushes data before closing.

3. If the underlying stream need to be kept open, use [`.detach()`](https://docs.python.org/3/library/io.html#io.BufferedIOBase.detach)

Since 3.12 flushing has been necessary in GzipFile (see gh-105808 which was a release blocker), this makes that more visible. Users have been encountering as they upgrade to 3.12 (ex. gh-129726).

There are a number of cases of unclosed file-like objects being deleted in CPython libraries and the test suite. This issue includes resolving those cases where the new ResourceWarning is emitted.

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-03-13 11:20:05 +01:00
Victor Stinner b2ca26875a
gh-131152: Remove unused imports from tests (part 2) (#131154) 2025-03-13 10:57:40 +01:00
Victor Stinner 73ab9e2ede
gh-131152: Remove unused imports from tests (#131153) 2025-03-13 10:55:23 +01:00
Victor Stinner 68922ace4d
gh-131032: Add support.linked_to_musl() function (#131071)
Skip test_math.test_fma_zero_result() if Python is linked to the musl
C library.
2025-03-13 10:33:46 +01:00
Victor Stinner 2ed671b5e3
gh-111178: Change Argument Clinic signature for `@staticmethod` (#131157) (#131159)
Use "PyObject*", instead of "void*", for `@staticmethod` functions to
fix an undefined behavior.
2025-03-13 10:22:58 +01:00
Hood Chatham db1e5827c4
gh-127503: Improve tracebacks on Emscripten when there is a trap (#131158)
Modifies the behavior of the interpreter on crash under Emscripten:
1. No Python traceback shown on segfault/trap
2. The JavaScript source line is shown

The JavaScript source line is super long and completely unenlightening,
whereas the Python traceback is very helpful.
2025-03-13 08:28:15 +08:00
Tian Gao b52866953a
gh-131123: Support completion in `pdb` for convenience variable attributes (#131124) 2025-03-12 17:23:53 -04:00
Ethan Furman 17d06aeb54
gh-131045: [Enum] fix flag containment checks when using values (GH-131053)
Check would fail if value would create a pseudo-member, but that member
had not yet been created.  We now attempt to create a pseudo-member for
a passed-in value first.

Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
2025-03-12 12:10:47 -07:00
Barney Gale db6a998b18
GH-130614: pathlib ABCs: revise test suite for writable paths (#131112)
Test `pathlib.types._WritablePath` in a dedicated test module. These tests
cover `WritableZipPath`, `WritableLocalPath` and `Path`, where the former
two classes are implementations of `_WritablePath` for use in tests.
2025-03-12 19:06:43 +00:00
Raymond Hettinger 25f24b01e3
Improve docstring for random.binomialvariate (gh-131164)
Add probability distribution to the docstring
2025-03-12 13:25:31 -05:00
Sam Gross 776ec1e167
gh-110097: Fix flaky `test_timeout` in `test_concurrent_futures.test_process_pool` (gh-131108)
On heavily loaded systems, the launch of the workers to run
`time.sleep(0)` can take longer than the five second timeout.
2025-03-12 13:16:23 -04:00
Victor Stinner 061da44bac
gh-111178: Change Argument Clinic signature for `@classmethod` (#131157)
Use "PyObject*", instead of "PyTypeObject*", for `@classmethod`
functions to fix an undefined behavior.
2025-03-12 17:42:07 +01:00
T. Wouters de2f7da77d
gh-115999: Add free-threaded specialization for FOR_ITER (#128798)
Add free-threaded versions of existing specialization for FOR_ITER (list, tuples, fast range iterators and generators), without significantly affecting their thread-safety. (Iterating over shared lists/tuples/ranges should be fine like before. Reusing iterators between threads is not fine, like before. Sharing generators between threads is a recipe for significant crashes, like before.)
2025-03-12 16:21:46 +01:00
Victor Stinner db27aee2fe
gh-131152: Remove unused imports in `_pyrepl` and `ctypes` (#131150) 2025-03-12 14:04:12 +00:00
Victor Stinner 14aed5e8ab
gh-131152, pkgutil: Remove unused imports (#131149) 2025-03-12 15:03:36 +01:00
Pieter Eendebak 1fb7e2aeb7
gh-120608: Make reversed iterator work with free-threading (#120971)
Co-authored-by: Sam Gross <colesbury@gmail.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-03-12 12:39:52 +01:00
Daniel Pope e0637cebe5
gh-129349: Accept bytes in bytes.fromhex()/bytearray.fromhex() (#129844)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-03-12 11:40:11 +01:00
Pieter Eendebak 405a2d74cb
gh-123471: make `itertools.batched` thread-safe (#129416) 2025-03-12 15:30:33 +05:30
Stan Ulbrych 155c44b901
gh-81267: Correct time.sleep() error message (#131055) 2025-03-12 08:12:57 +00:00
donBarbos 15a8412b5e
gh-93096: Load doctests in `test_itertools` (#131133) 2025-03-12 08:40:59 +01:00
Sergey B Kirpichev 52756c30db
Use subTest() in math.fma() tests (#131125) 2025-03-12 07:22:28 +01:00
Pablo Galindo Salgado ebc24d54bc
gh-117174: Fix reference leak and gdb tests (#131095) 2025-03-11 23:17:58 +00:00
Barney Gale ad90c5fabc
GH-130614: pathlib ABCs: revise test suite for readable paths (#131018)
Test `pathlib.types._ReadablePath` in a dedicated test module. These tests
cover `ReadableZipPath`, `ReadableLocalPath` and `Path`, where the former
two classes are implementations of `_ReadablePath` for use in tests.
2025-03-11 20:54:22 +00:00
Kumar Aditya 24070492cf
gh-128002: add `test_asyncio.test_free_threading` to tsan tests (#131106) 2025-03-12 01:33:44 +05:30
Kumar Aditya fcf756adef
fix various warnings in `test_asyncio.test_tasks` (#131109) 2025-03-11 19:51:53 +00:00
Tian Gao 8b1edae93a
gh-122029: Do not unpack method for legacy tracing anymore (#130898) 2025-03-11 14:04:22 -04:00
Barney Gale 3569e4a670
GH-130614: pathlib ABCs: revise test suite for Windows path joining (#131016)
Test Windows-flavoured `pathlib.types._JoinablePath` in a dedicated test
module. These tests cover `LexicalWindowsPath`, `PureWindowsPath` and
`WindowsPath`, where `LexicalWindowsPath` is a simple implementation of
`_JoinablePath` for use in tests.
2025-03-11 18:01:43 +00:00
Victor Stinner 9d759b63d8
gh-111178: Change Argument Clinic signature for METH_O (#130682)
Use "PyObject*" for METH_O functions to fix an undefined behavior.
2025-03-11 16:33:36 +01:00
Sam Gross 1908115871
gh-130957: Use `sleeping_retry` in `test_free_reference` (#130958)
The weak reference may not be immediately dead.
2025-03-11 09:51:26 -04:00
donBarbos 425e0af74f
gh-93096: Remove `-t` and `-v` flags from `pickle` cli (#131068)
* Remove `python -m pickle -t`

* Revert adding doctest to unittests
2025-03-11 12:07:00 +01:00
donBarbos 3ddf983afd
gh-93096: Remove `-t` and `-v` flags from `pickletools` cli (#131039)
Remove `python -m pickletools -t`
2025-03-11 12:06:26 +01:00
donBarbos 3bb20d13a8
gh-93096: Load doctests in `test_pickle` (#131069)
Add doctests to unittest for `pickle`
2025-03-11 12:25:25 +02:00
Michał Górny 33494b4d0d
gh-130959: Reject whitespace in fractions, in pure Python `fromisoformat()` (#130962)
* gh-130959: Reject whitespace in fractions, in pure Python `fromisoformat()`

Fix the pure Python implementation of `fromisoformat()` to reject any
non-digit characters, including whitespace, in the fractional part
of time specification.  This makes the behavior consistent with the C
implementation, and prevents incorrect parsing of these fractions
(e.g. `.400 ` would be misinterpreted as `.04`).

* Add the news entry

* Use a different example to fix Sphinx lint

* Apply suggestions from code review

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>

* Try fixing `:func:` ref.

---------

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
2025-03-11 10:15:40 +01:00
Jakub Kulík 69309a55bc
gh-130932: cwd cannot be removed on Solaris/Illumos (#131037) 2025-03-11 10:09:04 +01:00
Pablo Galindo Salgado 4192ce17ba
gh-117174: Adapt test_multiple_statements_fail_early now that we have always source (#131065) 2025-03-10 23:10:53 +00:00
Sergey Miryanov 7c98b0674d
gh-130804: Fix support of typing unicode chars in pyrepl (#130805) 2025-03-10 22:13:50 +00:00
FeH2 6ab5c4aa05
gh-124927: Fix conversion issue between coordinates and position in REPL (#125001) 2025-03-10 21:54:49 +00:00
Pablo Galindo Salgado a931a8b324
gh-117174: Add a new route in linecache to fetch interactive source code (#117500) 2025-03-10 21:54:05 +00:00