]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
17 months agogh-116560: Add PyLong_GetSign() public function (#116561)
Sergey B Kirpichev [Mon, 3 Jun 2024 12:06:31 +0000 (15:06 +0300)] 
gh-116560: Add PyLong_GetSign() public function (#116561)

Co-authored-by: Victor Stinner <vstinner@python.org>
17 months agogh-119786: move exception handling doc to InternalDocs (#119815)
Irit Katriel [Mon, 3 Jun 2024 09:36:20 +0000 (10:36 +0100)] 
gh-119786: move exception handling doc to InternalDocs (#119815)

17 months agogh-119968: Improved monitoring c-api docs (#119969)
Awbert [Mon, 3 Jun 2024 09:31:02 +0000 (12:31 +0300)] 
gh-119968: Improved monitoring c-api docs (#119969)

17 months agogh-119838: Treat Fraction as a real value in mixed arithmetic operations with complex...
Serhiy Storchaka [Mon, 3 Jun 2024 09:29:01 +0000 (12:29 +0300)] 
gh-119838: Treat Fraction as a real value in mixed arithmetic operations with complex (GH-119839)

17 months agogh-112026: Deprecate _PyDict_GetItemStringWithError() function (#119855)
Victor Stinner [Mon, 3 Jun 2024 08:26:13 +0000 (10:26 +0200)] 
gh-112026: Deprecate _PyDict_GetItemStringWithError() function (#119855)

17 months agogh-119856: Support exiting help() with just "exit" (#119858)
Victor Stinner [Mon, 3 Jun 2024 08:15:04 +0000 (10:15 +0200)] 
gh-119856: Support exiting help() with just "exit" (#119858)

17 months agogh-116991: Improve `pygen --help` for `python` subparser (#116992)
Nikita Sobolev [Mon, 3 Jun 2024 07:52:35 +0000 (10:52 +0300)] 
gh-116991: Improve `pygen --help` for `python` subparser (#116992)

17 months agogh-118827: Remove `Quoter` from `urllib.parse` (#118828)
Nikita Sobolev [Mon, 3 Jun 2024 07:50:29 +0000 (10:50 +0300)] 
gh-118827: Remove `Quoter` from `urllib.parse` (#118828)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
17 months agogh-119506: fix `_io.TextIOWrapper.write()` write during flush (#119507)
Radislav Chugunov [Mon, 3 Jun 2024 07:47:36 +0000 (10:47 +0300)] 
gh-119506: fix `_io.TextIOWrapper.write()` write during flush (#119507)

Co-authored-by: Inada Naoki <songofacandy@gmail.com>
17 months agogh-119396: Optimize unicode_decode_utf8_writer() (#119957)
Victor Stinner [Mon, 3 Jun 2024 06:45:20 +0000 (08:45 +0200)] 
gh-119396: Optimize unicode_decode_utf8_writer() (#119957)

Optimize unicode_decode_utf8_writer()

Take the ascii_decode() fast-path even if dest is not aligned on
size_t bytes.

17 months agogh-119961: Fix test workflow status badge in README (#119962)
wookie184 [Mon, 3 Jun 2024 06:05:57 +0000 (07:05 +0100)] 
gh-119961: Fix test workflow status badge in README (#119962)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
17 months agogh-117657: Fix data races report by TSAN unicode-hash (gh-119907)
Donghee Na [Mon, 3 Jun 2024 03:22:41 +0000 (12:22 +0900)] 
gh-117657: Fix data races report by TSAN unicode-hash (gh-119907)

17 months agogh-109975: What's New in Python 3.13: fix broken link for `telnetlib` alternative...
Solomon Himelbloom [Mon, 3 Jun 2024 00:43:03 +0000 (16:43 -0800)] 
gh-109975: What's New in Python 3.13: fix broken link for `telnetlib` alternative (#119958)

17 months agoGH-119054: Add "Reading and writing files" section to pathlib docs (#119524)
Barney Gale [Sun, 2 Jun 2024 19:39:19 +0000 (20:39 +0100)] 
GH-119054: Add "Reading and writing files" section to pathlib docs (#119524)

Add a dedicated subsection for `open()`, `read_text()`, `read_bytes()`,
`write_text()` and `write_bytes()`.

17 months agoImprove documentation for typing.get_type_hints (#119928)
Jelle Zijlstra [Sun, 2 Jun 2024 15:13:24 +0000 (08:13 -0700)] 
Improve documentation for typing.get_type_hints (#119928)

- Explicit list of what it does that is different from
  "just return __annotations__"
- Remove reference to PEP 563; adding the future import doesn't
  do anything to type aliases, and in general it will never make
  get_type_hints() less likely to fail.
- Remove example, as the Annotated docs already have a similar
  example, and it's unbalanced to have one example about this
  one edge case but not about other behaviors of the function.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
17 months agogh-117657: Fix TSAN reported race in `_PyEval_IsGILEnabled`. (#119921)
Sam Gross [Sun, 2 Jun 2024 14:19:02 +0000 (10:19 -0400)] 
gh-117657: Fix TSAN reported race in `_PyEval_IsGILEnabled`. (#119921)

The GIL may be disabled concurrently with this call so we need to use a
relaxed atomic load.

17 months agogh-119740: Remove deprecated trunc delegation (#119743)
Mark Dickinson [Sun, 2 Jun 2024 09:16:49 +0000 (10:16 +0100)] 
gh-119740: Remove deprecated trunc delegation (#119743)

Remove the delegation of `int` to the `__trunc__` special method: `int` will now only delegate to `__int__` and `__index__` (in that order). `__trunc__` continues to exist, but its sole purpose is to support `math.trunc`.

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
17 months agogh-119775: Remove ability to create immutable types with mutable bases (#119776)
Nikita Sobolev [Sun, 2 Jun 2024 07:27:20 +0000 (10:27 +0300)] 
gh-119775: Remove ability to create immutable types with mutable bases (#119776)

17 months agogh-118934: Fix PyEval_GetLocals docs (PEP 667) (#119932)
Alyssa Coghlan [Sun, 2 Jun 2024 04:44:29 +0000 (14:44 +1000)] 
gh-118934: Fix PyEval_GetLocals docs (PEP 667) (#119932)

PEP 667's description of the planned changes to PyEval_GetLocals
was internally inconsistent when accepted, so the docs added for
gh-74929 didn't match either the current behaviour or the intended
behaviour once gh-118934 is fixed.

This PR updates the documentation and 3.13 What's New to match the
intended behaviour (once gh-118934 is fixed).

It also tidies up lingering references to `f_locals` always being a
dictionary (this hasn't been true since at least when custom
namespace support for class statement execution was added)

17 months agoRefactor (mostly rearrange) the statistics module (gh-119930)
Raymond Hettinger [Sun, 2 Jun 2024 03:07:46 +0000 (22:07 -0500)] 
Refactor (mostly rearrange) the statistics module (gh-119930)

17 months agogh-119016: Remove outdated sentences from the "classes" tutorial (#119130)
Nice Zombies [Sat, 1 Jun 2024 21:20:00 +0000 (23:20 +0200)] 
gh-119016: Remove outdated sentences from the "classes" tutorial (#119130)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
17 months agoGH-89727: Fix `shutil.rmtree()` recursion error on deep trees (#119808)
Barney Gale [Sat, 1 Jun 2024 18:49:12 +0000 (19:49 +0100)] 
GH-89727: Fix `shutil.rmtree()` recursion error on deep trees (#119808)

Implement `shutil._rmtree_safe_fd()` using a list as a stack to avoid emitting recursion errors on deeply nested trees.

`shutil._rmtree_unsafe()` was fixed in a150679f90.

17 months agoAdd unique() recipe to itertools docs (gh-119911)
Raymond Hettinger [Sat, 1 Jun 2024 16:30:24 +0000 (11:30 -0500)] 
Add unique() recipe to itertools docs (gh-119911)

17 months agogh-117657: Add TSAN suppression for `set_discard_entry` (#119908)
Sam Gross [Sat, 1 Jun 2024 16:15:58 +0000 (12:15 -0400)] 
gh-117657: Add TSAN suppression for `set_discard_entry` (#119908)

Seen in CI occasionally when running `test_weakref`.

17 months agogh-113892: Add a extra check to `ProactorEventLoop.sock_connect` to ensure that the...
Kirill Podoprigora [Sat, 1 Jun 2024 16:05:19 +0000 (19:05 +0300)] 
gh-113892: Add a extra check to `ProactorEventLoop.sock_connect` to ensure that the given socket is in non-blocking mode (#119519)

17 months agoMinor speed/accuracy improvement for kde() (gh-119910)
Raymond Hettinger [Sat, 1 Jun 2024 15:49:14 +0000 (10:49 -0500)] 
Minor speed/accuracy improvement for kde() (gh-119910)

17 months agogh-117657: Fix TSAN race in QSBR assertion (#119887)
Sam Gross [Sat, 1 Jun 2024 14:04:38 +0000 (10:04 -0400)] 
gh-117657: Fix TSAN race in QSBR assertion (#119887)

Due to a limitation in TSAN, all reads from `PyThreadState.state` must be
atomic to avoid reported races.

17 months agogh-117657: Fix TSAN race in free-threaded GC (#119883)
Sam Gross [Sat, 1 Jun 2024 14:04:05 +0000 (10:04 -0400)] 
gh-117657: Fix TSAN race in free-threaded GC (#119883)

Only call `gc_restore_tid()` from stop-the-world contexts.
`worklist_pop()` can be called while other threads are running, so use a
relaxed atomic to modify `ob_tid`.

17 months agoBump types-psutil from 5.9.5.20240423 to 5.9.5.20240516 in /Tools (#119900)
dependabot[bot] [Sat, 1 Jun 2024 10:38:13 +0000 (10:38 +0000)] 
Bump types-psutil from 5.9.5.20240423 to 5.9.5.20240516 in /Tools (#119900)

17 months agobuild(deps-dev): bump types-setuptools from 69.5.0.20240423 to 70.0.0.20240524 in...
dependabot[bot] [Sat, 1 Jun 2024 10:11:53 +0000 (10:11 +0000)] 
build(deps-dev): bump types-setuptools from 69.5.0.20240423 to 70.0.0.20240524 in /Tools (#119899)

17 months agogh-118888: Further PEP 667 docs updates (gh-119893)
Alyssa Coghlan [Sat, 1 Jun 2024 06:21:48 +0000 (16:21 +1000)] 
gh-118888: Further PEP 667 docs updates (gh-119893)

* Clarify impact on default behaviour of exec, eval, etc
* Update documentation for changes to PyEval_GetLocals (gh-74929)

Closes gh-11888

17 months agogh-74929: PEP 667 C API documentation (gh-119379)
Alyssa Coghlan [Sat, 1 Jun 2024 03:59:35 +0000 (13:59 +1000)] 
gh-74929: PEP 667 C API documentation (gh-119379)

* Add docs for new APIs
* Add soft-deprecation notices
* Add What's New porting entries
* Update comments referencing `PyFrame_LocalsToFast()` to mention the proxy instead
* Other related cleanups found when looking for refs to the deprecated APIs

17 months agostatistics.fmean(): speed-up code path for non-sizeable inputs. (gh-119876) 119460/head
Raymond Hettinger [Fri, 31 May 2024 22:08:55 +0000 (17:08 -0500)] 
statistics.fmean(): speed-up code path for non-sizeable inputs. (gh-119876)

17 months agogh-119180: Lazily wrap annotations on classmethod and staticmethod (#119864)
Jelle Zijlstra [Fri, 31 May 2024 21:05:51 +0000 (14:05 -0700)] 
gh-119180: Lazily wrap annotations on classmethod and staticmethod (#119864)

17 months agogh-119821: Support non-dict globals in LOAD_FROM_DICT_OR_GLOBALS (#119822)
Jelle Zijlstra [Fri, 31 May 2024 21:05:24 +0000 (14:05 -0700)] 
gh-119821: Support non-dict globals in LOAD_FROM_DICT_OR_GLOBALS (#119822)

Support non-dict globals in LOAD_FROM_DICT_OR_GLOBALS

The implementation basically copies LOAD_GLOBAL. Possibly it could be deduplicated,
but that seems like it may get hairy since the two operations have different operands.

This is important to fix in 3.14 for PEP 649, but it's a bug in earlier versions too,
and we should backport to 3.13 and 3.12 if possible.

17 months agogh-118894: Make asyncio REPL use pyrepl (GH-119433)
Łukasz Langa [Fri, 31 May 2024 20:26:02 +0000 (16:26 -0400)] 
gh-118894: Make asyncio REPL use pyrepl (GH-119433)

17 months agogh-119853: Add Include/refcount.h to projects (#119860)
Victor Stinner [Fri, 31 May 2024 19:21:30 +0000 (21:21 +0200)] 
gh-119853: Add Include/refcount.h to projects (#119860)

17 months agogh-119799: Add missing `_Py_IncRefTotal` to `_Py_NewRefWithLock` (#119800)
Sam Gross [Fri, 31 May 2024 18:18:24 +0000 (14:18 -0400)] 
gh-119799: Add missing `_Py_IncRefTotal` to `_Py_NewRefWithLock` (#119800)

The free-threaded refleak builds were reporting negative refcount deltas
in some tests because of a missing `_Py_NewRefWithLock`.

17 months agodoc: Add glossary entry for "free threading" (#119865)
Sam Gross [Fri, 31 May 2024 17:23:29 +0000 (13:23 -0400)] 
doc: Add glossary entry for "free threading" (#119865)

17 months agocontextlib docs: Clean up redundant 'up' after 'cleanup' (GH-119867)
Zachary Ware [Fri, 31 May 2024 17:19:54 +0000 (12:19 -0500)] 
contextlib docs: Clean up redundant 'up' after 'cleanup' (GH-119867)

Reported by Michael Kass on docs@

17 months agogh-100117: Fix inaccuracy in documentation of the CodeObject's co_positions field...
Irit Katriel [Fri, 31 May 2024 17:09:48 +0000 (18:09 +0100)] 
gh-100117: Fix inaccuracy in documentation of the CodeObject's co_positions field. (#119364)

17 months agogh-119369: Fix deadlock during thread exit in free-threaded build (#119528)
Sam Gross [Fri, 31 May 2024 17:04:59 +0000 (13:04 -0400)] 
gh-119369: Fix deadlock during thread exit in free-threaded build (#119528)

Release the GIL before calling `_Py_qsbr_unregister`.

The deadlock could occur when the GIL was enabled at runtime. The
`_Py_qsbr_unregister` call might block while holding the GIL because the
thread state was not active, but the GIL was still held.

17 months agogh-119770: Make termios ioctl() constants positive (#119840)
Victor Stinner [Fri, 31 May 2024 15:18:40 +0000 (17:18 +0200)] 
gh-119770: Make termios ioctl() constants positive (#119840)

17 months agogh-119585: Fix crash involving `PyGILState_Release()` and `PyThreadState_Clear()...
Sam Gross [Fri, 31 May 2024 14:50:52 +0000 (10:50 -0400)] 
gh-119585: Fix crash involving `PyGILState_Release()` and `PyThreadState_Clear()` (#119753)

Make sure that `gilstate_counter` is not zero in when calling
`PyThreadState_Clear()`. A destructor called from `PyThreadState_Clear()` may
call back into `PyGILState_Ensure()` and `PyGILState_Release()`. If
`gilstate_counter` is zero, it will try to create a new thread state before
the current active thread state is destroyed, leading to an assertion failure
or crash.

17 months agogh-119853: Add Include/refcount.h file (#119854)
Victor Stinner [Fri, 31 May 2024 14:49:26 +0000 (16:49 +0200)] 
gh-119853: Add Include/refcount.h file  (#119854)

17 months agogh-111201: Skip pyrepl Windows tests earlier (#119848)
Victor Stinner [Fri, 31 May 2024 14:06:10 +0000 (16:06 +0200)] 
gh-111201: Skip pyrepl Windows tests earlier (#119848)

Don't attempt to load pyrepl Windows console if platforms others than
Windows. For example, the import can fail if ctypes is missing.

17 months agogh-111201: [pyrepl] Ensure optional platform-specific imports are optional (GH-119834)
Łukasz Langa [Fri, 31 May 2024 12:41:26 +0000 (08:41 -0400)] 
gh-111201: [pyrepl] Ensure optional platform-specific imports are optional (GH-119834)

17 months agogh-116145: Updated bundled Tcl/Tk on Windows to 8.6.14 (GH-117030)
Steve Dower [Fri, 31 May 2024 12:07:19 +0000 (13:07 +0100)] 
gh-116145: Updated bundled Tcl/Tk on Windows to 8.6.14 (GH-117030)

17 months agogh-119189: Fix the power operator for Fraction (GH-119242)
Joshua Herman [Fri, 31 May 2024 10:05:09 +0000 (05:05 -0500)] 
gh-119189:  Fix the power operator for Fraction (GH-119242)

When using the ** operator or pow() with Fraction as the base
and an exponent that is not rational, a float, or a complex, the
fraction is no longer converted to a float.

17 months agogh-111201: Improve pyrepl auto indentation (#119606)
Arnon Yaari [Fri, 31 May 2024 09:02:54 +0000 (12:02 +0300)] 
gh-111201: Improve pyrepl auto indentation (#119606)

- auto-indent when editing multi-line block
- ignore comments

17 months agogh-103194: Fix Tkinter’s Tcl value type handling for Tcl 8.7/9.0 (GH-103846)
Christopher Chavez [Fri, 31 May 2024 08:23:53 +0000 (03:23 -0500)] 
gh-103194: Fix Tkinter’s Tcl value type handling for Tcl 8.7/9.0 (GH-103846)

Some of standard Tcl types were renamed, removed, or no longer
registered in Tcl 8.7/9.0. This change fixes automatic conversion of Tcl
values to Python values to avoid returning a Tcl_Obj where the primary
Python types (int, bool, str, bytes) were returned in older Tcl.

17 months agogh-119780: Adjust exception messages in Lib/test/test_format.py (GH-119781)
Sergey B Kirpichev [Fri, 31 May 2024 08:07:16 +0000 (11:07 +0300)] 
gh-119780: Adjust exception messages in Lib/test/test_format.py (GH-119781)

Mismatches were just output to the stdout, without making the test failing.

17 months agogh-97747: Improvements to WASM browser REPL. (#97665)
Katie Bell [Fri, 31 May 2024 07:58:46 +0000 (17:58 +1000)] 
gh-97747: Improvements to WASM browser REPL. (#97665)

Improvements to WASM browser REPL.

Adds a text box to write and run code outside the REPL, a stop button, and handling of Ctrl-D for EOF.

17 months agogh-111201: Support pyrepl on Windows (#119559)
Dino Viehland [Fri, 31 May 2024 07:49:03 +0000 (00:49 -0700)] 
gh-111201: Support pyrepl on Windows (#119559)

Co-authored-by: Anthony Shaw <anthony.p.shaw@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
17 months agogh-119744: move a few functions from compile.c to flowgraph.c (#119745)
Irit Katriel [Thu, 30 May 2024 20:55:06 +0000 (21:55 +0100)] 
gh-119744: move a few functions from compile.c to flowgraph.c (#119745)

17 months agogh-107262: Update Tkinter tests for Tcl/Tk 8.6.14 (GH-119322)
James De Bias [Thu, 30 May 2024 20:34:59 +0000 (06:34 +1000)] 
gh-107262: Update Tkinter tests for Tcl/Tk 8.6.14 (GH-119322)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
17 months agogh-109218: Deprecate weird cases in the complex() constructor (GH-119620)
Serhiy Storchaka [Thu, 30 May 2024 20:30:57 +0000 (23:30 +0300)] 
gh-109218: Deprecate weird cases in the complex() constructor (GH-119620)

* Passing a string as the "real" keyword argument is now an error;
  it should only be passed as a single positional argument.
* Passing a complex number as the "real" or "imag" argument is now deprecated;
  it should only be passed as a single positional argument.

17 months agoDocs: `shutil.rmtree`'s `onerror` has no pending removal version (#118947)
Hugo van Kemenade [Thu, 30 May 2024 20:26:46 +0000 (23:26 +0300)] 
Docs: `shutil.rmtree`'s `onerror` has no pending removal version (#118947)

17 months agogh-109218: Improve documentation for the complex() constructor (GH-119687)
Serhiy Storchaka [Thu, 30 May 2024 20:20:07 +0000 (23:20 +0300)] 
gh-109218: Improve documentation for the complex() constructor (GH-119687)

* Remove the equivalence with real+imag*1j which can be incorrect in corner
  cases (non-finite numbers, the sign of zeroes).
* Separately document the three roles of the constructor: parsing a string,
  converting a number, and constructing a complex from components.
* Document positional-only parameters of complex(), float(), int() and bool()
  as positional-only.
* Add examples for complex() and int().
* Specify the grammar of the string for complex().
* Improve the grammar of the string for float().
* Describe more explicitly the behavior when real and/or imag arguments are
  complex numbers. (This will be deprecated in future.)

17 months agogh-119729: Use 't' in pkg-config file name for free-threaded build (#119738)
Sam Gross [Thu, 30 May 2024 17:48:28 +0000 (13:48 -0400)] 
gh-119729: Use 't' in pkg-config file name for free-threaded build (#119738)

For example, the free-threaded build now generates
`lib/pkgconfig/python-3.13t.pc` and the debug build generates
`lib/pkgconfig/python-3.13d.pc`.

17 months agogh-109218: Refactor tests for the complex() constructor (GH-119635)
Serhiy Storchaka [Thu, 30 May 2024 17:35:59 +0000 (20:35 +0300)] 
gh-109218: Refactor tests for the complex() constructor (GH-119635)

* Share common classes.
* Use exactly representable floats and exact tests.
* Check the sign of zero components.
* Remove duplicated tests (mostly left after merging int and long).
* Reorder tests in more consistent way.
* Test more error messages.
* Add tests for missed cases.

17 months agogh-119791: Fix new Tkinter tests for wantobjects=0 (GH-119792)
Serhiy Storchaka [Thu, 30 May 2024 17:22:52 +0000 (20:22 +0300)] 
gh-119791: Fix new Tkinter tests for wantobjects=0 (GH-119792)

PhotoImage.get() retruns a string instead of a 3-tuple of integers
in this case.

17 months agogh-119786: create folder in cpython repo for internals documentation (#119787)
Irit Katriel [Thu, 30 May 2024 16:38:37 +0000 (17:38 +0100)] 
gh-119786: create folder in cpython repo for internals documentation (#119787)

17 months agogh-119779: Fix pyporting howto docs (#119785)
Awbert [Thu, 30 May 2024 15:51:22 +0000 (18:51 +0300)] 
gh-119779: Fix pyporting howto docs (#119785)

17 months agogh-119336: Restore removed _PyLong_NumBits() function (#119418)
Ethan Smith [Thu, 30 May 2024 14:48:18 +0000 (07:48 -0700)] 
gh-119336: Restore removed _PyLong_NumBits() function (#119418)

It is used by the pywin32 project.

17 months agogh-110383: Remove references to removed popen[234] (GH-112783)
Bradley Reynolds [Thu, 30 May 2024 12:21:37 +0000 (07:21 -0500)] 
gh-110383: Remove references to removed popen[234] (GH-112783)

Signed-off-by: Bradley Reynolds <bradley.reynolds@darbia.dev>
17 months agogh-118055: Update the finder glossary entry (GH-118278)
Lincoln [Thu, 30 May 2024 08:51:23 +0000 (11:51 +0300)] 
gh-118055: Update the finder glossary entry (GH-118278)

17 months agogh-118235: Move RAISE_SYNTAX_ERROR actions to invalid rules and make sure they stay...
Petr Viktorin [Thu, 30 May 2024 07:27:32 +0000 (09:27 +0200)] 
gh-118235: Move RAISE_SYNTAX_ERROR actions to invalid rules and make sure they stay there (GH-119731)

The Full Grammar specification in the docs omits rule actions, so grammar rules that raise a syntax error looked like valid syntax.
This was solved in ef940de by hiding those rules in the custom syntax highlighter.

This moves all syntax-error alternatives to invalid rules, adds a validator that ensures that actions containing RAISE_SYNTAX_ERROR are in invalid rules, and reverts the syntax highlighter hack.

17 months agoGH-89727: Fix FD leak on `os.fwalk()` generator finalization. (#119766)
Barney Gale [Thu, 30 May 2024 03:45:47 +0000 (04:45 +0100)] 
GH-89727: Fix FD leak on `os.fwalk()` generator finalization. (#119766)

Follow-up to 3c890b50. Ensure we `os.close()` open file descriptors when
the `os.fwalk()` generator is finalized.

17 months agoGH-89727: Fix `os.fwalk()` recursion error on deep trees (#119638)
Barney Gale [Thu, 30 May 2024 03:05:36 +0000 (04:05 +0100)] 
GH-89727: Fix `os.fwalk()` recursion error on deep trees (#119638)

Implement `os.fwalk()` using a list as a stack to avoid emitting recursion
errors on deeply nested trees.

17 months agosubprocess docs: Fix semantically important typo (GH-119752)
Zachary Ware [Wed, 29 May 2024 22:19:54 +0000 (17:19 -0500)] 
subprocess docs: Fix semantically important typo (GH-119752)

GH-25416 accidentally replaced a reference to the *stderr* argument of
`subprocess.run` with a reference to the *stdin* argument.  *stdin* is
not affected by the `check_output` option.

17 months agoGH-119169: Implement `pathlib.Path.walk()` using `os.walk()` (#119573)
Barney Gale [Wed, 29 May 2024 20:51:04 +0000 (21:51 +0100)] 
GH-119169: Implement `pathlib.Path.walk()` using `os.walk()` (#119573)

For silly reasons, pathlib's generic implementation of `walk()` currently
resides in `glob._Globber`. This commit moves it into
`pathlib._abc.PathBase.walk()` where it really belongs, and makes
`pathlib.Path.walk()` call `os.walk()`.

17 months agoGH-89727: Partially fix `shutil.rmtree()` recursion error on deep trees (#119634)
Barney Gale [Wed, 29 May 2024 20:11:30 +0000 (21:11 +0100)] 
GH-89727: Partially fix `shutil.rmtree()` recursion error on deep trees (#119634)

Make `shutil._rmtree_unsafe()` call `os.walk()`, which is implemented
without recursion.

`shutil._rmtree_safe_fd()` is not affected and can still raise a recursion
error.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
17 months agogh-119525: Fix deadlock with `_PyType_Lookup` and the GIL (#119527)
Sam Gross [Wed, 29 May 2024 19:26:04 +0000 (15:26 -0400)] 
gh-119525: Fix deadlock with `_PyType_Lookup` and the GIL (#119527)

The deadlock only affected the free-threaded build and only occurred
when the GIL was enabled at runtime. The `Py_DECREF(old_name)` call
might temporarily release the GIL while holding the type seqlock.
Another thread may spin trying to acquire the seqlock while holding the
GIL.

The deadlock occurred roughly 1 in ~1,000 runs of `pool_in_threads.py`
from `test_multiprocessing_pool_circular_import`.

17 months agogh-119070: Fix py.exe handling of /usr/bin/env commands missing extension (GH-119426)
Steve Dower [Wed, 29 May 2024 17:51:13 +0000 (18:51 +0100)] 
gh-119070: Fix py.exe handling of /usr/bin/env commands missing extension (GH-119426)

17 months agogh-119594: Improve pow(fraction.Fraction(), b, modulo) error message (#119593)
Wim Jeantine-Glenn [Wed, 29 May 2024 17:46:20 +0000 (12:46 -0500)] 
gh-119594: Improve pow(fraction.Fraction(), b, modulo) error message (#119593)

If one calls pow(fractions.Fraction, x, module) with modulo not None, the error message now says that the types are incompatible rather than saying pow only takes 2 arguments.  Implemented by having fractions.Fraction __pow__ accept optional modulo argument and return NotImplemented if not None.  pow() then raises with appropriate message.
---------

Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
17 months agogh-119260: Clarify is_dataclass Behavior for Subclasses in Documentation and Tests...
Aditya Borikar [Wed, 29 May 2024 17:26:22 +0000 (11:26 -0600)] 
gh-119260: Clarify is_dataclass Behavior for Subclasses in Documentation and Tests (#119480)

Co-authored-by: Carl Meyer <carl@oddbird.net>
17 months agogh-93963: Remove deprecated names from importlib.abc (#119720)
Hugo van Kemenade [Wed, 29 May 2024 17:08:27 +0000 (20:08 +0300)] 
gh-93963: Remove deprecated names from importlib.abc (#119720)

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
17 months agogh-118673: Remove shebang and executable bits from stdlib modules. (#119658)
Jason R. Coombs [Wed, 29 May 2024 16:43:19 +0000 (12:43 -0400)] 
gh-118673: Remove shebang and executable bits from stdlib modules. (#119658)

* gh-118673: Remove shebang and executable bits from stdlib modules.

* Removed shebangs and exe bits on turtledemo scripts.

The setting was inappropriate for '__main__' and inconsistent across the other modules. The scripts can still be executed directly by invoking with the desired interpreter.

17 months agogh-119721: Integrate documentation fixes into heapq module docstring. (gh-119722)
Filip Łajszczak [Wed, 29 May 2024 16:39:34 +0000 (18:39 +0200)] 
gh-119721: Integrate documentation fixes into heapq module docstring. (gh-119722)

17 months agogh-119690: Adds Unicode support for named pipes in _winapi (GH-119717)
Steve Dower [Wed, 29 May 2024 15:51:09 +0000 (16:51 +0100)] 
gh-119690: Adds Unicode support for named pipes in _winapi (GH-119717)

17 months agogh-119655: Fix reference leak in the ``_datetimemodule.c`` (gh-119713)
Kirill Podoprigora [Wed, 29 May 2024 15:43:03 +0000 (18:43 +0300)] 
gh-119655: Fix reference leak in the ``_datetimemodule.c`` (gh-119713)

17 months agogh-119273: Don't run test_ioctl in a process group (#119275)
Victor Stinner [Wed, 29 May 2024 12:44:09 +0000 (14:44 +0200)] 
gh-119273: Don't run test_ioctl in a process group (#119275)

Python test runner no longer runs tests using TTY (ex: test_ioctl) in
a process group (using setsid()). Previously, tests using TTY were
skipped.

17 months agoCI: set correct working directory for Hypothesis cache (GH-119345)
Zac Hatfield-Dodds [Wed, 29 May 2024 12:13:18 +0000 (05:13 -0700)] 
CI: set correct working directory for Hypothesis cache (GH-119345)

Set cwd for Hypothesis database

17 months agogh-119613: Soft deprecate Py_IS_NAN/INFINITY/FINITE (#119701)
Sergey B Kirpichev [Wed, 29 May 2024 10:45:14 +0000 (13:45 +0300)] 
gh-119613: Soft deprecate Py_IS_NAN/INFINITY/FINITE (#119701)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
17 months agogh-93554: add test for quickening of code in loops ending with conditional statement...
Irit Katriel [Wed, 29 May 2024 10:44:04 +0000 (11:44 +0100)] 
gh-93554: add test for quickening of code in loops ending with conditional statement (#119485)

17 months agogh-97588: Align ctypes struct layout to GCC/MSVC (GH-97702)
Matthias Görgens [Wed, 29 May 2024 10:02:53 +0000 (18:02 +0800)] 
gh-97588: Align ctypes struct layout to GCC/MSVC (GH-97702)

Structure layout, and especially bitfields, sometimes resulted in clearly
wrong behaviour like overlapping fields. This fixes

Co-authored-by: Gregory P. Smith <gps@python.org>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
17 months agogh-119689: generate stack effect metadata for pseudo instructions (#119691)
Irit Katriel [Wed, 29 May 2024 09:47:56 +0000 (10:47 +0100)] 
gh-119689: generate stack effect metadata for pseudo instructions (#119691)

17 months agogh-119661: Add _Py_SINGLETON() include in Argumenet Clinic (#119712)
Victor Stinner [Wed, 29 May 2024 09:37:04 +0000 (11:37 +0200)] 
gh-119661: Add _Py_SINGLETON() include in Argumenet Clinic (#119712)

When the _Py_SINGLETON() is used, Argument Clinic now adds an
explicit "pycore_runtime.h" include to get the macro. Previously, the
macro may or may not be included indirectly by another include.

17 months agogh-119613: Use C99+ functions instead of Py_IS_NAN/INFINITY/FINITE (#119619)
Sergey B Kirpichev [Wed, 29 May 2024 07:51:19 +0000 (10:51 +0300)] 
gh-119613: Use C99+ functions instead of Py_IS_NAN/INFINITY/FINITE (#119619)

17 months agogh-119555: catch SyntaxError from compile() in the InteractiveColoredConsole (#119557)
Sergey B Kirpichev [Wed, 29 May 2024 06:57:50 +0000 (09:57 +0300)] 
gh-119555: catch SyntaxError from compile() in the InteractiveColoredConsole (#119557)

17 months agogh-119704: Fix reference leak in the ``Python/Python-tokenize.c`` (#119705)
Kirill Podoprigora [Wed, 29 May 2024 06:56:44 +0000 (09:56 +0300)] 
gh-119704: Fix reference leak in the ``Python/Python-tokenize.c`` (#119705)

17 months agogh-119443: Turn off from __future__ import annotations in REPL (#119493)
Jelle Zijlstra [Wed, 29 May 2024 00:05:18 +0000 (17:05 -0700)] 
gh-119443: Turn off from __future__ import annotations in REPL (#119493)

17 months agogh-117398: Convert datetime.IsoCalendarDate To A Heap Type (gh-119637)
Eric Snow [Tue, 28 May 2024 22:42:23 +0000 (18:42 -0400)] 
gh-117398: Convert datetime.IsoCalendarDate To A Heap Type (gh-119637)

This is the only static type in the module that we will not keep static.

17 months agogh-119538: Add missing expat build dependencies (#119647)
Erlend E. Aasland [Tue, 28 May 2024 20:05:19 +0000 (22:05 +0200)] 
gh-119538: Add missing expat build dependencies (#119647)

xmltok_impl.c and xmltok_ns.c are _included_ in xmltok.c by the C
pre-processor.

17 months agoGH-119258: Handle STORE_ATTR_WITH_HINT in tier two (GH-119481)
Brandt Bucher [Tue, 28 May 2024 19:47:54 +0000 (12:47 -0700)] 
GH-119258: Handle STORE_ATTR_WITH_HINT in tier two (GH-119481)

17 months agoGH-119476: Split _CHECK_FUNCTION_VERSION out of _CHECK_FUNCTION_EXACT_ARGS (GH-119510)
Brandt Bucher [Tue, 28 May 2024 19:45:11 +0000 (12:45 -0700)] 
GH-119476: Split _CHECK_FUNCTION_VERSION out of _CHECK_FUNCTION_EXACT_ARGS (GH-119510)

17 months agogh-119118: Fix performance regression in tokenize module (#119615)
Lysandros Nikolaou [Tue, 28 May 2024 19:17:49 +0000 (21:17 +0200)] 
gh-119118: Fix performance regression in tokenize module (#119615)

* gh-119118: Fix performance regression in tokenize module

- Cache line object to avoid creating a Unicode object
  for all of the tokens in the same line.
- Speed up byte offset to column offset conversion by using the
  smallest buffer possible to measure the difference.

Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
17 months agogh-119676: remove several pseudo instructions which are use only in codegen (#119677)
Irit Katriel [Tue, 28 May 2024 19:05:38 +0000 (20:05 +0100)] 
gh-119676: remove several pseudo instructions which are use only in codegen (#119677)

17 months agogh-119011: `type.__type_params__` now return an empty tuple (#119296)
Nikita Sobolev [Tue, 28 May 2024 18:12:58 +0000 (21:12 +0300)] 
gh-119011: `type.__type_params__` now return an empty tuple (#119296)