]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
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)

17 months agogh-117865: Defer import of re in ast (#119546)
Jelle Zijlstra [Tue, 28 May 2024 18:04:08 +0000 (11:04 -0700)] 
gh-117865: Defer import of re in ast (#119546)

This is used only by ast.get_source_segment(), so it seems sensible to avoid importing it.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
17 months agogh-117398: gh-119655: datetime: Init static state once & don't free it (GH-119662)
Petr Viktorin [Tue, 28 May 2024 17:27:52 +0000 (19:27 +0200)] 
gh-117398: gh-119655: datetime: Init static state once & don't free it (GH-119662)

- While datetime uses global state, only initialize it once.
- While `capi` is static, don't free it (thanks @neonene in https://github.com/python/cpython/pull/119641/files#r1616710048)

17 months agogh-119581: Add a test of InitVar with name shadowing (#119582)
Steven Troxler [Tue, 28 May 2024 17:18:57 +0000 (10:18 -0700)] 
gh-119581: Add a test of InitVar with name shadowing (#119582)

17 months agogh-119396: Optimize unicode_repr() (#119617)
Victor Stinner [Tue, 28 May 2024 16:05:20 +0000 (18:05 +0200)] 
gh-119396: Optimize unicode_repr() (#119617)

Use stringlib to specialize unicode_repr() for each string kind
(UCS1, UCS2, UCS4).

Benchmark:

+-------------------------------------+---------+----------------------+
| Benchmark                           | ref     | change2              |
+=====================================+=========+======================+
| repr('abc')                         | 100 ns  | 103 ns: 1.02x slower |
+-------------------------------------+---------+----------------------+
| repr('a' * 100)                     | 369 ns  | 369 ns: 1.00x slower |
+-------------------------------------+---------+----------------------+
| repr(('a' + squote) * 100)          | 1.21 us | 946 ns: 1.27x faster |
+-------------------------------------+---------+----------------------+
| repr(('a' + nl) * 100)              | 1.23 us | 907 ns: 1.36x faster |
+-------------------------------------+---------+----------------------+
| repr(dquote + ('a' + squote) * 100) | 1.08 us | 858 ns: 1.25x faster |
+-------------------------------------+---------+----------------------+
| Geometric mean                      | (ref)   | 1.16x faster         |
+-------------------------------------+---------+----------------------+

17 months agogh-119659: Move `@no_rerun` to `test.support` (#119660)
Nikita Sobolev [Tue, 28 May 2024 15:50:50 +0000 (18:50 +0300)] 
gh-119659: Move `@no_rerun` to `test.support` (#119660)

17 months agogh-118824: Remove deprecated `master_open` and `slave_open` from `pty` (#118826)
Nikita Sobolev [Tue, 28 May 2024 13:42:35 +0000 (16:42 +0300)] 
gh-118824: Remove deprecated `master_open` and `slave_open` from `pty` (#118826)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
17 months ago[doc] Clarify the nature of the root logger in the `logging` documentation (GH-119440)
Justin Kunimune [Tue, 28 May 2024 10:31:20 +0000 (06:31 -0400)] 
[doc] Clarify the nature of the root logger in the `logging` documentation (GH-119440)

Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
17 months agogh-116860: Remove outdated `test_parserhack` from `test_future` (#116861)
Nikita Sobolev [Tue, 28 May 2024 09:16:52 +0000 (12:16 +0300)] 
gh-116860: Remove outdated `test_parserhack` from `test_future` (#116861)

17 months agogh-117557: Improve error messages when a string, bytes or bytearray of length 1 are...
Serhiy Storchaka [Tue, 28 May 2024 09:01:37 +0000 (12:01 +0300)] 
gh-117557: Improve error messages when a string, bytes or bytearray of length 1 are expected (GH-117631)

17 months agoFix typos in comments (#119645)
Xie Yanbo [Tue, 28 May 2024 07:53:32 +0000 (15:53 +0800)] 
Fix typos in comments (#119645)

17 months agogh-119311: Fix name mangling with PEP 695 generic classes (#119464)
Jelle Zijlstra [Tue, 28 May 2024 02:50:38 +0000 (19:50 -0700)] 
gh-119311: Fix name mangling with PEP 695 generic classes (#119464)

Fixes #119311. Fixes #119395.

17 months agogh-117398: Add multiphase support to _datetime (gh-119373)
Erlend E. Aasland [Mon, 27 May 2024 22:02:46 +0000 (00:02 +0200)] 
gh-117398: Add multiphase support to _datetime (gh-119373)

This is minimal support.  Subinterpreters are not supported yet.  That will be addressed in a later change.

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
17 months agogh-119584: Fix test_import Failed Assertion (gh-119623)
Eric Snow [Mon, 27 May 2024 19:35:30 +0000 (15:35 -0400)] 
gh-119584: Fix test_import Failed Assertion (gh-119623)

The fix in gh-119561 introduced an assertion that doesn't hold true if any of the three new test extension modules are loaded more than once.  This is fine normally but breaks if the new test_check_state_first() is run more than once, which happens for refleak checking and with the regrtest --forever flag.  We fix that here by clearing each of the three modules after loading them.  We also tweak a check in _modules_by_index_check().

17 months agoMisc cleanups and wording improvements for the itertools docs (gh-119626)
Raymond Hettinger [Mon, 27 May 2024 18:22:57 +0000 (13:22 -0500)] 
Misc cleanups and wording improvements for the itertools docs (gh-119626)

17 months agoWithdraw most of my ownership in favor of Mark (#119611)
Guido van Rossum [Mon, 27 May 2024 18:07:16 +0000 (11:07 -0700)] 
Withdraw most of my ownership in favor of Mark (#119611)

17 months agoDocs: Move inline JavaScript to own file to reduce duplication (#119541)
Hugo van Kemenade [Mon, 27 May 2024 18:04:34 +0000 (21:04 +0300)] 
Docs: Move inline JavaScript to own file to reduce duplication (#119541)

17 months agogh-119580: Improve version added section for convenience variable (#119583)
Tian Gao [Mon, 27 May 2024 17:54:23 +0000 (10:54 -0700)] 
gh-119580: Improve version added section for convenience variable (#119583)

17 months agoDocs: Only install sphinx-autobuild for `make htmllive` (#119607)
Hugo van Kemenade [Mon, 27 May 2024 17:29:27 +0000 (20:29 +0300)] 
Docs: Only install sphinx-autobuild for `make htmllive` (#119607)

17 months agoDocs: Add class role for IPV{4,6}Address and fix a typo (#118059)
Rafael Fontenelle [Mon, 27 May 2024 12:39:59 +0000 (09:39 -0300)] 
Docs: Add class role for IPV{4,6}Address and fix a typo (#118059)

Add class role for IPV{4,6}Address and fix a typo

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
17 months agoGH-117283: Add doc warning for `PyTuple_SetItem` refcount > 1 (#117916)
Savannah Ostrowski [Mon, 27 May 2024 12:20:28 +0000 (05:20 -0700)] 
GH-117283: Add doc warning for `PyTuple_SetItem` refcount > 1 (#117916)

17 months agogh-119467: Fix Py_buffer.format type and correct documentation typo (#119475)
Aditya Borikar [Mon, 27 May 2024 12:16:13 +0000 (06:16 -0600)] 
gh-119467: Fix Py_buffer.format type and correct documentation typo (#119475)

17 months ago``Include/internal/pycore_import.h``: Fix typo (#119586)
Kirill Podoprigora [Mon, 27 May 2024 11:35:36 +0000 (14:35 +0300)] 
``Include/internal/pycore_import.h``: Fix typo (#119586)

Fix typo

17 months agoFix typos in HISTORY documentation (#119453)
Xie Yanbo [Mon, 27 May 2024 07:57:23 +0000 (15:57 +0800)] 
Fix typos in HISTORY documentation (#119453)

17 months agoRe-order imports to align with zipp 3.18.2 (#119587)
Jason R. Coombs [Mon, 27 May 2024 01:33:16 +0000 (21:33 -0400)] 
Re-order imports to align with zipp 3.18.2 (#119587)

17 months agogh-102864: Add switching frame test for pdb (#119564)
Tian Gao [Sun, 26 May 2024 17:05:23 +0000 (10:05 -0700)] 
gh-102864: Add switching frame test for pdb (#119564)

17 months agogh-119562: Remove unused private string constants from `ast.py` (#119576)
Alex Waygood [Sun, 26 May 2024 13:31:02 +0000 (14:31 +0100)] 
gh-119562: Remove unused private string constants from `ast.py` (#119576)

17 months agogh-111997: Fix argument count for LINE event and clarify type of argument counts...
scoder [Sun, 26 May 2024 12:37:33 +0000 (14:37 +0200)] 
gh-111997: Fix argument count for LINE event and clarify type of argument counts. (#119179)

17 months agogh-119562: Remove AST nodes deprecated since Python 3.8 (#119563)
Alex Waygood [Sun, 26 May 2024 12:34:48 +0000 (13:34 +0100)] 
gh-119562: Remove AST nodes deprecated since Python 3.8 (#119563)

17 months agoUpdate README and layout.html from 3.13 to 3.14 (#119539)
Wulian233 [Sun, 26 May 2024 11:26:59 +0000 (19:26 +0800)] 
Update README and layout.html from 3.13 to 3.14 (#119539)

Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
17 months agodocs: fix a few typos identified by codespell (#119516)
Ned Batchelder [Sun, 26 May 2024 01:13:31 +0000 (21:13 -0400)] 
docs: fix a few typos identified by codespell (#119516)

17 months agoGH-82805: Fix handling of single-dot file extensions in pathlib (#118952)
Barney Gale [Sat, 25 May 2024 20:01:36 +0000 (21:01 +0100)] 
GH-82805: Fix handling of single-dot file extensions in pathlib (#118952)

pathlib now treats "`.`" as a valid file extension (suffix). This brings
it in line with `os.path.splitext()`.

In the (private) pathlib ABCs, we add a new `ParserBase.splitext()` method
that splits a path into a `(root, ext)` pair, like `os.path.splitext()`.
This method is called by `PurePathBase.stem`, `suffix`, etc. In a future
version of pathlib, we might make these base classes public, and so users
will be able to define their own `splitext()` method to control file
extension splitting.

In `pathlib.PurePath` we add optimised `stem`, `suffix` and `suffixes`
properties that don't use `splitext()`, which avoids computing the path
base name twice.

17 months agogh-119560: Drop an Invalid Assert in PyState_FindModule() (gh-119561)
Eric Snow [Sat, 25 May 2024 19:30:48 +0000 (15:30 -0400)] 
gh-119560: Drop an Invalid Assert in PyState_FindModule() (gh-119561)

The assertion was added in gh-118532 but was based on the invalid assumption that PyState_FindModule() would only be called with an already-initialized module def.  I've added a test to make sure we don't make that assumption again.