]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
19 months agogh-117439: Make refleak checking thread-safe without the GIL (#117469)
Sam Gross [Mon, 8 Apr 2024 16:11:36 +0000 (12:11 -0400)] 
gh-117439: Make refleak checking thread-safe without the GIL (#117469)

This keeps track of the per-thread total reference count operations in
PyThreadState in the free-threaded builds. The count is merged into the
interpreter's total when the thread exits.

19 months agogh-117547: Fix mimalloc compile error on OpenBSD (#117548)
Sam Gross [Mon, 8 Apr 2024 15:53:13 +0000 (11:53 -0400)] 
gh-117547: Fix mimalloc compile error on OpenBSD (#117548)

19 months agogh-111926: Make weakrefs thread-safe in free-threaded builds (#117168)
mpage [Mon, 8 Apr 2024 14:58:38 +0000 (07:58 -0700)] 
gh-111926: Make weakrefs thread-safe in free-threaded builds (#117168)

Most mutable data is protected by a striped lock that is keyed on the
referenced object's address. The weakref's hash is protected using the
weakref's per-object lock.

Note that this only affects free-threaded builds. Apart from some minor
refactoring, the added code is all either gated by `ifdef`s or is a no-op
(e.g. `Py_BEGIN_CRITICAL_SECTION`).

19 months agogh-96471: Correct documentation for asyncio queue shutdown (#117621)
Laurie O [Mon, 8 Apr 2024 14:50:54 +0000 (00:50 +1000)] 
gh-96471: Correct documentation for asyncio queue shutdown (#117621)

19 months agogh-117293: Fix race condition in run_workers.py (#117298)
Sam Gross [Mon, 8 Apr 2024 14:47:42 +0000 (10:47 -0400)] 
gh-117293: Fix race condition in run_workers.py (#117298)

The worker thread may still be alive after it enqueues it's last result,
which can lead to a delay of 30 seconds after the test finishes. This
happens much more frequently in the free-threaded build with the GIL
disabled.

This changes run_workers.py to track of live workers by enqueueing a
`WorkerExited()` instance before the worker exits.

19 months agogh-117552: Add timeout in HTTPHandlerTest (#117553)
Sam Gross [Mon, 8 Apr 2024 14:46:56 +0000 (10:46 -0400)] 
gh-117552: Add timeout in HTTPHandlerTest (#117553)

19 months agogh-116303: Skip tests if C recursion limit is unavailable (GH-117368)
Erlend E. Aasland [Mon, 8 Apr 2024 12:45:25 +0000 (14:45 +0200)] 
gh-116303: Skip tests if C recursion limit is unavailable (GH-117368)

The test suite fetches the C recursion limit from the _testcapi
extension module. Test extension modules can be disabled using the
--disable-test-modules configure option.

19 months agogh-106023: Update What's New in 3.13: _PyObject_FastCall() (#117633)
Victor Stinner [Mon, 8 Apr 2024 12:19:43 +0000 (14:19 +0200)] 
gh-106023: Update What's New in 3.13: _PyObject_FastCall() (#117633)

The function _PyObject_FastCall() was restored.

19 months agogh-111726: Explicitly close database connections in sqlite3 doctests (#111730)
Nikita Sobolev [Mon, 8 Apr 2024 09:29:47 +0000 (12:29 +0300)] 
gh-111726: Explicitly close database connections in sqlite3 doctests (#111730)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
19 months agogh-111726: Remove some doctests from sqlite3 docs (#117623)
Erlend E. Aasland [Mon, 8 Apr 2024 08:11:08 +0000 (10:11 +0200)] 
gh-111726: Remove some doctests from sqlite3 docs (#117623)

* remove load extension doctest since we cannot skip it conditionally
* remove sys.unraisablehook example; using unraisable hooks is not "an
  improved debug experience"

19 months agogh-113317: Remove unused INVALID constant in Argument Clinic (#117624)
Victor Stinner [Mon, 8 Apr 2024 07:51:20 +0000 (09:51 +0200)] 
gh-113317: Remove unused INVALID constant in Argument Clinic (#117624)

19 months agogh-111726: Cleanup test files after running sqlite3 doctest (#117604)
Hugo van Kemenade [Mon, 8 Apr 2024 06:35:48 +0000 (09:35 +0300)] 
gh-111726: Cleanup test files after running sqlite3 doctest (#117604)

Remove all temporary databases in a dedicated 'testcleanup' step
at the end of the file.

19 months agogh-117594: Require cpu resource to test_search_anchor_at_beginning (gh-117595)
Donghee Na [Sun, 7 Apr 2024 23:58:19 +0000 (08:58 +0900)] 
gh-117594: Require cpu resource to test_search_anchor_at_beginning (gh-117595)

19 months agoFix reference in code.rst (#117615)
Anita Hammer [Sun, 7 Apr 2024 22:58:57 +0000 (23:58 +0100)] 
Fix reference in code.rst (#117615)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
19 months agoCases generator: Remove type_prop and passthrough (#117614)
Ken Jin [Sun, 7 Apr 2024 22:26:52 +0000 (06:26 +0800)] 
Cases generator: Remove type_prop and passthrough (#117614)

19 months agogh-117584: Raise TypeError for non-paths in posixpath.relpath() (GH-117585)
Nice Zombies [Sun, 7 Apr 2024 09:00:08 +0000 (11:00 +0200)] 
gh-117584: Raise TypeError for non-paths in posixpath.relpath() (GH-117585)

19 months agoGH-117512: Allow 64-bit JIT operands on 32-bit platforms (GH-117527)
Brandt Bucher [Sat, 6 Apr 2024 15:26:43 +0000 (08:26 -0700)] 
GH-117512: Allow 64-bit JIT operands on 32-bit platforms (GH-117527)

19 months agogh-96471: Add asyncio queue shutdown (#104228)
Laurie O [Sat, 6 Apr 2024 14:27:13 +0000 (00:27 +1000)] 
gh-96471: Add asyncio queue shutdown (#104228)

Co-authored-by: Duprat <yduprat@gmail.com>
19 months agogh-116622: Test updates for Android (#117299)
Malcolm Smith [Fri, 5 Apr 2024 20:57:36 +0000 (21:57 +0100)] 
gh-116622: Test updates for Android (#117299)

- re-enable test_fcntl_64_bit on Linux aarch64, but disable it on all
  Android ABIs
- use support.setswitchinterval in all relevant tests
- skip test_fma_zero_result on Android x86_64
- accept EACCES when calling os.get_terminal_size on Android

19 months agoGH-77609: Add recurse_symlinks argument to `pathlib.Path.glob()` (#117311)
Barney Gale [Fri, 5 Apr 2024 18:51:54 +0000 (19:51 +0100)] 
GH-77609: Add recurse_symlinks argument to `pathlib.Path.glob()` (#117311)

Replace tri-state `follow_symlinks` with boolean `recurse_symlinks` argument. The new argument controls whether symlinks are followed when expanding recursive `**` wildcards. The possible argument values correspond as follows:

    follow_symlinks  recurse_symlinks
    ===============  ================
    False            N/A
    None             False
    True             True

We therefore drop support for not following symlinks when expanding non-recursive pattern parts; it wasn't requested in the original issue, and it's a feature not found in any shells.

This makes the API a easier to grok by eliminating `None` as an option.

No news blurb as `follow_symlinks` was new in 3.13.

19 months agogh-116608: Ignore UTF-16 BOM in importlib.resources._functional tests (GH-117569)
Petr Viktorin [Fri, 5 Apr 2024 15:00:29 +0000 (17:00 +0200)] 
gh-116608: Ignore UTF-16 BOM in importlib.resources._functional tests (GH-117569)

gh-116609: Ignore UTF-16 BOM in importlib.resources._functional tests

To test the `errors` argument, we read a UTF-16 file as UTF-8
with "backslashreplace" error handling. However, the utf-16
codec adds an endian-specific byte-order mark, so on big-endian
machines the expectation doesn't match the test file (which was
saved on a little-endian machine).

Use endswith to ignore the BOM.

19 months agogh-111140: PyLong_From/AsNativeBytes: Take *flags* rather than just *endianness*...
Steve Dower [Fri, 5 Apr 2024 14:21:16 +0000 (15:21 +0100)] 
gh-111140: PyLong_From/AsNativeBytes: Take *flags* rather than just *endianness* (GH-116053)

19 months agoGH-114847: Speed up `posixpath.realpath()` (#114848)
Barney Gale [Fri, 5 Apr 2024 12:35:01 +0000 (13:35 +0100)] 
GH-114847: Speed up `posixpath.realpath()` (#114848)

Apply the following optimizations to `posixpath.realpath()`:

- Remove use of recursion
- Construct child paths directly rather than using `join()`
- Use `os.getcwd[b]()` rather than `abspath()`
- Use `startswith(sep)` rather than `isabs()`
- Use slicing rather than `split()`

Co-authored-by: Petr Viktorin <encukou@gmail.com>
19 months agogh-116608: importlib.resources: Un-deprecate functional API & add subdirectory suppor...
Petr Viktorin [Fri, 5 Apr 2024 11:55:59 +0000 (13:55 +0200)] 
gh-116608: importlib.resources: Un-deprecate functional API & add subdirectory support  (GH-116609)

19 months agogh-117457: Regen executor cases post PR #117477 (#117559)
Erlend E. Aasland [Fri, 5 Apr 2024 10:13:00 +0000 (12:13 +0200)] 
gh-117457: Regen executor cases post PR #117477 (#117559)

19 months agogh-116303: Don't build xxlimited and xxlimited_35 if --disable-test-modules is given...
Erlend E. Aasland [Fri, 5 Apr 2024 08:29:15 +0000 (10:29 +0200)] 
gh-116303: Don't build xxlimited and xxlimited_35 if --disable-test-modules is given (#117554)

19 months agoGH-117457: Correct pystats uop "miss" counts (GH-117477)
Michael Droettboom [Thu, 4 Apr 2024 22:49:18 +0000 (18:49 -0400)] 
GH-117457: Correct pystats uop "miss" counts (GH-117477)

19 months agogh-117549: Match declaration order for _Py_BackoffCounter initializer (#117551)
Michael Droettboom [Thu, 4 Apr 2024 21:14:35 +0000 (17:14 -0400)] 
gh-117549: Match declaration order for _Py_BackoffCounter initializer (#117551)

Otherwise it might not compile with C++ (or certain C compilers/flags?).

19 months agogh-117474: Skip GIL test in free-threaded build (#117475)
Sam Gross [Thu, 4 Apr 2024 20:27:14 +0000 (16:27 -0400)] 
gh-117474: Skip GIL test in free-threaded build (#117475)

In the free-threaded build, the GIL will typically be disabled so
`py-bt` will not show threads waiting on the GIL.

19 months agogh-112075: Make _PyDict_LoadGlobal thread safe (#117529)
Dino Viehland [Thu, 4 Apr 2024 19:26:07 +0000 (12:26 -0700)] 
gh-112075: Make _PyDict_LoadGlobal thread safe (#117529)

Make _PyDict_LoadGlobal threadsafe

19 months agogh-117478: Add `@support.requires_gil_enabled` decorator (#117479)
Sam Gross [Thu, 4 Apr 2024 18:10:46 +0000 (14:10 -0400)] 
gh-117478: Add `@support.requires_gil_enabled` decorator (#117479)

Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
19 months agogh-117435: Make `SemLock` thread-safe in free-threaded build (#117436)
Sam Gross [Thu, 4 Apr 2024 18:09:38 +0000 (14:09 -0400)] 
gh-117435: Make `SemLock` thread-safe in free-threaded build (#117436)

Use critical sections to make acquire, release, and _count thread-safe
without the GIL.

19 months agogh-117494: extract the Instruction Sequence data structure into a separate file ...
Irit Katriel [Thu, 4 Apr 2024 15:47:26 +0000 (16:47 +0100)] 
gh-117494: extract the Instruction Sequence data structure into a separate file (#117496)

19 months agogh-116968: Reimplement Tier 2 counters (#117144)
Guido van Rossum [Thu, 4 Apr 2024 15:03:27 +0000 (08:03 -0700)] 
gh-116968: Reimplement Tier 2 counters (#117144)

Introduce a unified 16-bit backoff counter type (``_Py_BackoffCounter``),
shared between the Tier 1 adaptive specializer and the Tier 2 optimizer. The
API used for adaptive specialization counters is changed but the behavior is
(supposed to be) identical.

The behavior of the Tier 2 counters is changed:
- There are no longer dynamic thresholds (we never varied these).
- All counters now use the same exponential backoff.
- The counter for ``JUMP_BACKWARD`` starts counting down from 16.
- The ``temperature`` in side exits starts counting down from 64.

19 months agogh-109802: Add coverage test for complex_abs() (GH-117449)
Sergey B Kirpichev [Thu, 4 Apr 2024 14:54:17 +0000 (17:54 +0300)] 
gh-109802: Add coverage test for complex_abs() (GH-117449)

* gh-109802: Add coverage test for complex_abs()

This tests overflow on L594.

// line numbers wrt to 0f2fa6150b

19 months ago[doc] Update logging documentation to improve grammar and elucidate an example. ...
Vinay Sajip [Thu, 4 Apr 2024 12:14:44 +0000 (13:14 +0100)] 
[doc] Update logging documentation to improve grammar and elucidate an example. (GH-117541)

19 months agogh-117521: Improve typing.TypeGuard docstring (#117522)
Jelle Zijlstra [Thu, 4 Apr 2024 10:39:16 +0000 (06:39 -0400)] 
gh-117521: Improve typing.TypeGuard docstring (#117522)

19 months agogh-117467: Add preserving of mailbox owner on flush (GH-117510)
Tony Mountifield [Thu, 4 Apr 2024 10:32:53 +0000 (11:32 +0100)] 
gh-117467: Add preserving of mailbox owner on flush (GH-117510)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
19 months agogh-113317: Finish splitting Argument Clinic into sub-files (#117513)
Victor Stinner [Thu, 4 Apr 2024 09:09:40 +0000 (11:09 +0200)] 
gh-113317: Finish splitting Argument Clinic into sub-files (#117513)

Add libclinic.parser module and move the following classes and
functions there:

* Parser
* PythonParser
* create_parser_namespace()

Add libclinic.dsl_parser module and move the following classes,
functions and variables there:

* ConverterArgs
* DSLParser
* FunctionNames
* IndentStack
* ParamState
* StateKeeper
* eval_ast_expr()
* unsupported_special_methods

Add libclinic.app module and move the Clinic class there.

Add libclinic.cli module and move the following functions there:

* create_cli()
* main()
* parse_file()
* run_clinic()

19 months agogh-117459: Keep the traceback in _convert_future_exc (#117460)
rsp4jack [Thu, 4 Apr 2024 03:13:32 +0000 (11:13 +0800)] 
gh-117459: Keep the traceback in _convert_future_exc (#117460)

19 months agogh-117205: Increase chunksize when compiling pyc in parallel (#117206)
Shantanu [Wed, 3 Apr 2024 22:24:24 +0000 (15:24 -0700)] 
gh-117205: Increase chunksize when compiling pyc in parallel (#117206)

19 months agogh-117267: Ensure DirEntry.stat().st_ctime still contains creation time during deprec...
Steve Dower [Wed, 3 Apr 2024 22:14:55 +0000 (23:14 +0100)] 
gh-117267: Ensure DirEntry.stat().st_ctime still contains creation time during deprecation period (GH-117354)

19 months agogh-114329: Fix PyList_GetItemRef() limited C API definition (#117520)
Victor Stinner [Wed, 3 Apr 2024 21:02:42 +0000 (23:02 +0200)] 
gh-114329: Fix PyList_GetItemRef() limited C API definition (#117520)

19 months agogh-113317: Argument Clinic: Add libclinic.clanguage (#117455)
Victor Stinner [Wed, 3 Apr 2024 18:17:51 +0000 (20:17 +0200)] 
gh-113317: Argument Clinic: Add libclinic.clanguage (#117455)

Add libclinic.clanguage module and move the following classes and
functions there:

* CLanguage
* declare_parser()

Add libclinic.codegen and move the following classes there:

* BlockPrinter
* BufferSeries
* Destination

Move the following functions to libclinic.function:

* permute_left_option_groups()
* permute_optional_groups()
* permute_right_option_groups()

19 months agogh-116168: Remove extra `_CHECK_STACK_SPACE` uops (#117242)
Peter Lazorchak [Wed, 3 Apr 2024 17:14:18 +0000 (10:14 -0700)] 
gh-116168: Remove extra `_CHECK_STACK_SPACE` uops (#117242)

This merges all `_CHECK_STACK_SPACE` uops in a trace into a single `_CHECK_STACK_SPACE_OPERAND` uop that checks whether there is enough stack space for all calls included in the entire trace.

19 months agogh-76785: Raise InterpreterError, Not RuntimeError (gh-117489)
Eric Snow [Wed, 3 Apr 2024 16:58:39 +0000 (10:58 -0600)] 
gh-76785: Raise InterpreterError, Not RuntimeError (gh-117489)

I had meant to switch everything to InterpreterError when I added it a while back.  At the time I missed a few key spots.

As part of this, I've added print-the-exception to _PyXI_InitTypes() and fixed an error case in `_PyStaticType_InitBuiltin().

19 months agogh-117431: Adapt str.find and friends to Argument Clinic (#117468)
Erlend E. Aasland [Wed, 3 Apr 2024 15:59:18 +0000 (17:59 +0200)] 
gh-117431: Adapt str.find and friends to Argument Clinic (#117468)

This change gives a significant speedup, as the METH_FASTCALL calling
convention is now used. The following methods are adapted:

- str.count
- str.find
- str.index
- str.rfind
- str.rindex

19 months agoGH-114847: Raise FileNotFoundError when getcwd() returns '(unreachable)' (#117481)
Barney Gale [Wed, 3 Apr 2024 15:39:40 +0000 (16:39 +0100)] 
GH-114847: Raise FileNotFoundError when getcwd() returns '(unreachable)' (#117481)

On Linux >= 2.6.36 with glibc < 2.27, `getcwd()` can return a relative
pathname starting with '(unreachable)'. We detect this and fail with
ENOENT, matching new glibc behaviour.

Co-authored-by: Petr Viktorin <encukou@gmail.com>
19 months agogh-117215 Make the fromskey() signature match dict.fromkeys(). (gh-117493)
Raymond Hettinger [Wed, 3 Apr 2024 15:08:18 +0000 (10:08 -0500)] 
gh-117215 Make the fromskey() signature match dict.fromkeys(). (gh-117493)

19 months agogh-59215: unittest: restore _top_level_dir at end of discovery (GH-15242)
Zackery Spytz [Wed, 3 Apr 2024 14:17:13 +0000 (07:17 -0700)] 
gh-59215: unittest: restore _top_level_dir at end of discovery (GH-15242)

19 months agogh-116303: Skip test module dependent tests if test modules are unavailable (#117341)
Erlend E. Aasland [Wed, 3 Apr 2024 13:11:36 +0000 (15:11 +0200)] 
gh-116303: Skip test module dependent tests if test modules are unavailable (#117341)

19 months agogh-117381: Improve error messages for ntpath.commonpath() (GH-117382)
Nice Zombies [Wed, 3 Apr 2024 13:10:09 +0000 (15:10 +0200)] 
gh-117381: Improve error messages for ntpath.commonpath() (GH-117382)

19 months agogh-117483: Accept "Broken pipe" as valid error message in `test_wrong_cert_tls13...
Sam Gross [Wed, 3 Apr 2024 12:29:02 +0000 (08:29 -0400)] 
gh-117483: Accept "Broken pipe" as valid error message in `test_wrong_cert_tls13` (GH-117484)

On macOS, the closed connection can lead to a "Broken pipe" error instead of
a "Connection reset by peer" error.

19 months agoGH-70647: Deprecate strptime day of month parsing without a year present to avoid...
Gregory P. Smith [Wed, 3 Apr 2024 12:19:49 +0000 (05:19 -0700)] 
GH-70647: Deprecate strptime day of month parsing without a year present to avoid leap-year bugs (GH-117107)

19 months agogh-117431: Adapt bytes and bytearray .startswith() and .endswith() to Argument Clinic...
Erlend E. Aasland [Wed, 3 Apr 2024 11:11:14 +0000 (13:11 +0200)] 
gh-117431: Adapt bytes and bytearray .startswith() and .endswith() to Argument Clinic (#117495)

This change gives a significant speedup, as the METH_FASTCALL calling
convention is now used.

19 months agogh-117431: Fix str.endswith docstring (#117499)
Erlend E. Aasland [Wed, 3 Apr 2024 10:33:20 +0000 (12:33 +0200)] 
gh-117431: Fix str.endswith docstring (#117499)

The first parameter is named 'suffix', not 'prefix'.

Regression introduced by commit 444156ed

19 months agogh-117281: Change weakref repr() to fully qualified name (#117285)
Victor Stinner [Wed, 3 Apr 2024 10:18:05 +0000 (12:18 +0200)] 
gh-117281: Change weakref repr() to fully qualified name (#117285)

Use the fully qualified type name in repr() of weakref.ref and
weakref.proxy types.

Fix a crash in proxy_repr() when the reference is dead.

Add also test_ref_repr() and test_proxy_repr().

19 months agogh-91565: Update issue tracker URL in error message. (#117450)
Ezio Melotti [Wed, 3 Apr 2024 08:43:52 +0000 (10:43 +0200)] 
gh-91565: Update issue tracker URL in error message. (#117450)

* Update issue tracker URL in commit message.

* Also update issue tracker URL in comment.

19 months agogh-117431: Adapt str.startswith and str.endswith to Argument Clinic (#117466)
Erlend E. Aasland [Wed, 3 Apr 2024 07:11:39 +0000 (09:11 +0200)] 
gh-117431: Adapt str.startswith and str.endswith to Argument Clinic (#117466)

This change gives a significant speedup, as the METH_FASTCALL calling
convention is now used.

19 months agogh-76785: Fix a Refleak in _interpreters.new_config() (gh-117491)
Eric Snow [Wed, 3 Apr 2024 01:10:26 +0000 (19:10 -0600)] 
gh-76785: Fix a Refleak in _interpreters.new_config() (gh-117491)

This is a follow-up to gh-117170 and gh-117485.

19 months agogh-76785: Consolidate Some Interpreter-related Testing Helpers (gh-117485)
Eric Snow [Tue, 2 Apr 2024 23:16:50 +0000 (17:16 -0600)] 
gh-76785: Consolidate Some Interpreter-related Testing Helpers (gh-117485)

This eliminates the duplication of functionally identical helpers in the _testinternalcapi and _xxsubinterpreters modules.

19 months agogh-76785: Add PyInterpreterConfig Helpers (gh-117170)
Eric Snow [Tue, 2 Apr 2024 20:35:52 +0000 (14:35 -0600)] 
gh-76785: Add PyInterpreterConfig Helpers (gh-117170)

These helpers make it easier to customize and inspect the config used to initialize interpreters.  This is especially valuable in our tests.  I found inspiration from the PyConfig API for the PyInterpreterConfig dict conversion stuff.  As part of this PR I've also added a bunch of tests.

19 months agogh-117349: Micro-optimize a few `os.path` functions (#117350)
Nice Zombies [Tue, 2 Apr 2024 20:32:35 +0000 (22:32 +0200)] 
gh-117349: Micro-optimize a few `os.path` functions (#117350)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Barney Gale <barney.gale@gmail.com>
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
19 months agoFix successor opcode name printing in Tier 2 DEOPT debug message (#117471)
Guido van Rossum [Tue, 2 Apr 2024 18:25:48 +0000 (11:25 -0700)] 
Fix successor opcode name printing in Tier 2 DEOPT debug message (#117471)

19 months agogh-112087: Make `list.extend(dict)` behave atomically (#117438)
Sam Gross [Tue, 2 Apr 2024 14:45:00 +0000 (10:45 -0400)] 
gh-112087: Make `list.extend(dict)` behave atomically (#117438)

Add a special case for `list.extend(dict)` and `list(dict)` so that those
patterns behave atomically with respect to modifications to the list or
dictionary.

This is required by multiprocessing, which assumes that
`list(_finalizer_registry)` is atomic.

19 months agogh-117440: Make `syslog` thread-safe in free-threaded builds (#117441)
Sam Gross [Tue, 2 Apr 2024 14:44:26 +0000 (10:44 -0400)] 
gh-117440: Make `syslog` thread-safe in free-threaded builds (#117441)

Use critical sections to protect access to the syslog module.

19 months agogh-117074: Update Traversable.joinpath docs to the 3.11+ protocol (GH-117113)
Petr Viktorin [Tue, 2 Apr 2024 14:08:16 +0000 (16:08 +0200)] 
gh-117074: Update Traversable.joinpath docs to the 3.11+ protocol (GH-117113)

19 months agogh-115538: Use pathlib to compare prefixes in test_venv (GH-117076)
AN Long [Tue, 2 Apr 2024 13:10:24 +0000 (21:10 +0800)] 
gh-115538: Use pathlib to compare prefixes in test_venv (GH-117076)

19 months agogh-113317: Argument Clinic: Add libclinic.return_converters (#117451)
Victor Stinner [Tue, 2 Apr 2024 11:29:39 +0000 (13:29 +0200)] 
gh-113317: Argument Clinic: Add libclinic.return_converters (#117451)

Move the following converter classes to libclinic.return_converters:

* CReturnConverter
* CReturnConverterAutoRegister
* Py_ssize_t_return_converter
* bool_return_converter
* double_return_converter
* float_return_converter
* int_return_converter
* long_return_converter
* size_t_return_converter
* unsigned_int_return_converter
* unsigned_long_return_converter

Move also the add_c_return_converter() function there.

19 months agoGH-115776: Embed the values array into the object, for "normal" Python objects. ...
Mark Shannon [Tue, 2 Apr 2024 10:59:21 +0000 (11:59 +0100)] 
GH-115776: Embed the values array into the object, for "normal" Python objects. (GH-116115)

19 months agogh-109120: Fix syntax error in handlinh of incorrect star expressions (#117444)
Grigoriev Semyon [Tue, 2 Apr 2024 10:42:58 +0000 (13:42 +0300)] 
gh-109120: Fix syntax error in handlinh of incorrect star expressions (#117444)

19 months agogh-117411: move PyFutureFeatures to pycore_symtable.h and make it private (#117412)
Irit Katriel [Tue, 2 Apr 2024 10:34:49 +0000 (11:34 +0100)] 
gh-117411: move PyFutureFeatures to pycore_symtable.h and make it private (#117412)

19 months agogh-113317: Argument Clinic: Add libclinic.converters module (#117315)
Victor Stinner [Tue, 2 Apr 2024 10:09:53 +0000 (12:09 +0200)] 
gh-113317: Argument Clinic: Add libclinic.converters module (#117315)

Move the following converter classes to libclinic.converters:

* PyByteArrayObject_converter
* PyBytesObject_converter
* Py_UNICODE_converter
* Py_buffer_converter
* Py_complex_converter
* Py_ssize_t_converter
* bool_converter
* byte_converter
* char_converter
* defining_class_converter
* double_converter
* fildes_converter
* float_converter
* int_converter
* long_converter
* long_long_converter
* object_converter
* self_converter
* short_converter
* size_t_converter
* slice_index_converter
* str_converter
* unicode_converter
* unsigned_char_converter
* unsigned_int_converter
* unsigned_long_converter
* unsigned_long_long_converter
* unsigned_short_converter

Move also the following classes to libclinic.converters:

* buffer
* robuffer
* rwbuffer

Move the following functions to libclinic.converters:

* correct_name_for_self()
* r()
* str_converter_key()

Move Null and NULL to libclinic.utils.

19 months agoDocs: specify XML document name in xml.etree.elementtree example (#24223) 113771/head
Moshe Kaplan [Mon, 1 Apr 2024 19:53:00 +0000 (15:53 -0400)] 
Docs: specify XML document name in xml.etree.elementtree example (#24223)

19 months agoDocs: add more links to PIPE in subprocess docs (#25416)
Matthew Davis [Mon, 1 Apr 2024 19:49:14 +0000 (21:49 +0200)] 
Docs: add more links to PIPE in subprocess docs (#25416)

19 months agoGH-117337: Deprecate `glob.glob0()` and `glob.glob1()`. (#117371)
Barney Gale [Mon, 1 Apr 2024 19:37:41 +0000 (20:37 +0100)] 
GH-117337: Deprecate `glob.glob0()` and `glob.glob1()`. (#117371)

These undocumented functions are no longer used by `msilib`, so there's no
reason to keep them around.

19 months agogh-77714: Provide an async iterator version of as_completed (GH-22491)
Justin Turner Arthur [Mon, 1 Apr 2024 17:07:29 +0000 (12:07 -0500)] 
gh-77714: Provide an async iterator version of as_completed (GH-22491)

* as_completed returns object that is both iterator and async iterator
* Existing tests adjusted to test both the old and new style
* New test to ensure iterator can be resumed
* New test to ensure async iterator yields any passed-in Futures as-is

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
19 months agoSilence compiler warnings in gc.c (#117422)
Guido van Rossum [Mon, 1 Apr 2024 16:13:38 +0000 (09:13 -0700)] 
Silence compiler warnings in gc.c (#117422)

19 months agogh-94808: Fix refcounting in PyObject_Print tests (GH-117421)
Petr Viktorin [Mon, 1 Apr 2024 15:01:22 +0000 (17:01 +0200)] 
gh-94808: Fix refcounting in PyObject_Print tests (GH-117421)

19 months agogh-117142: ctypes: Unify meta tp slot functions (GH-117143)
neonene [Mon, 1 Apr 2024 13:28:14 +0000 (22:28 +0900)] 
gh-117142: ctypes: Unify meta tp slot functions (GH-117143)

Integrates the following ctypes meta tp slot functions:
* `CDataType_traverse()` into `CType_Type_traverse()`.
* `CDataType_clear()` into `CType_Type_clear()`.
* `CDataType_dealloc()` into `CType_Type_dealloc()`.
* `CDataType_repeat()` into `CType_Type_repeat()`.

19 months agogh-91565: Replace bugs.python.org links with Devguide/GitHub ones (GH-91568)
Steve (Gadget) Barnes [Mon, 1 Apr 2024 13:02:07 +0000 (14:02 +0100)] 
gh-91565: Replace bugs.python.org links with Devguide/GitHub ones  (GH-91568)

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
19 months agogh-94808:Improve coverage of PyObject_Print (GH-98749)
MonadChains [Mon, 1 Apr 2024 12:52:25 +0000 (13:52 +0100)] 
gh-94808:Improve coverage of PyObject_Print (GH-98749)

19 months agoBump mypy from 1.8.0 to 1.9.0 in /Tools (#117418)
dependabot[bot] [Mon, 1 Apr 2024 11:14:37 +0000 (11:14 +0000)] 
Bump mypy from 1.8.0 to 1.9.0 in /Tools (#117418)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
19 months agobuild(deps-dev): bump types-psutil from 5.9.5.20240205 to 5.9.5.20240316 in /Tools...
dependabot[bot] [Mon, 1 Apr 2024 11:05:14 +0000 (11:05 +0000)] 
build(deps-dev): bump types-psutil from 5.9.5.20240205 to 5.9.5.20240316 in /Tools (#117417)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
19 months agobuild(deps-dev): bump types-setuptools from 69.1.0.20240301 to 69.2.0.20240317 in...
dependabot[bot] [Mon, 1 Apr 2024 10:38:38 +0000 (11:38 +0100)] 
build(deps-dev): bump types-setuptools from 69.1.0.20240301 to 69.2.0.20240317 in /Tools (#117419)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
19 months agobuild(deps): bump actions/add-to-project from 0.6.0 to 1.0.0 (#117415)
dependabot[bot] [Mon, 1 Apr 2024 09:54:33 +0000 (09:54 +0000)] 
build(deps): bump actions/add-to-project from 0.6.0 to 1.0.0 (#117415)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
19 months agoDoc: printf-style library/stdtype improvements (#16741)
Adorilson Bezerra [Sun, 31 Mar 2024 22:34:54 +0000 (23:34 +0100)] 
Doc: printf-style library/stdtype improvements (#16741)

19 months agogh-117387 Remove hash mark from introductory text (#117409)
Raymond Hettinger [Sun, 31 Mar 2024 21:09:22 +0000 (16:09 -0500)] 
gh-117387 Remove hash mark from introductory text (#117409)

19 months agogh-102190: Add additional zipfile `pwd=` arg docstrings (gh-102195)
Deborah [Sun, 31 Mar 2024 20:11:48 +0000 (22:11 +0200)] 
gh-102190: Add additional zipfile `pwd=` arg docstrings (gh-102195)

This just documents the parameter that already exists.

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
19 months agoLink to the Python type system specification (#117400)
Shantanu [Sun, 31 Mar 2024 19:02:48 +0000 (12:02 -0700)] 
Link to the Python type system specification (#117400)

19 months agoGH-114575: Rename `PurePath.pathmod` to `PurePath.parser` (#116513)
Barney Gale [Sun, 31 Mar 2024 18:14:48 +0000 (19:14 +0100)] 
GH-114575: Rename `PurePath.pathmod` to `PurePath.parser` (#116513)

And rename the private base class from `PathModuleBase` to `ParserBase`.

19 months agogh-117303: Don't detach in `PyThreadState_DeleteCurrent()` (#117304)
Sam Gross [Fri, 29 Mar 2024 22:58:08 +0000 (18:58 -0400)] 
gh-117303: Don't detach in `PyThreadState_DeleteCurrent()` (#117304)

This fixes a crash in `test_threading.test_reinit_tls_after_fork()` when
running with the GIL disabled. We already properly handle the case where
the thread state is `_Py_THREAD_ATTACHED` in `tstate_delete_common()` --
we just need to remove an assertion.

Keeping the thread attached means that a stop-the-world pause, such as
for a `fork()`, won't commence until we remove our thread state from the
interpreter's linked list. This prevents a crash when the child process
tries to clean up the dead thread states.

19 months agogh-116664: In _warnings.c, make filters_version access thread-safe (#117374)
Erlend E. Aasland [Fri, 29 Mar 2024 20:23:28 +0000 (21:23 +0100)] 
gh-116664: In _warnings.c, make filters_version access thread-safe (#117374)

- assert that the lock is held in already_warned()
- protect 'filters_version' increment in warnings_filters_mutated_impl()

19 months agogh-117348: Refactored RawConfigParser._read for similicity and comprehensibility...
Jason R. Coombs [Fri, 29 Mar 2024 20:06:09 +0000 (16:06 -0400)] 
gh-117348: Refactored RawConfigParser._read for similicity and comprehensibility (#117372)

* Extract method for _read_inner, reducing complexity and indentation by 1.

* Extract method for _raise_all and yield ParseErrors from _read_inner.

Reduces complexity by 1 and reduces touch points for handling errors in _read_inner.

* Prefer iterators to splat expansion and literal indexing.

* Extract method for _strip_comments. Reduces complexity by 7.

* Model the file lines in a class to encapsulate the comment status and cleaned value.

* Encapsulate the read state as a dataclass

* Extract _handle_continuation_line and _handle_rest methods. Reduces complexity by 8.

* Reindent

* At least for now, collect errors in the ReadState

* Check for missing section header separately.

* Extract methods for _handle_header and _handle_option. Reduces complexity by 6.

* Remove unreachable code. Reduces complexity by 4.

* Remove unreachable branch

* Handle error condition early. Reduces complexity by 1.

* Add blurb

* Move _raise_all to ParsingError, as its behavior is most closely related to the exception class and not the reader.

* Split _strip* into separate methods.

* Refactor _strip_full to compute the strip just once and use 'not any' to determine the factor.

* Replace use of 'sys.maxsize' with direct computation of the stripped value.

* Extract has_comments as a dynamic property.

* Implement clean as a cached property.

* Model comment prefixes in the RawConfigParser within a prefixes namespace.

* Use a regular expression to search for the first match.

Avoids mutating variables and tricky logic and over-computing all of the starts when only the first is relevant.

19 months agogh-117300: Use stop the world to make `sys._current_frames` and `sys._current_excepti...
Sam Gross [Fri, 29 Mar 2024 19:33:06 +0000 (15:33 -0400)] 
gh-117300: Use stop the world to make `sys._current_frames` and `sys._current_exceptions` thread-safe. (#117301)

This adds a stop the world pause to make the two functions thread-safe
when the GIL is disabled in the free-threaded build.

Additionally, the main test thread may call `sys._current_exceptions()` as
soon as `g_raised.set()` is called. The background thread may not yet reach
the `leave_g.wait()` line.

19 months agoFix broken format in error for bad input in summarize_stats.py (#117375)
Guido van Rossum [Fri, 29 Mar 2024 18:31:09 +0000 (11:31 -0700)] 
Fix broken format in error for bad input in summarize_stats.py (#117375)

When you pass the script a non-existent input file, you get a TypeError instead of the intended ValueError.

19 months agogh-111926: Avoid locking in PyType_IsSubtype (#117275)
mpage [Fri, 29 Mar 2024 17:42:02 +0000 (10:42 -0700)] 
gh-111926: Avoid locking in PyType_IsSubtype (#117275)

Read the MRO in a thread-unsafe way in `PyType_IsSubtype` to avoid locking. Fixing this is tracked in #117306.

The motivation for this change is in support of making weakrefs thread-safe in free-threaded builds:

`WeakValueDictionary` uses a special dictionary function, `_PyDict_DelItemIf`
to remove dead weakrefs from the dictionary. `_PyDict_DelItemIf` removes a key
if a user supplied predicate evaluates to true for the value associated with
the key. Crucially for the `WeakValueDictionary` use case, the predicate
evaluation + deletion sequence is atomic, provided that the predicate doesn’t
suspend. The predicate used by `WeakValueDictionary` includes a subtype check,
which we must ensure doesn't suspend in free-threaded builds.

19 months agogh-117323: Make `cell` thread-safe in free-threaded builds (#117330)
Sam Gross [Fri, 29 Mar 2024 17:35:43 +0000 (13:35 -0400)] 
gh-117323: Make `cell` thread-safe in free-threaded builds (#117330)

Use critical sections to lock around accesses to cell contents. The critical sections are no-ops in the default (with GIL) build.

19 months agogh-117344: Skip flaky tests in free-threaded build (#117355)
Sam Gross [Fri, 29 Mar 2024 17:34:04 +0000 (13:34 -0400)] 
gh-117344: Skip flaky tests in free-threaded build (#117355)

The tests are not reliable with the GIL disabled. In theory, they can
fail with the GIL enabled too, but the failures are much more likely
with the GIL disabled.

19 months agogh-112529: Don't untrack tuples or dicts with zero refcount (#117370)
Sam Gross [Fri, 29 Mar 2024 17:33:04 +0000 (13:33 -0400)] 
gh-112529: Don't untrack tuples or dicts with zero refcount (#117370)

The free-threaded GC sometimes sees objects with zero refcount. This can
happen due to the delay in merging biased reference counting fields,
and, in the future, due to deferred reference counting. We should not
untrack these objects or they will never be collected.

This fixes the refleaks in the free-threaded build.