]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
11 months agogh-127316: fix incorrect assertion in setting `__class__` in free-threading (#127399)
Kumar Aditya [Fri, 29 Nov 2024 16:14:20 +0000 (21:44 +0530)] 
gh-127316: fix incorrect assertion in setting `__class__` in free-threading (#127399)

11 months agogh-127208: Reject null character in _imp.create_dynamic() (#127400)
Victor Stinner [Fri, 29 Nov 2024 15:20:38 +0000 (16:20 +0100)] 
gh-127208: Reject null character in _imp.create_dynamic() (#127400)

_imp.create_dynamic() now rejects embedded null characters in the
path and in the module name.

11 months agofix param type in PyObject_HasAttrWithError (docs) (#127403)
biggus-developerus [Fri, 29 Nov 2024 10:53:34 +0000 (14:53 +0400)] 
fix param type in PyObject_HasAttrWithError (docs) (#127403)

11 months agogh-126024: optimize UTF-8 decoder for short non-ASCII string (#126025)
Inada Naoki [Fri, 29 Nov 2024 10:48:02 +0000 (19:48 +0900)] 
gh-126024: optimize UTF-8 decoder for short non-ASCII string (#126025)

11 months agogh-127258: Fix asyncio test_staggered_race_with_eager_tasks() (#127358)
Victor Stinner [Fri, 29 Nov 2024 10:39:54 +0000 (11:39 +0100)] 
gh-127258: Fix asyncio test_staggered_race_with_eager_tasks() (#127358)

Replace the sleep(2) with a task which is blocked forever.

11 months agogh-127341: Argument Clinic: fix compiler warnings for getters with docstrings (#127310)
Peter Bierma [Fri, 29 Nov 2024 10:12:13 +0000 (05:12 -0500)] 
gh-127341: Argument Clinic: fix compiler warnings for getters with docstrings (#127310)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
11 months agogh-126881: fix finalization of dtoa state (#126904)
Kumar Aditya [Fri, 29 Nov 2024 09:47:16 +0000 (15:17 +0530)] 
gh-126881: fix finalization of dtoa state (#126904)

11 months agogh-127303: Add docs for token.EXACT_TOKEN_TYPES (#127304)
Илья Любавский [Fri, 29 Nov 2024 09:00:50 +0000 (12:00 +0300)] 
gh-127303: Add docs for token.EXACT_TOKEN_TYPES (#127304)

---------

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
11 months agogh-127359: Pin Tcl/Tk to 8 (8.6) for testing macOS (#127365)
Hugo van Kemenade [Thu, 28 Nov 2024 17:03:09 +0000 (19:03 +0200)] 
gh-127359: Pin Tcl/Tk to 8 (8.6) for testing macOS (#127365)

11 months agogh-127190: Fix local_setattro() error handling (#127366)
Victor Stinner [Thu, 28 Nov 2024 16:35:48 +0000 (17:35 +0100)] 
gh-127190: Fix local_setattro() error handling (#127366)

Don't make the assumption that the 'name' argument is a string. Use
repr() to format the 'name' argument instead.

11 months agoTouch up docs for ctypes.FormatError & WinError (GH-127210)
Jun Komoda [Thu, 28 Nov 2024 15:59:47 +0000 (00:59 +0900)] 
Touch up docs for ctypes.FormatError & WinError (GH-127210)

Reformat paragraphs, add backquotes, and directives.

11 months agogh-127330: Update for OpenSSL 3.4 & document+improve the update process (GH-127331)
Petr Viktorin [Thu, 28 Nov 2024 12:29:27 +0000 (13:29 +0100)] 
gh-127330: Update for OpenSSL 3.4 & document+improve the update process (GH-127331)

- Add `git describe` output to headers generated by `make_ssl_data.py`

  This info is more important than the date when the file was generated.
  It does mean that the tool now requires a Git checkout of OpenSSL,
  not for example a release tarball.

- Regenerate the older file to add the info.
  To the other older file, add a note about manual edits.

- Add notes on how to add a new OpenSSL version

- Add 3.4 error messages and multissl tests

11 months agoGH-127178: install a _sysconfig_vars_(...).json file in the stdlib directory (#127302)
Filipe Laíns 🇵🇸 [Wed, 27 Nov 2024 23:32:54 +0000 (23:32 +0000)] 
GH-127178: install a _sysconfig_vars_(...).json file in the stdlib directory (#127302)

11 months agoGH-127154: Remove PGO and unknown-linux-gnu/clang from JIT CI (#127212)
Savannah Ostrowski [Wed, 27 Nov 2024 22:36:36 +0000 (14:36 -0800)] 
GH-127154: Remove PGO and unknown-linux-gnu/clang from JIT CI (#127212)

11 months agogh-122288: Improve performances of `fnmatch.translate` (#122289)
Bénédikt Tran [Wed, 27 Nov 2024 16:42:45 +0000 (17:42 +0100)] 
gh-122288: Improve performances of `fnmatch.translate` (#122289)

Improve performance of this function by a factor of 1.7x.

Co-authored-by: Barney Gale <barney.gale@gmail.com>
11 months agogh-126882: Fix indentation in code sample block (#126887)
Topher Fischer [Wed, 27 Nov 2024 15:24:45 +0000 (07:24 -0800)] 
gh-126882: Fix indentation in code sample block (#126887)

11 months agogh-123967: Fix faulthandler for trampoline frames (#127329)
Victor Stinner [Wed, 27 Nov 2024 15:14:49 +0000 (16:14 +0100)] 
gh-123967: Fix faulthandler for trampoline frames (#127329)

If the top-most frame is a trampoline frame, skip it.

11 months agoFix indentation for contextlib.asynccontextmanager docs (#127333)
Jelle Zijlstra [Wed, 27 Nov 2024 14:38:55 +0000 (06:38 -0800)] 
Fix indentation for contextlib.asynccontextmanager docs (#127333)

11 months agogh-124008: Fix calculation of the number of written bytes for the Windows console...
Serhiy Storchaka [Wed, 27 Nov 2024 11:38:12 +0000 (13:38 +0200)] 
gh-124008: Fix calculation of the number of written bytes for the Windows console (GH-124059)

Since MultiByteToWideChar()/WideCharToMultiByte() is not reversible if
the data contains invalid UTF-8 sequences, use binary search to
calculate the number of written bytes from the number of written
characters.

Also fix writing incomplete UTF-8 sequences.

Also fix handling of memory allocation failures.

11 months agogh-109746: Fix race condition in test_start_new_thread_failed (GH-127299)
Serhiy Storchaka [Wed, 27 Nov 2024 11:29:50 +0000 (13:29 +0200)] 
gh-109746: Fix race condition in test_start_new_thread_failed (GH-127299)

11 months agogh-127072: Remove outdated `socket.NETLINK_*` constants. (GH-127256)
RUANG (James Roy) [Wed, 27 Nov 2024 06:53:41 +0000 (14:53 +0800)] 
gh-127072: Remove outdated `socket.NETLINK_*` constants. (GH-127256)

Remove seriously outdated netlink constants.

Co-authored-by: Gregory P. Smith <greg@krypto.org>
11 months agogh-115999: Add free-threaded specialization for `STORE_SUBSCR` (#127169)
Sam Gross [Tue, 26 Nov 2024 21:46:06 +0000 (21:46 +0000)] 
gh-115999: Add free-threaded specialization for `STORE_SUBSCR` (#127169)

The specialization only depends on the type, so no special thread-safety
considerations there.

STORE_SUBSCR_LIST_INT needs to lock the list before modifying it.

`_PyDict_SetItem_Take2` already internally locks the dictionary using a
critical section.

11 months agogh-69639: Add mixed-mode rules for complex arithmetic (C-like) (GH-124829)
Sergey B Kirpichev [Tue, 26 Nov 2024 18:20:37 +0000 (21:20 +0300)] 
gh-69639: Add mixed-mode rules for complex arithmetic (C-like) (GH-124829)

"Generally, mixed-mode arithmetic combining real and complex variables should
be performed directly, not by first coercing the real to complex, lest the sign
of zero be rendered uninformative; the same goes for combinations of pure
imaginary quantities with complex variables." (c) Kahan, W: Branch cuts for
complex elementary functions.

This patch implements mixed-mode arithmetic rules, combining real and
complex variables as specified by C standards since C99 (in particular,
there is no special version for the true division with real lhs
operand).  Most C compilers implementing C99+ Annex G have only these
special rules (without support for imaginary type, which is going to be
deprecated in C2y).

11 months agogh-127285: Update PCbuild files for a number of missed changes (GH-127286)
Sergey Muraviov [Tue, 26 Nov 2024 16:39:33 +0000 (19:39 +0300)] 
gh-127285: Update PCbuild files for a number of missed changes (GH-127286)

11 months agogh-69639: Add mixed-mode rules for complex arithmetic (C-like) (GH-124829)
Sergey B Kirpichev [Tue, 26 Nov 2024 15:57:39 +0000 (18:57 +0300)] 
gh-69639: Add mixed-mode rules for complex arithmetic (C-like) (GH-124829)

"Generally, mixed-mode arithmetic combining real and complex variables should
be performed directly, not by first coercing the real to complex, lest the sign
of zero be rendered uninformative; the same goes for combinations of pure
imaginary quantities with complex variables." (c) Kahan, W: Branch cuts for
complex elementary functions.

This patch implements mixed-mode arithmetic rules, combining real and
complex variables as specified by C standards since C99 (in particular,
there is no special version for the true division with real lhs
operand).  Most C compilers implementing C99+ Annex G have only these
special rules (without support for imaginary type, which is going to be
deprecated in C2y).

11 months agogh-119180: Add VALUE_WITH_FAKE_GLOBALS format to annotationlib (#124415)
Jelle Zijlstra [Tue, 26 Nov 2024 15:40:13 +0000 (07:40 -0800)] 
gh-119180: Add VALUE_WITH_FAKE_GLOBALS format to annotationlib (#124415)

11 months agoGH-126985: move pyvenv.cfg detection from site to getpath (#126987)
Filipe Laíns 🇵🇸 [Tue, 26 Nov 2024 13:46:33 +0000 (13:46 +0000)] 
GH-126985: move pyvenv.cfg detection from site to getpath (#126987)

11 months agoDoc: Typo fix: nrace -> race (#127288)
Richard Hansen [Tue, 26 Nov 2024 13:05:07 +0000 (08:05 -0500)] 
Doc: Typo fix: nrace -> race (#127288)

11 months agogh-113993: InternalDocs: Add String Interning to README (#127250)
Petr Viktorin [Tue, 26 Nov 2024 10:06:57 +0000 (11:06 +0100)] 
gh-113993: InternalDocs: Add String Interning to README (#127250)

11 months agogh-124873: Skip timerfd tests on Android (#127279)
Malcolm Smith [Tue, 26 Nov 2024 09:46:46 +0000 (09:46 +0000)] 
gh-124873: Skip timerfd tests on Android (#127279)

* Revert "[3.13] gh-124873: Tolerate 100 ms in TimerfdTests on Android (GH-127101) (#127105)"

This reverts commit c09366b1fed2289530581505834b2b262120a7c7.

* Skip timerfd tests on Android.

Co-authored-by: Victor Stinner <vstinner@python.org>
11 months agogh-122273: Support PyREPL history on Windows (#127141)
Victor Stinner [Tue, 26 Nov 2024 09:21:57 +0000 (10:21 +0100)] 
gh-122273: Support PyREPL history on Windows (#127141)

Co-authored-by: devdanzin <74280297+devdanzin@users.noreply.github.com>
11 months agogh-126946: Improve error message in getopt.do_longs based on existing comment (GH...
Beomsoo Kim [Tue, 26 Nov 2024 08:54:02 +0000 (17:54 +0900)] 
gh-126946: Improve error message in getopt.do_longs based on existing comment (GH-126871)

Include a list of possibilities for not unique prefix.

11 months agogh-101100: Fix sphinx warnings in `howto/*` (#127084)
Yuki Kobayashi [Tue, 26 Nov 2024 08:17:54 +0000 (17:17 +0900)] 
gh-101100: Fix sphinx warnings in `howto/*` (#127084)

11 months agoFix typo: Use AsyncFor element access in codegen (#127278)
Marc Mueller [Tue, 26 Nov 2024 01:00:46 +0000 (02:00 +0100)] 
Fix typo: Use AsyncFor element access in codegen (#127278)

Use AsyncFor element access in codegen

11 months agogh-126612: Include stack effects of uops when computing maximum stack depth (#126894)
mpage [Tue, 26 Nov 2024 00:53:49 +0000 (16:53 -0800)] 
gh-126612: Include stack effects of uops when computing maximum stack depth (#126894)

11 months agogh-127265: Remove single quotes from 'arrow's in tutorial/errors.rst (GH-127267)
funkyrailroad [Mon, 25 Nov 2024 21:34:01 +0000 (16:34 -0500)] 
gh-127265: Remove single quotes from 'arrow's in tutorial/errors.rst (GH-127267)

11 months agoGH-127236: `pathname2url()`: generate RFC 1738 URL for absolute POSIX path (#127194)
Barney Gale [Mon, 25 Nov 2024 19:59:20 +0000 (19:59 +0000)] 
GH-127236: `pathname2url()`: generate RFC 1738 URL for absolute POSIX path (#127194)

When handed an absolute Windows path such as `C:\foo` or `//server/share`,
the `urllib.request.pathname2url()` function returns a URL with an
authority section, such as `///C:/foo` or `//server/share` (or before
GH-126205, `////server/share`). Only the `file:` prefix is omitted.

But when handed an absolute POSIX path such as `/etc/hosts`, or a Windows
path of the same form (rooted but lacking a drive), the function returns a
URL without an authority section, such as `/etc/hosts`.

This patch corrects the discrepancy by adding a `//` prefix before
drive-less, rooted paths when generating URLs.

11 months agogh-127182: Fix `io.StringIO.__setstate__` crash when `None` is the first value (...
sobolevn [Mon, 25 Nov 2024 17:32:02 +0000 (20:32 +0300)] 
gh-127182: Fix `io.StringIO.__setstate__` crash when `None` is the first value (#127219)

Co-authored-by: Victor Stinner <vstinner@python.org>
11 months agogh-127022: Remove `_PyEvalFramePushAndInit_UnTagged` (gh-127168)
Sam Gross [Mon, 25 Nov 2024 17:24:37 +0000 (17:24 +0000)] 
gh-127022: Remove `_PyEvalFramePushAndInit_UnTagged` (gh-127168)

The interpreter now handles `_PyStackRef`s pointing to immortal objects
without the deferred bit set, so `_PyEvalFramePushAndInit_UnTagged` is
no longer necessary.

11 months agogh-127248: Fix several removed or misnamed files in pythoncore.vcxproj (GH-127249)
Sergey Muraviov [Mon, 25 Nov 2024 14:56:46 +0000 (17:56 +0300)] 
gh-127248: Fix several removed or misnamed files in pythoncore.vcxproj (GH-127249)

11 months agogh-107954: Document PEP 741 in What's New 3.14 (#127056)
Victor Stinner [Mon, 25 Nov 2024 14:24:33 +0000 (15:24 +0100)] 
gh-107954: Document PEP 741 in What's New 3.14 (#127056)

11 months agogh-127183: Add `_ctypes.CopyComPointer` tests (GH-127184)
Jun Komoda [Mon, 25 Nov 2024 13:55:07 +0000 (22:55 +0900)] 
gh-127183: Add `_ctypes.CopyComPointer` tests (GH-127184)

* Make `create_shelllink_persist` top level function.

* Add `CopyComPointerTests`.

* Add more tests.

* Update tests.

* Add assertions for `Release`'s return value.

11 months agoReplace `:platform:` with `.. availability::` in `socket.ioctl` doc. (GH-127122)
Jun Komoda [Mon, 25 Nov 2024 12:53:17 +0000 (21:53 +0900)] 
Replace `:platform:` with `.. availability::` in `socket.ioctl` doc. (GH-127122)

In `socket.ioctl`, `:platform:` -> `.. availability::`

11 months agogh-127238: adjust error message for sys.set_int_max_str_digits() (#127241)
Sergey B Kirpichev [Mon, 25 Nov 2024 05:29:55 +0000 (08:29 +0300)] 
gh-127238: adjust error message for sys.set_int_max_str_digits() (#127241)

Now it's correct and closer to Python/initconfig.c

11 months agoGH-115869: Make jit_stencils.h reproducible (GH-127166)
Brandt Bucher [Sun, 24 Nov 2024 22:42:50 +0000 (14:42 -0800)] 
GH-115869: Make jit_stencils.h reproducible (GH-127166)

11 months agoImprove `pathname2url()` and `url2pathname()` docs (#127125)
Barney Gale [Sun, 24 Nov 2024 17:33:46 +0000 (17:33 +0000)] 
Improve `pathname2url()` and `url2pathname()` docs (#127125)

These functions have long sown confusion among Python developers. The
existing documentation says they deal with URL path components, but that
doesn't fit the evidence on Windows:

    >>> pathname2url(r'C:\foo')
    '///C:/foo'
    >>> pathname2url(r'\\server\share')
    '////server/share'  # or '//server/share' as of quite recently

If these were URL path components, they would imply complete URLs like
`file://///C:/foo` and `file://////server/share`. Clearly this isn't right.
Yet the implementation in `nturl2path` is deliberate, and the
`url2pathname()` function correctly inverts it.

On non-Windows platforms, the behaviour until quite recently is to simply
quote/unquote the path without adding or removing any leading slashes. This
behaviour is compatible with *both* interpretations -- 1) the value is a
URL path component (existing docs), and 2) the value is everything
following `file:` (this commit)

The conclusion I draw is that these functions operate on everything after
the `file:` prefix, which may include an authority section. This is the
only explanation that fits both the  Windows and non-Windows behaviour.
It's also a better match for the function names.

11 months agogh-127217: Fix pathname2url() for paths starting with multiple slashes on Posix ...
Serhiy Storchaka [Sun, 24 Nov 2024 17:30:29 +0000 (19:30 +0200)] 
gh-127217: Fix pathname2url() for paths starting with multiple slashes on Posix (GH-127218)

11 months agoFix macro expansions in critical section docs (#127226)
da-woods [Sun, 24 Nov 2024 17:21:02 +0000 (17:21 +0000)] 
Fix macro expansions in critical section docs (#127226)

11 months agogh-122356: restore the position of a file-like object after `zipfile.is_zipfile`...
Bénédikt Tran [Sun, 24 Nov 2024 16:36:15 +0000 (17:36 +0100)] 
gh-122356: restore the position of a file-like object after `zipfile.is_zipfile` (#122397)

11 months agogh-101100: Fix sphinx warnings of removed opcodes (#127222)
Yuki Kobayashi [Sun, 24 Nov 2024 15:43:25 +0000 (00:43 +0900)] 
gh-101100: Fix sphinx warnings of removed opcodes (#127222)

11 months agoGH-127133: Remove ability to nest argument groups & mutually exclusive groups (#127186)
Savannah Ostrowski [Sun, 24 Nov 2024 15:20:37 +0000 (07:20 -0800)] 
GH-127133: Remove ability to nest argument groups & mutually exclusive groups (#127186)

11 months agogh-113841: fix possible undefined division by 0 in _Py_c_pow() (GH-127211)
Sergey B Kirpichev [Sun, 24 Nov 2024 07:37:37 +0000 (10:37 +0300)] 
gh-113841: fix possible undefined division by 0 in _Py_c_pow() (GH-127211)

`x**y == 1/x**-y ` thus changing `/=` to `*=` by negating the exponent.

11 months agogh-126662: harmonize naming for three namedtuple base classes in urllib.parse (GH...
Stephen Morton [Sun, 24 Nov 2024 02:36:48 +0000 (18:36 -0800)] 
gh-126662: harmonize naming for three namedtuple base classes in urllib.parse (GH-126663)

harmonize naming for three namedtuple base classes in urllib.parse

11 months agopathlib tests: move `walk()` tests into their own classes (GH-126651)
Barney Gale [Sun, 24 Nov 2024 02:31:00 +0000 (02:31 +0000)] 
pathlib tests: move `walk()` tests into their own classes (GH-126651)

Move tests for Path.walk() into a new PathWalkTest class, and apply a similar change in tests for the ABCs. This allows us to properly tear down the walk test hierarchy in tearDown(), rather than leaving it to os_helper.rmtree().

11 months agoFix "useable" typo in docs (#127200)
Stan U. [Sat, 23 Nov 2024 21:41:01 +0000 (21:41 +0000)] 
Fix "useable" typo in docs (#127200)

Fix typo in docs

11 months agoDoc: C API: Fix `Py_NewInterpreterFromConfig` example code (#126667)
Richard Hansen [Sat, 23 Nov 2024 19:47:08 +0000 (14:47 -0500)] 
Doc: C API: Fix `Py_NewInterpreterFromConfig` example code (#126667)

11 months agoGH-125866: Preserve Windows drive letter case in file URIs (#127138)
Barney Gale [Sat, 23 Nov 2024 10:41:39 +0000 (10:41 +0000)] 
GH-125866: Preserve Windows drive letter case in file URIs (#127138)

Stop converting Windows drive letters to uppercase in
`urllib.request.pathname2url()` and `url2pathname()`. This behaviour is
unnecessary and inconsistent with pathlib's file URI implementation.

11 months agoGH-127134: Add note about forward compatibility for suggest_on_error (#127137)
Savannah Ostrowski [Sat, 23 Nov 2024 03:18:18 +0000 (19:18 -0800)] 
GH-127134: Add note about forward compatibility for suggest_on_error (#127137)

11 months agoFix a few typos found in the docs (GH-127126)
Rafael Fontenelle [Sat, 23 Nov 2024 00:02:51 +0000 (21:02 -0300)] 
Fix a few typos found in the docs (GH-127126)

11 months agogh-115999: Record success in `specialize` (#127167)
mpage [Fri, 22 Nov 2024 20:07:05 +0000 (12:07 -0800)] 
gh-115999: Record success in `specialize` (#127167)

Record success in `specialize`

This matches the existing behavior where we increment the success
stat for the generic opcode each time we successfully specialize
an instruction.

11 months agogh-119786: add code object doc, inline locations.md into it (#126832)
Irit Katriel [Fri, 22 Nov 2024 19:27:41 +0000 (19:27 +0000)] 
gh-119786: add code object doc, inline locations.md into it (#126832)

11 months agogh-109746: Make _thread.start_new_thread delete state of new thread on its startup...
Radislav Chugunov [Fri, 22 Nov 2024 19:20:07 +0000 (22:20 +0300)] 
gh-109746: Make _thread.start_new_thread delete state of new thread on its startup failure (GH-109761)

If Python fails to start newly created thread
due to failure of underlying PyThread_start_new_thread() call,
its state should be removed from interpreter' thread states list
to avoid its double cleanup.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
11 months agoGH-89435: os.path should not be a frozen module (#126924)
Filipe Laíns 🇵🇸 [Fri, 22 Nov 2024 18:50:30 +0000 (18:50 +0000)] 
GH-89435: os.path should not be a frozen module (#126924)

11 months agogh-127022: Simplify `PyStackRef_FromPyObjectSteal` (#127024)
Sam Gross [Fri, 22 Nov 2024 17:55:33 +0000 (17:55 +0000)] 
gh-127022: Simplify `PyStackRef_FromPyObjectSteal` (#127024)

This gets rid of the immortal check in `PyStackRef_FromPyObjectSteal()`.
Overall, this improves performance about 2% in the free threading
build.

This also renames `PyStackRef_Is()` to `PyStackRef_IsExactly()` because
the macro requires that the tag bits of the arguments match, which is
only true in certain special cases.

11 months agoEnable aarch64 Ubuntu CI jobs (#125786)
Łukasz Langa [Fri, 22 Nov 2024 17:29:18 +0000 (18:29 +0100)] 
Enable aarch64 Ubuntu CI jobs (#125786)

This change enables custom GHA runners for Ubuntu-24.04 that run on Arm hardware. It also prepares for Windows runners on Arm hardware, but doesn't enable that just yet, because the Arm GHA runner images for Windows need to be updated.

11 months agogh-115999: Add free-threaded specialization for `UNPACK_SEQUENCE` (#126600)
Kirill Podoprigora [Fri, 22 Nov 2024 17:00:35 +0000 (19:00 +0200)] 
gh-115999: Add free-threaded specialization for `UNPACK_SEQUENCE` (#126600)

Add free-threaded specialization for `UNPACK_SEQUENCE` opcode.
`UNPACK_SEQUENCE_TUPLE/UNPACK_SEQUENCE_TWO_TUPLE` are already thread safe since tuples are immutable.
`UNPACK_SEQUENCE_LIST` is not thread safe because of nature of lists (there is nothing preventing another thread from adding items to or removing them the list while the instruction is executing). To achieve thread safety we add a critical section to the implementation of `UNPACK_SEQUENCE_LIST`, especially around the parts where we check the size of the list and push items onto the stack.

---------

Co-authored-by: Matt Page <mpage@meta.com>
Co-authored-by: mpage <mpage@cs.stanford.edu>
11 months agogh-127117: Ensure the Correct Last Fields of PyInterpreterState and of _PyRuntimeStat...
Eric Snow [Fri, 22 Nov 2024 16:37:02 +0000 (09:37 -0700)] 
gh-127117: Ensure the Correct Last Fields of PyInterpreterState and of _PyRuntimeState (gh-127118)

We add some comments so contributors can be aware and we move one out-of-place field up.

11 months agogh-86463: Fix a trailing space in argparse.rst (#127162)
Serhiy Storchaka [Fri, 22 Nov 2024 16:34:05 +0000 (18:34 +0200)] 
gh-86463: Fix a trailing space in argparse.rst (#127162)

11 months agogh-88110: Clear concurrent.futures.thread._threads_queues after fork to avoid joining...
Andrei Bodrov [Fri, 22 Nov 2024 16:20:34 +0000 (19:20 +0300)] 
gh-88110: Clear concurrent.futures.thread._threads_queues after fork to avoid joining parent process' threads (GH-126098)

Threads are gone after fork, so clear the queues too. Otherwise the
child process (here created via multiprocessing.Process) crashes on
interpreter exit.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
11 months agogh-126384: Add tests to verify the behavior of basic COM methods. (GH-126610)
Jun Komoda [Fri, 22 Nov 2024 15:57:31 +0000 (00:57 +0900)] 
gh-126384: Add tests to verify the behavior of basic COM methods. (GH-126610)

11 months agogh-109413: Fix libregrtest get_running() (#127153)
Victor Stinner [Fri, 22 Nov 2024 15:56:03 +0000 (16:56 +0100)] 
gh-109413: Fix libregrtest get_running() (#127153)

Skip threads which are not running.

11 months agogh-127001: Fix PATHEXT issues in shutil.which() on Windows (GH-127035)
Serhiy Storchaka [Fri, 22 Nov 2024 15:52:15 +0000 (17:52 +0200)] 
gh-127001: Fix PATHEXT issues in shutil.which() on Windows (GH-127035)

* Name without a PATHEXT extension is only searched if the mode does not
  include X_OK.
* Support multi-component PATHEXT extensions (e.g. ".foo.bar").
* Support files without extensions in PATHEXT contains dot-only extension
  (".", "..", etc).
* Support PATHEXT extensions that end with a dot (e.g. ".foo.").

11 months agoFix broken XML in Visual Studio project file (GH-127142)
Sergey Muraviov [Fri, 22 Nov 2024 15:30:01 +0000 (18:30 +0300)] 
Fix broken XML in Visual Studio project file (GH-127142)

11 months agogh-86463: Fix default prog in subparsers if usage is used in the main parser (GH...
Serhiy Storchaka [Fri, 22 Nov 2024 15:29:33 +0000 (17:29 +0200)] 
gh-86463: Fix default prog in subparsers if usage is used in the main parser (GH-125891)

The usage parameter of argparse.ArgumentParser no longer
affects the default value of the prog parameter in subparsers.

Previously the full custom usage of the main parser was used as
the prog prefix in subparsers.

11 months agogh-127076: Ignore memory mmap in FileIO testing (#127088)
Cody Maloney [Fri, 22 Nov 2024 14:55:32 +0000 (06:55 -0800)] 
gh-127076: Ignore memory mmap in FileIO testing (#127088)

`mmap`, `munmap`, and `mprotect` are used by CPython for memory
management, which may occur in the middle of the FileIO tests. The
system calls can also be used with files, so `strace` includes them
in its `%file` and `%desc` filters.

Filter out the `mmap` system calls related to memory allocation for the
file tests. Currently FileIO doesn't do `mmap` at all, so didn't add
code to track from `mmap` through `munmap` since it wouldn't be used.
For now if an `mmap` on a fd happens, the call will be included (which
may cause test to fail), and at that time support for tracking the
address throug `munmap` could be added.

11 months agogh-126700: pygettext: Support more gettext functions (GH-126912)
Tomas R. [Fri, 22 Nov 2024 14:52:16 +0000 (15:52 +0100)] 
gh-126700: pygettext: Support more gettext functions (GH-126912)

Support multi-argument gettext functions: ngettext(), pgettext(), dgettext(), etc.

11 months agogh-127065: Make `methodcaller` thread-safe in free threading build (#127109)
Sam Gross [Fri, 22 Nov 2024 14:21:59 +0000 (14:21 +0000)] 
gh-127065: Make `methodcaller` thread-safe in free threading build (#127109)

The `methodcaller` C vectorcall implementation uses an arguments array
that is shared across calls. The first argument is modified on every
invocation. This isn't thread-safe in the free threading build. I think
it's also not safe in general, but for now just disable it in the free
threading build.

11 months agogh-127082: Replace "Windows only" with the `availability: Windows` in `ctypes` doc...
Jun Komoda [Fri, 22 Nov 2024 07:56:34 +0000 (16:56 +0900)] 
gh-127082: Replace "Windows only" with the `availability: Windows` in `ctypes` doc (#127099)

11 months agoAllow local use of `static PyMutex` in the C analyzer (#127102)
Peter Bierma [Fri, 22 Nov 2024 07:48:39 +0000 (02:48 -0500)] 
Allow local use of `static PyMutex` in the C analyzer (#127102)

11 months agoGH-127078: `url2pathname()`: handle extra slash before UNC drive in URL path (#127132)
Barney Gale [Fri, 22 Nov 2024 04:12:50 +0000 (04:12 +0000)] 
GH-127078: `url2pathname()`: handle extra slash before UNC drive in URL path (#127132)

Decode a file URI like `file://///server/share` as a UNC path like
`\\server\share`. This form of file URI is created by software the simply
prepends `file:///` to any absolute Windows path.

11 months agoGH-126766: `url2pathname()`: handle 'localhost' authority (#127129)
Barney Gale [Fri, 22 Nov 2024 03:17:06 +0000 (03:17 +0000)] 
GH-126766: `url2pathname()`: handle 'localhost' authority (#127129)

Discard any 'localhost' authority from the beginning of a `file:` URI. As a
result, file URIs like `//localhost/etc/hosts` are correctly decoded as
`/etc/hosts`.

11 months agoGH-122679: Add `register()` to argparse docs (#126939)
Savannah Ostrowski [Fri, 22 Nov 2024 00:36:11 +0000 (16:36 -0800)] 
GH-122679: Add `register()` to argparse docs (#126939)

* Add register() to argparse docs

* Add newline

* Formatting

* Fix codeblock

* Move section

* Add signature

* Add newline

* Fix indent

* Fix indent take 2

* Rephrase

* Simplify language

* Address PR comments

* Add references to register in type and action

* Remove unnecessary reference

* Rephrase and add success case

11 months agoGH-126601: `pathname2url()`: handle NTFS alternate data streams (#126760)
Barney Gale [Fri, 22 Nov 2024 00:29:05 +0000 (00:29 +0000)] 
GH-126601: `pathname2url()`: handle NTFS alternate data streams (#126760)

Adjust `pathname2url()` to encode embedded colon characters in Windows
paths, rather than bailing out with an `OSError`.

Co-authored-by: Steve Dower <steve.dower@microsoft.com>
11 months agogh-126091: Always link generator frames when propagating a thrown-in exception throug...
Jacob Bower [Thu, 21 Nov 2024 23:37:49 +0000 (15:37 -0800)] 
gh-126091: Always link generator frames when propagating a thrown-in exception through a yield-from chain (#126092)

Always link generator frames when propagating a thrown-in exception through a yield-from chain.

11 months agoImprove comment for co_nlocalsplus (#126993)
Jacob Bower [Thu, 21 Nov 2024 23:26:25 +0000 (15:26 -0800)] 
Improve comment for co_nlocalsplus (#126993)

11 months agogh-115999: Add free-threaded specialization for ``TO_BOOL`` (gh-126616)
Donghee Na [Thu, 21 Nov 2024 22:52:16 +0000 (07:52 +0900)] 
gh-115999: Add free-threaded specialization for ``TO_BOOL`` (gh-126616)

11 months agogh-115999: Specialize `LOAD_GLOBAL` in free-threaded builds (#126607)
mpage [Thu, 21 Nov 2024 19:22:21 +0000 (11:22 -0800)] 
gh-115999: Specialize `LOAD_GLOBAL` in free-threaded builds (#126607)

Enable specialization of LOAD_GLOBAL in free-threaded builds.

Thread-safety of specialization in free-threaded builds is provided by the following:

A critical section is held on both the globals and builtins objects during specialization. This ensures we get an atomic view of both builtins and globals during specialization.
Generation of new keys versions is made atomic in free-threaded builds.
Existing helpers are used to atomically modify the opcode.
Thread-safety of specialized instructions in free-threaded builds is provided by the following:

Relaxed atomics are used when loading and storing dict keys versions. This avoids potential data races as the dict keys versions are read without holding the dictionary's per-object lock in version guards.
Dicts keys objects are passed from keys version guards to the downstream uops. This ensures that we are loading from the correct offset in the keys object. Once a unicode key has been stored in a keys object for a combined dictionary in free-threaded builds, the offset that it is stored in will never be reused for a different key. Once the version guard passes, we know that we are reading from the correct offset.
The dictionary read fast-path is used to read values from the dictionary once we know the correct offset.

11 months agogh-114940: Add _Py_FOR_EACH_TSTATE_UNLOCKED(), and Friends (gh-127077)
Eric Snow [Thu, 21 Nov 2024 18:08:38 +0000 (11:08 -0700)] 
gh-114940: Add _Py_FOR_EACH_TSTATE_UNLOCKED(), and Friends (gh-127077)

This is a precursor to the actual fix for gh-114940, where we will change these macros to use the new lock.  This change is almost entirely mechanical; the exceptions are the loops in codeobject.c and ceval.c, which now hold the "head" lock.  Note that almost all of the uses of _Py_FOR_EACH_TSTATE_UNLOCKED() here will change to _Py_FOR_EACH_TSTATE_BEGIN() once we add the new per-interpreter lock.

11 months agogh-124470: Fix crash when reading from object instance dictionary while replacing...
Dino Viehland [Thu, 21 Nov 2024 16:41:19 +0000 (08:41 -0800)] 
gh-124470: Fix crash when reading from object instance dictionary while replacing it (#122489)

Delay free a dictionary when replacing it

11 months agogh-127020: Make `PyCode_GetCode` thread-safe for free threading (#127043)
Sam Gross [Thu, 21 Nov 2024 16:00:50 +0000 (16:00 +0000)] 
gh-127020: Make `PyCode_GetCode` thread-safe for free threading (#127043)

Some fields in PyCodeObject are lazily initialized. Use atomics and
critical sections to make their initializations and accesses thread-safe.

11 months agogh-118761: Improve import time of `mimetypes` (#126979)
Hugo van Kemenade [Thu, 21 Nov 2024 14:55:28 +0000 (16:55 +0200)] 
gh-118761: Improve import time of `mimetypes` (#126979)

11 months agogh-124873: Tolerate 100 ms in TimerfdTests on Android (#127101)
Victor Stinner [Thu, 21 Nov 2024 14:53:52 +0000 (15:53 +0100)] 
gh-124873: Tolerate 100 ms in TimerfdTests on Android (#127101)

On Android, TimerfdTests of test_os now uses 100 ms accuracy instead
of 10 ms.

11 months agogh-126316: Make grp.getgrall() thread-safe: add a mutex (#127055)
Victor Stinner [Thu, 21 Nov 2024 14:47:24 +0000 (15:47 +0100)] 
gh-126316: Make grp.getgrall() thread-safe: add a mutex (#127055)

grpmodule.c is no longer built with the limited C API, since PyMutex
is excluded from the limited C API.

11 months agogh-126780: Fix `ntpath.normpath()` for drive-relative paths (GH-126801)
Nice Zombies [Thu, 21 Nov 2024 14:43:36 +0000 (15:43 +0100)] 
gh-126780: Fix `ntpath.normpath()` for drive-relative paths (GH-126801)

11 months agogh-112136: Remove unused #include "pycore_lock.h" (#127093)
Victor Stinner [Thu, 21 Nov 2024 12:50:11 +0000 (13:50 +0100)] 
gh-112136: Remove unused #include "pycore_lock.h" (#127093)

pycore_modsupport.h no longer needs pycore_lock.h.

11 months agogh-126727: Fix locale.nl_langinfo(locale.ERA) (GH-126730)
Serhiy Storchaka [Thu, 21 Nov 2024 11:16:08 +0000 (13:16 +0200)] 
gh-126727: Fix locale.nl_langinfo(locale.ERA) (GH-126730)

It now returns multiple era description segments separated by semicolons.
Previously it only returned the first segment on platforms with Glibc.

11 months agogh-126997: Fix support of non-ASCII strings in pickletools (GH-127062)
Serhiy Storchaka [Thu, 21 Nov 2024 11:15:12 +0000 (13:15 +0200)] 
gh-126997: Fix support of non-ASCII strings in pickletools (GH-127062)

* Fix support of STRING and GLOBAL opcodes with non-ASCII arguments.
* dis() now outputs non-ASCII bytes in STRING, BINSTRING and
  SHORT_BINSTRING arguments as escaped (\xXX).

11 months agogh-127076: Disable strace tests under LD_PRELOAD (#127086)
Cody Maloney [Thu, 21 Nov 2024 09:33:12 +0000 (01:33 -0800)] 
gh-127076: Disable strace tests under LD_PRELOAD (#127086)

Distribution tooling (ex. sandbox on Gentoo and fakeroot on Debian) uses
LD_PRELOAD to intercept system calls and potentially modify them when
building. These tools can change the set of system calls, so disable
system call testing under these cases.

Co-authored-by: Michał Górny <mgorny@gentoo.org>
11 months agogh-126898: Emscripten support: Use es6 modules (#126903)
Hood Chatham [Thu, 21 Nov 2024 04:10:46 +0000 (05:10 +0100)] 
gh-126898: Emscripten support: Use es6 modules (#126903)

Modify Emscripten support to use ES6 modules.

11 months agogh-115999: Don't take a reason in unspecialize (#127030)
mpage [Wed, 20 Nov 2024 22:54:48 +0000 (14:54 -0800)] 
gh-115999: Don't take a reason in unspecialize (#127030)

Don't take a reason in unspecialize

We only want to compute the reason if stats are enabled. Optimizing
compilers should optimize this away for us (gcc and clang do), but
it's better to be safe than sorry.