]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
17 months agogh-120056: Add `IP_RECVERR`, `IP_RECVORIGDSTADDR`, `IP_RECVTTL` to `socket` module...
Nikita Sobolev [Wed, 12 Jun 2024 01:00:56 +0000 (04:00 +0300)] 
gh-120056: Add `IP_RECVERR`, `IP_RECVORIGDSTADDR`, `IP_RECVTTL` to `socket` module (#120058)

* gh-120056: Add `IP_RECVERR` and `IP_RECVTTL` to `socket` module

* Fix news

* Address review

* Update NEWS

17 months agogh-120221: Deliver real singals on Ctrl-C and Ctrl-Z in the new REPL (#120354)
Pablo Galindo Salgado [Tue, 11 Jun 2024 19:20:25 +0000 (20:20 +0100)] 
gh-120221: Deliver real singals on Ctrl-C and Ctrl-Z in the new REPL (#120354)

17 months agogh-120198: Fix race condition when editing __class__ with an audit hook active (GH...
Ken Jin [Tue, 11 Jun 2024 19:10:23 +0000 (03:10 +0800)] 
gh-120198: Fix race condition when editing __class__ with an audit hook active (GH-120195)

17 months agogh-120326: Include <intrin.h> on Windows with Free Threading (#120329)
Kirill Podoprigora [Tue, 11 Jun 2024 17:50:21 +0000 (20:50 +0300)] 
gh-120326: Include <intrin.h> on Windows with Free Threading (#120329)

17 months agogh-118908: Limit exposed globals from internal imports and definitions on new REPL...
Eugene Triguba [Tue, 11 Jun 2024 17:40:31 +0000 (13:40 -0400)] 
gh-118908: Limit exposed globals from internal imports and definitions on new REPL startup (#119547)

17 months agoFix typo in ElementTree docs (#120342)
naglis [Tue, 11 Jun 2024 17:01:48 +0000 (20:01 +0300)] 
Fix typo in ElementTree docs (#120342)

17 months agogh-120343: Do not reset byte_col_offset_diff after multiline tokens (#120352)
Lysandros Nikolaou [Tue, 11 Jun 2024 17:00:53 +0000 (19:00 +0200)] 
gh-120343: Do not reset byte_col_offset_diff after multiline tokens (#120352)

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
17 months agogh-119517: Fixes for pasting in pyrepl (#120253)
Matt Wozniski [Tue, 11 Jun 2024 16:42:10 +0000 (12:42 -0400)] 
gh-119517: Fixes for pasting in pyrepl (#120253)

* Remove pyrepl's optimization for self-insert

This will be replaced by a less specialized optimization.

* Use line-buffering when pyrepl echoes pastes

Previously echoing was totally suppressed until the entire command had
been pasted and the terminal ended paste mode, but this gives the user
no feedback to indicate that an operation is in progress. Drawing
something to the screen once per line strikes a balance between
perceived responsiveness and performance.

* Remove dead code from pyrepl

`msg_at_bottom` is always true.

* Speed up pyrepl's screen rendering computation

The Reader in pyrepl doesn't hold a complete representation of the
screen area being drawn as persistent state. Instead, it recomputes it,
on each keypress. This is fast enough for a few hundred bytes, but
incredibly slow as the input buffer grows into the kilobytes (likely
because of pasting).

Rather than making some expensive and expansive changes to the repl's
internal representation of the screen, add some caching: remember some
data from one refresh to the next about what was drawn to the screen
and, if we don't find anything that has invalidated the results that
were computed last time around, reuse them. To keep this caching as
simple as possible, all we'll do is look for lines in the buffer that
were above the cursor the last time we were asked to update the screen,
and that are still above the cursor now. We assume that nothing can
affect a line that comes before both the old and new cursor location
without us being informed. Based on this assumption, we can reuse old
lines, which drastically speeds up the overwhelmingly common case where
the user is typing near the end of the buffer.

* Speed up pyrepl prompt drawing

Cache the `can_colorize()` call rather than repeatedly recomputing it.
This call looks up an environment variable, and is called once per
character typed at the REPL. The environment variable lookup shows up as
a hot spot when profiling, and we don't expect this to change while the
REPL is running.

* Speed up pasting multiple lines into the REPL

Previously, we were checking whether the command should be accepted each
time a line break was encountered, but that's not the expected behavior.
In bracketed paste mode, we expect everything pasted to be part of
a single block of code, and encountering a newline shouldn't behave like
a user pressing <Enter> to execute a command. The user should always
have a chance to review the pasted command before running it.

* Use a read buffer for input in pyrepl

Previously we were reading one byte at a time, which causes much slower
IO than necessary. Instead, read in chunks, processing previously read
data before asking for more.

* Optimize finding width of a single character

`wlen` finds the width of a multi-character string by adding up the
width of each character, and then subtracting the width of any escape
sequences. It's often called for single character strings, however,
which can't possibly contain escape sequences. Optimize for that case.

* Optimize disp_str for ASCII characters

Since every ASCII character is known to display as single width, we can
avoid not only the Unicode data lookup in `disp_str` but also the one
hidden in `str_width` for them.

* Speed up cursor movements in long pyrepl commands

When the current pyrepl command buffer contains many lines, scrolling up
becomes slow. We have optimizations in place to reuse lines above the
cursor position from one refresh to the next, but don't currently try to
reuse lines below the cursor position in the same way, so we wind up
with quadratic behavior where all lines of the buffer below the cursor
are recomputed each time the cursor moves up another line.

Optimize this by only computing one screen's worth of lines beyond the
cursor position. Any lines beyond that can't possibly be shown by the
console, and bounding this makes scrolling up have linear time
complexity instead.

---------

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
17 months agogh-120346: Respect PYTHON_BASIC_REPL when running in interactive inspect mode (#120349)
Pablo Galindo Salgado [Tue, 11 Jun 2024 16:15:01 +0000 (17:15 +0100)] 
gh-120346: Respect PYTHON_BASIC_REPL when running in interactive inspect mode (#120349)

17 months agogh-119180: PEP 649 compiler changes (#119361)
Jelle Zijlstra [Tue, 11 Jun 2024 13:06:49 +0000 (07:06 -0600)] 
gh-119180: PEP 649 compiler changes (#119361)

17 months agogh-120080: Mark test_round_with_none_arg_direct_call as cpython_only (#120328)
Kirill Podoprigora [Tue, 11 Jun 2024 07:56:38 +0000 (10:56 +0300)] 
gh-120080: Mark test_round_with_none_arg_direct_call as cpython_only (#120328)

17 months agogh-120291: Fix a bashism in python-config.sh.in (#120292)
Michał Górny [Tue, 11 Jun 2024 07:11:13 +0000 (09:11 +0200)] 
gh-120291: Fix a bashism in python-config.sh.in (#120292)

gh-120291: Fix bashisms in python-config.sh.in

Replace the use of bash-specific `[[ ... ]]` with POSIX-compliant
`[ ... ]` to make the `python-config` shell script work with non-bash
shells again.  While at it, use `local` in a safer way, since it is
not in POSIX either (though universally supported).

Fixes #120291

17 months agogh-120298: Fix use-after-free in `list_richcompare_impl` (#120303)
Nikita Sobolev [Tue, 11 Jun 2024 07:04:27 +0000 (10:04 +0300)] 
gh-120298: Fix use-after-free in `list_richcompare_impl` (#120303)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
17 months agogh-65454: avoid triggering call to a PropertyMock in NonCallableMock.__setattr__...
blhsing [Tue, 11 Jun 2024 05:42:49 +0000 (13:42 +0800)] 
gh-65454: avoid triggering call to a PropertyMock in NonCallableMock.__setattr__ (#120019)

17 months agogh-119600: mock: do not access attributes of original when new_callable is set (...
Robert Collins [Tue, 11 Jun 2024 05:41:12 +0000 (07:41 +0200)] 
gh-119600: mock: do not access attributes of original when new_callable is set (#119601)

In order to patch flask.g e.g. as in #84982, that
proxies getattr must not be invoked. For that,
mock must not try to read from the original
object. In some cases that is unavoidable, e.g.
when doing autospec. However, patch("flask.g",
new_callable=MagicMock) should be entirely safe.

17 months agoFix the CODEOWNERS for _interpretersmodule.c (gh-120288)
AN Long [Mon, 10 Jun 2024 16:45:16 +0000 (00:45 +0800)] 
Fix the CODEOWNERS for _interpretersmodule.c (gh-120288)

17 months agogh-120057: Add os.environ.refresh() method (#120059)
Victor Stinner [Mon, 10 Jun 2024 16:34:17 +0000 (18:34 +0200)] 
gh-120057: Add os.environ.refresh() method (#120059)

17 months agogh-119786: copy compiler doc from devguide to InternalDocs and convert to markdown...
Irit Katriel [Mon, 10 Jun 2024 15:15:12 +0000 (16:15 +0100)] 
gh-119786: copy compiler doc from devguide to InternalDocs and convert to markdown (#120134)

* gh-119876: move compiler doc from devguide to InternalDocs

Copy of https://github.com/python/devguide/commit/78fc0d7aa9fd0d6733d10c23b178b2a0e2799afc

Co-Authored-By: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-Authored-By: Adam Turner <9087854+aa-turner@users.noreply.github.com>
Co-Authored-By: Brett Cannon <brett@python.org>
Co-Authored-By: Carol Willing <carolcode@willingconsulting.com>
Co-Authored-By: Daniel Porteous <danielporteous1@gmail.com>
Co-Authored-By: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
Co-Authored-By: Éric Araujo <merwok@netwok.org>
Co-Authored-By: Erlend Egeberg Aasland <erlend.aasland@innova.no>
Co-Authored-By: Ezio Melotti <ezio.melotti@gmail.com>
Co-Authored-By: Georg Brandl <georg@python.org>
Co-Authored-By: Guido van Rossum <guido@python.org>
Co-Authored-By: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-Authored-By: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Co-Authored-By: Jeff Allen <ja.py@farowl.co.uk>
Co-Authored-By: Jim Fasarakis-Hilliard <d.f.hilliard@gmail.com>
Co-Authored-By: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Co-Authored-By: Lincoln <71312724+Lincoln-developer@users.noreply.github.com>
Co-Authored-By: Mariatta <Mariatta@users.noreply.github.com>
Co-Authored-By: Muhammad Mahad <mahadpy@gmail.com>
Co-Authored-By: Ned Deily <nad@acm.org>
Co-Authored-By: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com>
Co-Authored-By: Stéphane Wirtel <stephane@wirtel.be>
Co-Authored-By: Suriyaa ✌️️ <isc.suriyaa@gmail.com>
Co-Authored-By: Zachary Ware <zachary.ware@gmail.com>
Co-Authored-By: psyker156 <242220+psyker156@users.noreply.github.com>
Co-Authored-By: slateny <46876382+slateny@users.noreply.github.com>
Co-Authored-By: svelankar <17737361+svelankar@users.noreply.github.com>
Co-Authored-By: zikcheng <surfingbyte@gmail.com>
* convert to markdown

* add to index

* update more of the out of date stuff

---------

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Brett Cannon <brett@python.org>
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
Co-authored-by: Daniel Porteous <danielporteous1@gmail.com>
Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
Co-authored-by: Éric Araujo <merwok@netwok.org>
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
Co-authored-by: Georg Brandl <georg@python.org>
Co-authored-by: Guido van Rossum <guido@python.org>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-authored-by: Jeff Allen <ja.py@farowl.co.uk>
Co-authored-by: Jim Fasarakis-Hilliard <d.f.hilliard@gmail.com>
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Co-authored-by: Lincoln <71312724+Lincoln-developer@users.noreply.github.com>
Co-authored-by: Mariatta <Mariatta@users.noreply.github.com>
Co-authored-by: Muhammad Mahad <mahadpy@gmail.com>
Co-authored-by: Ned Deily <nad@acm.org>
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Stéphane Wirtel <stephane@wirtel.be>
Co-authored-by: Suriyaa ✌️️ <isc.suriyaa@gmail.com>
Co-authored-by: Zachary Ware <zachary.ware@gmail.com>
Co-authored-by: psyker156 <242220+psyker156@users.noreply.github.com>
Co-authored-by: slateny <46876382+slateny@users.noreply.github.com>
Co-authored-by: svelankar <17737361+svelankar@users.noreply.github.com>
Co-authored-by: zikcheng <surfingbyte@gmail.com>
17 months agogh-115801: Only allow sequence of strings as input for difflib.unified_diff (GH-118333)
Pieter Eendebak [Mon, 10 Jun 2024 11:06:18 +0000 (13:06 +0200)] 
gh-115801: Only allow sequence of strings as input for difflib.unified_diff (GH-118333)

17 months agogh-120155: Fix Coverity issue in zoneinfo load_data() (#120232)
Victor Stinner [Mon, 10 Jun 2024 09:54:35 +0000 (11:54 +0200)] 
gh-120155: Fix Coverity issue in zoneinfo load_data() (#120232)

Declare the 'rv' varaible at the top of the load_data() function to
make sure that it's initialized before the first 'goto error' which
uses 'rv' (return rv).

Fix the Coverity issue:

Error: UNINIT (CWE-457):
Python-3.12.2/Modules/_zoneinfo.c:1233:5: skipped_decl: Jumping over declaration of ""rv"".
Python-3.12.2/Modules/_zoneinfo.c:1284:5: uninit_use: Using uninitialized value ""rv"".
  1282|       }
  1283|
  1284|->     return rv;
  1285|   }
  1286|

17 months agobpo-24766: doc= argument to subclasses of property not handled correctly (GH-2487)
E. M. Bray [Mon, 10 Jun 2024 08:55:49 +0000 (10:55 +0200)] 
bpo-24766: doc= argument to subclasses of property not handled correctly (GH-2487)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
17 months agogh-120296: Fix format string of fcntl.ioctl() audit (#120301)
Clinton [Mon, 10 Jun 2024 08:17:50 +0000 (04:17 -0400)] 
gh-120296: Fix format string of fcntl.ioctl() audit (#120301)

17 months agogh-119666: fix multiple class-scope comprehensions referencing __class__ (#120295)
Carl Meyer [Mon, 10 Jun 2024 02:23:30 +0000 (22:23 -0400)] 
gh-119666: fix multiple class-scope comprehensions referencing __class__ (#120295)

17 months agogh-120268: Prohibit passing ``None`` to ``_pydatetime.date.fromtimestamp`` (#120269)
Kirill Podoprigora [Sat, 8 Jun 2024 20:45:57 +0000 (23:45 +0300)] 
gh-120268: Prohibit passing ``None`` to ``_pydatetime.date.fromtimestamp`` (#120269)

This makes the pure Python implementation consistent with the C implementation.

17 months agogh-120276: Fix incorrect email.header.Header maxlinelen default (GH-120277)
Clinton [Sat, 8 Jun 2024 17:18:58 +0000 (13:18 -0400)] 
gh-120276: Fix incorrect email.header.Header maxlinelen default (GH-120277)

17 months agogh-120121: Add InvalidStateError to concurrent.futures.__all__ (#120123)
AN Long [Sat, 8 Jun 2024 16:11:19 +0000 (00:11 +0800)] 
gh-120121: Add InvalidStateError to concurrent.futures.__all__ (#120123)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
17 months agogh-120244: Fix re.sub() reference leak (GH-120245)
neonene [Sat, 8 Jun 2024 10:22:07 +0000 (19:22 +0900)] 
gh-120244: Fix re.sub() reference leak (GH-120245)

17 months agogh-119258: Eliminate Type Guards in Tier 2 Optimizer with Watcher (GH-119365)
Saul Shanabrook [Sat, 8 Jun 2024 09:41:45 +0000 (05:41 -0400)] 
gh-119258: Eliminate Type Guards in Tier 2 Optimizer with Watcher (GH-119365)

Co-authored-by: parmeggiani <parmeggiani@spaziodati.eu>
Co-authored-by: dpdani <git@danieleparmeggiani.me>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
Co-authored-by: Ken Jin <kenjin@python.org>
17 months agobpo-37755: Use configured output in pydoc instead of pager (GH-15105)
Enrico Tröger [Sat, 8 Jun 2024 09:19:13 +0000 (11:19 +0200)] 
bpo-37755: Use configured output in pydoc instead of pager (GH-15105)

If the Helper() class was initialized with an output, the topics, keywords
and symbols help still use the pager instead of the output.
Change the behavior so  the output is used if available while keeping the
previous behavior if no output was configured.

17 months agogh-120242: Fix handling of `[setUp,tearDown]Class` in `test_datetime` (#120243)
Nikita Sobolev [Sat, 8 Jun 2024 07:51:09 +0000 (10:51 +0300)] 
gh-120242: Fix handling of `[setUp,tearDown]Class` in `test_datetime` (#120243)

17 months agogh-120225: fix crash in compiler on empty block at end of exception handler (#120235)
Irit Katriel [Fri, 7 Jun 2024 21:37:35 +0000 (22:37 +0100)] 
gh-120225: fix crash in compiler on empty block at end of exception handler (#120235)

17 months agogh-119659: Get the datetime CAPI Tests Running Again (gh-120180)
Eric Snow [Fri, 7 Jun 2024 17:44:56 +0000 (13:44 -0400)] 
gh-119659: Get the datetime CAPI Tests Running Again (gh-120180)

The tests were accidentally disabled by 2da0dc0, which didn't handle classes correctly.

I considered updating no_rerun() to support classes, but the way test_datetime.py works would have made things fairly messy.  Plus, it looks like the refleaks we had encountered before have been resolved.

17 months agoGH-116380: Move pathlib-specific code from `glob` to `pathlib._abc`. (#120011)
Barney Gale [Fri, 7 Jun 2024 16:59:34 +0000 (17:59 +0100)] 
GH-116380: Move pathlib-specific code from `glob` to `pathlib._abc`. (#120011)

In `glob._Globber`, move pathlib-specific methods to `pathlib._abc.PathGlobber` and replace them with abstract methods. Rename `glob._Globber` to `glob._GlobberBase`. As a result, the `glob` module is no longer befouled by code that can only ever apply to pathlib.

No change of behaviour.

17 months agogh-120155: Fix copy/paste error in HAVE_SUBOFFSETS_IN_LAST_DIM() (#120228)
Victor Stinner [Fri, 7 Jun 2024 15:58:21 +0000 (17:58 +0200)] 
gh-120155: Fix copy/paste error in HAVE_SUBOFFSETS_IN_LAST_DIM() (#120228)

Don't hardcode 'dest' in HAVE_SUBOFFSETS_IN_LAST_DIM() macro of
memoryobject.c, but use its 'view' parameter instead.

Fix the Coverity issue:

Error: COPY_PASTE_ERROR (CWE-398):
Python-3.12.2/Objects/memoryobject.c:273:14: original: ""dest->suboffsets + (dest->ndim - 1)"" looks like the original copy.
Python-3.12.2/Objects/memoryobject.c:274:14: copy_paste_error: ""dest"" in ""src->suboffsets + (dest->ndim - 1)"" looks like a copy-paste error.
Python-3.12.2/Objects/memoryobject.c:274:14: remediation: Should it say ""src"" instead?
#  272|       assert(dest->ndim > 0 && src->ndim > 0);
#  273|       return (!HAVE_SUBOFFSETS_IN_LAST_DIM(dest) &&
#  274|->             !HAVE_SUBOFFSETS_IN_LAST_DIM(src) &&
#  275|               dest->strides[dest->ndim-1] == dest->itemsize &&
#  276|               src->strides[src->ndim-1] == src->itemsize);

17 months agogh-120226: Fix test_sendfile_close_peer_in_the_middle_of_receiving on Linux >= 6...
Xi Ruoyao [Fri, 7 Jun 2024 15:51:32 +0000 (23:51 +0800)] 
gh-120226: Fix test_sendfile_close_peer_in_the_middle_of_receiving on Linux >= 6.10 (#120227)

The worst case is that the kernel buffers 17 pages with a page size of 64k.

17 months agogh-120200: Fix `inspect.iscoroutinefunction(inspect) is True` corner case (#120214)
Nikita Sobolev [Fri, 7 Jun 2024 15:48:31 +0000 (18:48 +0300)] 
gh-120200: Fix `inspect.iscoroutinefunction(inspect) is True` corner case (#120214)

17 months agogh-114264: Optimize performance of copy.deepcopy by adding a fast path for atomic...
Pieter Eendebak [Fri, 7 Jun 2024 15:42:01 +0000 (17:42 +0200)] 
gh-114264: Optimize performance of copy.deepcopy by adding a fast path for atomic types (GH-114266)

17 months agogh-110383: Improve 'old string formatting' text in tutorial (#120219)
Erlend E. Aasland [Fri, 7 Jun 2024 13:37:18 +0000 (15:37 +0200)] 
gh-110383: Improve 'old string formatting' text in tutorial (#120219)

17 months agogh-93691: fix too broad source locations of with-statement instructions (#120125)
Irit Katriel [Fri, 7 Jun 2024 13:06:24 +0000 (14:06 +0100)] 
gh-93691: fix too broad source locations of with-statement instructions (#120125)

17 months agogh-120211: Fix tkinter.ttk with Tcl/Tk 9.0 (GH-120213)
Serhiy Storchaka [Fri, 7 Jun 2024 10:49:07 +0000 (13:49 +0300)] 
gh-120211: Fix tkinter.ttk with Tcl/Tk 9.0 (GH-120213)

* Use new methods for tracing Tcl variable.
* Fix Combobox.current() for empty combobox.

17 months agogh-110383: Clarify "non-integral" wording in pow() docs (#119688)
Aditya Borikar [Fri, 7 Jun 2024 09:44:42 +0000 (03:44 -0600)] 
gh-110383: Clarify "non-integral" wording in pow() docs (#119688)

17 months agogh-120164: Fix test_os.test_win32_mkdir_700() (#120177)
Kirill Podoprigora [Fri, 7 Jun 2024 09:14:13 +0000 (12:14 +0300)] 
gh-120164: Fix test_os.test_win32_mkdir_700() (#120177)

Don't compare the path to avoid encoding issues.

Co-authored-by: Eryk Sun <eryksun@gmail.com>
17 months agogh-120154: Fix Emscripten/WASI pattern in case statement for LDSHARED (#120173)
Michael Allwright [Fri, 7 Jun 2024 08:38:15 +0000 (10:38 +0200)] 
gh-120154: Fix Emscripten/WASI pattern in case statement for LDSHARED (#120173)

Fix Emscripten/WASI pattern in case statement for LDSHARED

17 months agoFix typos in comments (#120188)
Xie Yanbo [Fri, 7 Jun 2024 08:19:41 +0000 (16:19 +0800)] 
Fix typos in comments (#120188)

17 months agogh-120080: Accept ``None`` as a valid argument for direct call of the ``int.__round__...
Kirill Podoprigora [Fri, 7 Jun 2024 08:03:28 +0000 (11:03 +0300)] 
gh-120080: Accept ``None`` as a valid argument for direct call of the ``int.__round__`` (#120088)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
17 months agogh-120157: Remove unused code in concurrent.future (gh-120187)
Clinton [Fri, 7 Jun 2024 07:39:19 +0000 (03:39 -0400)] 
gh-120157: Remove unused code in concurrent.future (gh-120187)

17 months agoAdd Plausible for docs metrics (#119977)
Hugo van Kemenade [Fri, 7 Jun 2024 06:38:31 +0000 (00:38 -0600)] 
Add Plausible for docs metrics (#119977)

Co-authored-by: Julien Palard <julien@palard.fr>
17 months agogh-119577: Adjust DeprecationWarning when testing element truth values in ElementTree...
Jacob Walls [Fri, 7 Jun 2024 03:18:30 +0000 (23:18 -0400)] 
gh-119577: Adjust DeprecationWarning when testing element truth values in ElementTree (GH-119762)

Adjust DeprecationWarning when testing element truth values in ElementTree, we're planning to go with the more natural True return rather than a disruptive harder to code around exception raise, and are deferring the behavior change for a few more releases.

17 months agoGH-119054: Add "Reading directories" section to pathlib docs (#119956)
Barney Gale [Thu, 6 Jun 2024 23:27:39 +0000 (00:27 +0100)] 
GH-119054: Add "Reading directories" section to pathlib docs (#119956)

Add a dedicated subsection for `Path.iterdir()`-related methods,
specifically `iterdir()`, `glob()`, `rglob()` and `walk()`.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
17 months agogh-120178: Documentation typo corrections (#120179)
David Lowry-Duda [Thu, 6 Jun 2024 21:35:24 +0000 (17:35 -0400)] 
gh-120178: Documentation typo corrections (#120179)

17 months agogh-117657: Fix TSAN race involving import lock (#118523)
Sam Gross [Thu, 6 Jun 2024 17:40:58 +0000 (13:40 -0400)] 
gh-117657: Fix TSAN race involving import lock (#118523)

This adds a `_PyRecursiveMutex` type based on `PyMutex` and uses that
for the import lock. This fixes some data races in the free-threaded
build and generally simplifies the import lock code.

17 months agoAdd Tian Gao to CODEOWNERS and ACKS (GH-120166)
Tian Gao [Thu, 6 Jun 2024 17:20:37 +0000 (10:20 -0700)] 
Add Tian Gao to CODEOWNERS and ACKS (GH-120166)

17 months agoRestore decimal context after decimal doctests (GH-120149)
Serhiy Storchaka [Thu, 6 Jun 2024 17:12:32 +0000 (20:12 +0300)] 
Restore decimal context after decimal doctests (GH-120149)

The modified context caused tests failures in several other tests.

17 months agoCODEOWNERS: Add myself to symtable and AST (#120139)
Jelle Zijlstra [Thu, 6 Jun 2024 16:25:05 +0000 (09:25 -0700)] 
CODEOWNERS: Add myself to symtable and AST (#120139)

Co-authored-by: Carl Meyer <carl@oddbird.net>
17 months agogh-120155: Initialize variables in _tkinter.c (#120156)
Victor Stinner [Thu, 6 Jun 2024 15:31:33 +0000 (17:31 +0200)] 
gh-120155: Initialize variables in _tkinter.c (#120156)

Initialize variables in _tkinter.c to make static analyzers happy.

17 months agogh-119679: Fix layout of PYD and DLL files on Windows when using PC/layout script...
Steve Dower [Thu, 6 Jun 2024 15:11:42 +0000 (16:11 +0100)] 
gh-119679: Fix layout of PYD and DLL files on Windows when using PC/layout script (GH-120133)

17 months agogh-120111: Don't use cirrus M1 macOS runners on fork (#120116)
Nice Zombies [Thu, 6 Jun 2024 11:40:37 +0000 (13:40 +0200)] 
gh-120111: Don't use cirrus M1 macOS runners on fork (#120116)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
17 months agogh-119786: move adaptive interpreter doc from Python to InternalsDoc (#120137)
Irit Katriel [Thu, 6 Jun 2024 10:56:58 +0000 (11:56 +0100)] 
gh-119786: move adaptive interpreter doc from Python to InternalsDoc (#120137)

17 months agogh-120128: fix description of argument to ipaddress.collapse_addresses() (#120131)
Jan Kaliszewski [Wed, 5 Jun 2024 21:52:40 +0000 (23:52 +0200)] 
gh-120128: fix description of argument to ipaddress.collapse_addresses() (#120131)

The argument to collapse_addresses() is now described as an *iterable*
(rather than *iterator*).

17 months agopathlib ABCs: remove duplicate `realpath()` implementation. (#119178)
Barney Gale [Wed, 5 Jun 2024 17:54:50 +0000 (18:54 +0100)] 
pathlib ABCs: remove duplicate `realpath()` implementation. (#119178)

Add private `posixpath._realpath()` function, which is a generic version of `realpath()` that can be parameterised with string tokens (`sep`, `curdir`, `pardir`) and query functions (`getcwd`, `lstat`, `readlink`). Also add support for limiting the number of symlink traversals.

In the private `pathlib._abc.PathBase` class, call `posixpath._realpath()` and remove our re-implementation of the same algorithm.

No change to any public APIs, either in `posixpath` or `pathlib`.

Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
17 months agogh-115225: Raise error on unsupported ISO 8601 time strings (#119339)
benchatt [Wed, 5 Jun 2024 17:35:40 +0000 (10:35 -0700)] 
gh-115225: Raise error on unsupported ISO 8601 time strings (#119339)

Some time strings that contain fractional hours or minutes are permitted
by ISO 8601, but such strings are very unlikely to be intentional. The
current parser does not parse such strings correctly or raise an error.
This change raises a ValueError when hours or minutes contain a decimal mark.

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
17 months agogh-119786: add links to code in exception handling doc (#120077)
Irit Katriel [Wed, 5 Jun 2024 15:28:47 +0000 (16:28 +0100)] 
gh-119786: add links to code in exception handling doc (#120077)

17 months agogh-120065: Increase `collect_in_thread` period to 5 ms. (#120068)
Sam Gross [Wed, 5 Jun 2024 13:23:29 +0000 (09:23 -0400)] 
gh-120065: Increase `collect_in_thread` period to 5 ms. (#120068)

This matches the default GIL switch interval. It greatly speeds up the
free-threaded build: previously, it spent nearly all its time in
`gc.collect()`.

17 months agogh-119287: clarify doc on BaseExceptionGroup.derive and link to it from contextlib...
Irit Katriel [Wed, 5 Jun 2024 11:56:01 +0000 (12:56 +0100)] 
gh-119287: clarify doc on BaseExceptionGroup.derive and link to it from contextlib.suppress (#119657)

17 months agogh-119819: Update logging configuration to support joinable multiproc… (GH-120090)
Vinay Sajip [Wed, 5 Jun 2024 06:25:47 +0000 (07:25 +0100)] 
gh-119819: Update logging configuration to support joinable multiproc… (GH-120090)

gh-119819: Update logging configuration to support joinable multiprocessing manager queues.

17 months agogh-120078: Fix struct_time attr typo tm_day -> tm_mday in Doc/library/time.rst (GH...
shurj0 [Wed, 5 Jun 2024 00:23:12 +0000 (06:23 +0600)] 
gh-120078: Fix struct_time attr typo tm_day -> tm_mday in Doc/library/time.rst (GH-120081)

17 months agogh-114616: Improve docs regarding changes to caches representation in dis (#120033)
Irit Katriel [Tue, 4 Jun 2024 23:00:02 +0000 (00:00 +0100)] 
gh-114616: Improve docs regarding changes to caches representation in dis (#120033)

17 months agogh-119553: Fix console when pressing Ctrl-C within a multiline block (#120075)
Lysandros Nikolaou [Tue, 4 Jun 2024 21:22:28 +0000 (23:22 +0200)] 
gh-119553: Fix console when pressing Ctrl-C within a multiline block (#120075)

17 months agogh-119999: Fix potential race condition in `_Py_ExplicitMergeRefcount` (#120000)
Sam Gross [Tue, 4 Jun 2024 19:26:26 +0000 (15:26 -0400)] 
gh-119999: Fix potential race condition in `_Py_ExplicitMergeRefcount` (#120000)

We need to write to `ob_ref_local` and `ob_tid` before `ob_ref_shared`.
Once we mark `ob_ref_shared` as merged, some other thread may free the
object because the caller also passes in `-1` as `extra` to give up its
only reference.

17 months agogh-119819: Update test to skip if _multiprocessing is unavailable. (GH-120067)
Vinay Sajip [Tue, 4 Jun 2024 19:16:43 +0000 (20:16 +0100)] 
gh-119819: Update test to skip if _multiprocessing is unavailable. (GH-120067)

17 months agogh-120048: Make `test_imaplib` faster (#120050)
Sam Gross [Tue, 4 Jun 2024 18:59:23 +0000 (14:59 -0400)] 
gh-120048: Make `test_imaplib` faster (#120050)

The `test_imaplib` was taking 40+ minutes in the refleak build bots because
the tests waiting on a client `self._setup()` was creating a client that
prevented progress until its connection timed out, which scaled with the
global timeout.

We should set `connect=False` for the tests that don't want `_setup()` to
create a client.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
17 months agogh-119842: Honor PyOS_InputHook in the new REPL (GH-119843)
Pablo Galindo Salgado [Tue, 4 Jun 2024 18:32:43 +0000 (19:32 +0100)] 
gh-119842: Honor PyOS_InputHook in the new REPL (GH-119843)

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Michael Droettboom <mdboom@gmail.com>
17 months agodoc: Mention the missing reflected special methods for all binary operations (GH...
Paulo Freitas [Tue, 4 Jun 2024 17:55:11 +0000 (14:55 -0300)] 
doc: Mention the missing reflected special methods for all binary operations (GH-119931)

17 months agogh-119553: Clear reader on Ctrl-C command (GH-119801)
Lysandros Nikolaou [Tue, 4 Jun 2024 17:46:33 +0000 (19:46 +0200)] 
gh-119553: Clear reader on Ctrl-C command (GH-119801)

17 months agogh-120039: Reduce expected timeout in test_siginterrupt_off (#120047)
Sam Gross [Tue, 4 Jun 2024 17:38:29 +0000 (13:38 -0400)] 
gh-120039: Reduce expected timeout in test_siginterrupt_off (#120047)

The process is expected to time out. In the refleak builds,
`support.SHORT_TIMEOUT` is often five minutes and we run the tests six
times, so test_signal was taking >30 minutes.

17 months agogh-120041: Refactor check for visible completion menu in completing_reader (#120055)
Lysandros Nikolaou [Tue, 4 Jun 2024 17:26:44 +0000 (19:26 +0200)] 
gh-120041: Refactor check for visible completion menu in completing_reader (#120055)

17 months agogh-112672: Fix builtin Tkinter with Tcl 9.0 (GH-112681)
Christopher Chavez [Tue, 4 Jun 2024 16:47:15 +0000 (11:47 -0500)] 
gh-112672: Fix builtin Tkinter with Tcl 9.0 (GH-112681)

* Add declaration of Tcl_AppInit(), missing in Tcl 9.0.
* Use Tcl_Size instead of int where needed.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
17 months agogh-89928: Fix integer conversion of device numbers (GH-31794)
Serhiy Storchaka [Tue, 4 Jun 2024 16:36:37 +0000 (19:36 +0300)] 
gh-89928: Fix integer conversion of device numbers (GH-31794)

Fix os.major(), os.minor() and os.makedev().
Support device numbers larger than 2**63-1.
Support non-existent device number (NODEV).

17 months agoFix incorrect pull GitHub link in What's New (#120045)
Trey Hunner [Tue, 4 Jun 2024 16:28:08 +0000 (09:28 -0700)] 
Fix incorrect pull GitHub link in What's New (#120045)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
17 months agogh-120041: Do not use append_to_screen when completions are visible (GH-120042)
Lysandros Nikolaou [Tue, 4 Jun 2024 16:09:31 +0000 (18:09 +0200)] 
gh-120041: Do not use append_to_screen when completions are visible (GH-120042)

17 months agogh-119588: Update docs to reflect decision to include the change with Python 3.13...
Jason R. Coombs [Tue, 4 Jun 2024 15:20:01 +0000 (11:20 -0400)] 
gh-119588: Update docs to reflect decision to include the change with Python 3.13 and not 3.12. (#120043)

17 months agogh-120029: export `DEF_TYPE_PARAM` compiler flag (#120028)
Bénédikt Tran [Tue, 4 Jun 2024 14:24:22 +0000 (16:24 +0200)] 
gh-120029: export `DEF_TYPE_PARAM` compiler flag (#120028)

17 months agogh-117657: Fix race involving GC and heap initialization (#119923)
Sam Gross [Tue, 4 Jun 2024 13:42:13 +0000 (09:42 -0400)] 
gh-117657: Fix race involving GC and heap initialization (#119923)

The `_PyThreadState_Bind()` function is called before the first
`PyEval_AcquireThread()` so it's not synchronized with the stop the
world GC. We had a race where `gc_visit_heaps()` might visit a thread's
heap while it's being initialized.

Use a simple atomic int to avoid visiting heaps for threads that are not
yet fully initialized (i.e., before `tstate_mimalloc_bind()` is called).

The race was reproducible by running:
`python Lib/test/test_importlib/partial/pool_in_threads.py`.

17 months agogh-94808: Reorganize _make_posargs and mark unused code (GH-119227)
Mark Jason Dominus (陶敏修) [Tue, 4 Jun 2024 12:59:56 +0000 (08:59 -0400)] 
gh-94808: Reorganize _make_posargs and mark unused code (GH-119227)

* Reorganize four-way if-elsif-elsif-elsif as nested if-elses
* Mark unused branch in _make_posargs

`names_with_default` is never `NULL`, even if there are no names with
defaults.  In that case it points to a structure with `size` zero.

Rather than eliminating the branch, we leave it behind with an `assert(0)`
in case a future change to the grammar exercises the branch.

17 months agogh-119819: Fix regression to allow logging configuration with multipr… (GH-120030)
Vinay Sajip [Tue, 4 Jun 2024 12:20:50 +0000 (13:20 +0100)] 
gh-119819: Fix regression to allow logging configuration with multipr… (GH-120030)

17 months agogh-118868: logging QueueHandler fix passing of kwargs (GH-118869)
Kaundur [Tue, 4 Jun 2024 11:48:05 +0000 (12:48 +0100)] 
gh-118868: logging QueueHandler fix passing of kwargs (GH-118869)

Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
17 months agoFix typos in documentation and comments (#119763)
Xie Yanbo [Tue, 4 Jun 2024 10:22:22 +0000 (18:22 +0800)] 
Fix typos in documentation and comments (#119763)

17 months agogh-111499: Fix PYTHONMALLOCSTATS at Python exit (#120021)
Victor Stinner [Tue, 4 Jun 2024 09:39:07 +0000 (11:39 +0200)] 
gh-111499: Fix PYTHONMALLOCSTATS at Python exit (#120021)

Call _PyObject_DebugMallocStats() earlier in Py_FinalizeEx(), before
the interpreter is deleted.

17 months agogh-119613: Soft deprecate the Py_MEMCPY() macro (#120020)
Victor Stinner [Tue, 4 Jun 2024 09:23:55 +0000 (11:23 +0200)] 
gh-119613: Soft deprecate the Py_MEMCPY() macro (#120020)

Use directly memcpy() instead.

17 months agogh-119070: Update test_shebang_executable_extension to always use non-installed versi...
Steve Dower [Tue, 4 Jun 2024 08:17:45 +0000 (09:17 +0100)] 
gh-119070: Update test_shebang_executable_extension to always use non-installed version (GH-119846)

17 months agogh-119879: str.find(): Utilize last character gap for two-way periodic needles (...
d.grigonis [Tue, 4 Jun 2024 07:44:49 +0000 (10:44 +0300)] 
gh-119879: str.find(): Utilize last character gap for two-way periodic needles (#119880)

17 months agogh-106531: Apply changes from importlib_resources 6.3.2 (#117054)
Jason R. Coombs [Tue, 4 Jun 2024 06:36:28 +0000 (02:36 -0400)] 
gh-106531: Apply changes from importlib_resources 6.3.2 (#117054)

Apply changes from importlib_resources 6.3.2.

17 months agogh-119724: Revert "bpo-45759: Better error messages for non-matching 'elif'/'else...
Petr Viktorin [Tue, 4 Jun 2024 01:10:15 +0000 (03:10 +0200)] 
gh-119724: Revert "bpo-45759: Better error messages for non-matching 'elif'/'else' statements (#29513)" (#119974)

This reverts commit 1c8f912ebdfdb146cd7dd2d7a3a67d2c5045ddb0.

17 months agogh-117398: Use Per-Interpreter State for the _datetime Static Types (gh-119929)
Eric Snow [Mon, 3 Jun 2024 23:09:18 +0000 (19:09 -0400)] 
gh-117398: Use Per-Interpreter State for the _datetime Static Types (gh-119929)

We make use of the same mechanism that we use for the static builtin types.  This required a few tweaks.

The relevant code could use some cleanup but I opted to avoid the significant churn in this change.  I'll tackle that separately.

This change is the final piece needed to make _datetime support multiple interpreters.  I've updated the module slot accordingly.

17 months agogh-117142: Support Importing ctypes in Isolated Interpreters (gh-119991)
Eric Snow [Mon, 3 Jun 2024 22:42:48 +0000 (18:42 -0400)] 
gh-117142: Support Importing ctypes in Isolated Interpreters (gh-119991)

This makes the support official.

Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
17 months agogh-117398: Add datetime Module State (gh-119810)
Eric Snow [Mon, 3 Jun 2024 21:56:00 +0000 (17:56 -0400)] 
gh-117398: Add datetime Module State (gh-119810)

I was able to make use of the existing datetime_state struct, but there was one tricky thing I had to sort out.  We mostly aren't converting to heap types, so we can't use things like PyType_GetModuleByDef() to look up the module state.  The solution I came up with is somewhat novel, but I consider it straightforward.  Also, it shouldn't have much impact on performance.

In summary, this main changes here are:

* I've added some macros to help hide how various objects relate to module state
* as a solution to the module state lookup problem, I've stored the last loaded module on the current interpreter's internal dict (actually a weakref)
* if the static type method is used after the module has been deleted, it is reloaded
* to avoid extra work when loading the module, we directly copy the objects (new refs only) from the old module state into the new state if the old module hasn't been deleted yet
* during module init we set various objects on the static types' __dict__s; to simplify things, we only do that the first time; once those static types have a separate __dict__ per interpreter, we'll do it every time
* we now clear the module state when the module is destroyed (before, we were leaking everything in _datetime_global_state)

17 months agogh-117657: Fix race involving immortalizing objects (#119927)
Sam Gross [Mon, 3 Jun 2024 20:58:41 +0000 (16:58 -0400)] 
gh-117657: Fix race involving immortalizing objects (#119927)

The free-threaded build currently immortalizes objects that use deferred
reference counting (see gh-117783). This typically happens once the
first non-main thread is created, but the behavior can be suppressed for
tests, in subinterpreters, or during a compile() call.

This fixes a race condition involving the tracking of whether the
behavior is suppressed.

17 months agoupdate CODEOWNERS (#120003)
Irit Katriel [Mon, 3 Jun 2024 20:44:36 +0000 (21:44 +0100)] 
update CODEOWNERS (#120003)

17 months agogh-117657: Avoid `sem_clockwait` in TSAN (#119915)
Sam Gross [Mon, 3 Jun 2024 17:42:27 +0000 (13:42 -0400)] 
gh-117657: Avoid `sem_clockwait` in TSAN (#119915)

The `sem_clockwait` function is not currently instrumented, which leads
to false positives.

17 months agogh-118835: pyrepl: Fix prompt length computation for custom prompts containing ANSI...
Daniel Hollas [Mon, 3 Jun 2024 17:07:06 +0000 (18:07 +0100)] 
gh-118835: pyrepl: Fix prompt length computation for custom prompts containing ANSI escape codes (#119942)