Commit Graph

29339 Commits

Author SHA1 Message Date
Petr Viktorin 31a4fb3c74
gh-119724: Revert "bpo-45759: Better error messages for non-matching 'elif'/'else' statements (#29513)" (#119974)
This reverts commit 1c8f912ebd.
2024-06-03 18:10:15 -07:00
Eric Snow 105f22ea46
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.
2024-06-03 17:09:18 -06:00
Eric Snow dba7a167db
gh-117142: Support Importing ctypes in Isolated Interpreters (gh-119991)
This makes the support official.

Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
2024-06-03 16:42:48 -06:00
Daniel Hollas 2e0aa731ae
gh-118835: pyrepl: Fix prompt length computation for custom prompts containing ANSI escape codes (#119942) 2024-06-03 18:07:06 +01:00
Victor Stinner 4e8aa32245
gh-119727: Add --single-process option to regrtest (#119728) 2024-06-03 16:34:36 +00:00
Nikita Sobolev 1d4c2e4a87
gh-119057: Use better error messages for zero division (#119066) 2024-06-03 19:03:56 +03:00
Jason R. Coombs 42a34ddb0b
gh-119588: Implement zipfile.Path.is_symlink (zipp 3.19.0). (#119591) 2024-06-03 11:13:07 -04:00
Steve Dower fd01271366
gh-119679: Ensures correct import libraries are included in Windows install packages (GH-119790) 2024-06-03 15:42:45 +01:00
Nice Zombies 4765e1fa29
gh-102511: Amend 3.13.0b1.rst (GH-119895) 2024-06-03 14:27:44 +01:00
Sergey B Kirpichev 61d3ab32da
gh-116560: Add PyLong_GetSign() public function (#116561)
Co-authored-by: Victor Stinner <vstinner@python.org>
2024-06-03 14:06:31 +02:00
Serhiy Storchaka d7fcaa73b7
gh-119838: Treat Fraction as a real value in mixed arithmetic operations with complex (GH-119839) 2024-06-03 12:29:01 +03:00
Nikita Sobolev 84c3191954
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>
2024-06-03 10:50:29 +03:00
Radislav Chugunov 52586f930f
gh-119506: fix `_io.TextIOWrapper.write()` write during flush (#119507)
Co-authored-by: Inada Naoki <songofacandy@gmail.com>
2024-06-03 16:47:36 +09:00
Mark Dickinson f79ffc879b
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>
2024-06-02 10:16:49 +01:00
Nikita Sobolev 4aed319a8e
gh-119775: Remove ability to create immutable types with mutable bases (#119776) 2024-06-02 07:27:20 +00:00
Barney Gale 53b1981fb0
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.
2024-06-01 19:49:12 +01:00
Kirill Podoprigora cf3bba3f06
gh-113892: Add a extra check to `ProactorEventLoop.sock_connect` to ensure that the given socket is in non-blocking mode (#119519) 2024-06-01 09:05:19 -07:00
Jelle Zijlstra d28afd3fa0
gh-119180: Lazily wrap annotations on classmethod and staticmethod (#119864) 2024-05-31 14:05:51 -07:00
Jelle Zijlstra 80a4e38994
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.
2024-05-31 14:05:24 -07:00
Łukasz Langa 2237946af0
gh-118894: Make asyncio REPL use pyrepl (GH-119433) 2024-05-31 22:26:02 +02:00
Sam Gross 078b8c8cf2
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.
2024-05-31 13:04:59 -04:00
Victor Stinner 64ff1e217d
gh-119770: Make termios ioctl() constants positive (#119840) 2024-05-31 17:18:40 +02:00
Sam Gross bcc1be39cb
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.
2024-05-31 10:50:52 -04:00
Steve Dower 0e8d35b931
gh-116145: Updated bundled Tcl/Tk on Windows to 8.6.14 (GH-117030) 2024-05-31 13:07:19 +01:00
Joshua Herman b9965ef282
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.
2024-05-31 10:05:09 +00:00
Christopher Chavez 94e9585e99
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.
2024-05-31 11:23:53 +03:00
Dino Viehland 0d07182821
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>
2024-05-31 09:49:03 +02:00
Serhiy Storchaka ef01e95ae3
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.
2024-05-30 23:30:57 +03:00
Sam Gross 1c04c63ced
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`.
2024-05-30 13:48:28 -04:00
Ethan Smith e50fac96e8
gh-119336: Restore removed _PyLong_NumBits() function (#119418)
It is used by the pywin32 project.
2024-05-30 14:48:18 +00:00
Barney Gale 3c890b503c
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.
2024-05-30 03:05:36 +00:00
Barney Gale a150679f90
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>
2024-05-29 20:11:30 +00:00
Sam Gross c22323cd1c
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`.
2024-05-29 15:26:04 -04:00
Steve Dower df93f5d4bf
gh-119070: Fix py.exe handling of /usr/bin/env commands missing extension (GH-119426) 2024-05-29 18:51:13 +01:00
Wim Jeantine-Glenn fcca08ec2f
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>
2024-05-29 13:46:20 -04:00
Hugo van Kemenade 0751511d24
gh-93963: Remove deprecated names from importlib.abc (#119720)
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
2024-05-29 11:08:27 -06:00
Jason R. Coombs c8b45a385a
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.
2024-05-29 12:43:19 -04:00
Steve Dower 78d697b7d5
gh-119690: Adds Unicode support for named pipes in _winapi (GH-119717) 2024-05-29 16:51:09 +01:00
Victor Stinner 1f481fd327
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.
2024-05-29 12:44:09 +00:00
Sergey B Kirpichev 0cdc5c8d54
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>
2024-05-29 10:45:14 +00:00
Matthias Görgens 18c1a8d3a8
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>
2024-05-29 12:02:53 +02:00
Irit Katriel c1e9647107
gh-119689: generate stack effect metadata for pseudo instructions (#119691) 2024-05-29 09:47:56 +00:00
Sergey B Kirpichev 86d1a1aa88
gh-119555: catch SyntaxError from compile() in the InteractiveColoredConsole (#119557) 2024-05-29 07:57:50 +01:00
Jelle Zijlstra a8e35e8eba
gh-119443: Turn off from __future__ import annotations in REPL (#119493) 2024-05-28 17:05:18 -07:00
Lysandros Nikolaou d87b015106
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>
2024-05-28 19:17:49 +00:00
Nikita Sobolev 6b240c2308
gh-119011: `type.__type_params__` now return an empty tuple (#119296) 2024-05-28 18:12:58 +00:00
Jelle Zijlstra ae11d68ab9
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>
2024-05-28 11:04:08 -07:00
Nikita Sobolev f912e5a2f6
gh-118824: Remove deprecated `master_open` and `slave_open` from `pty` (#118826)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-05-28 16:42:35 +03:00
Serhiy Storchaka b313cc68d5
gh-117557: Improve error messages when a string, bytes or bytearray of length 1 are expected (GH-117631) 2024-05-28 12:01:37 +03:00
Jelle Zijlstra a9a74da4a0
gh-119311: Fix name mangling with PEP 695 generic classes (#119464)
Fixes #119311. Fixes #119395.
2024-05-27 19:50:38 -07:00