Commit Graph

52659 Commits

Author SHA1 Message Date
Victor Stinner 30b4e9f9c4
gh-119050: Add type hints to libregrtest/results.py (#119144)
Sort also 'omitted' in TestResults.display_result().
2024-05-18 16:21:05 -04:00
Donghee Na c141d43937
gh-119132: Update sys.version to identify free-threaded or not. (gh-119134) 2024-05-18 19:44:40 +00:00
Victor Stinner 74072a3ffc
gh-119132: Log sys._is_gil_enabled() in test.pythoninfo (#119140) 2024-05-18 09:24:22 -04:00
Kirill Podoprigora 31a28cbae0
gh-119049: Defer `import warnings` in `pathlib._local` (#119111) 2024-05-17 17:12:02 +01:00
Alex Waygood 033f5c87f1
Improve `pyrepl` type-annotation coverage (#119081) 2024-05-17 06:13:24 -04:00
Kirill Podoprigora 100c7ab00a
gh-119049: Fix incorrect display of warning which is constructed by C API (GH-119063)
The source line was not displayed if the warnings module had not yet
been imported.
2024-05-16 20:27:59 +00:00
Serhiy Storchaka b6839942a8
Add Tkinter tests for different events (GH-118778) 2024-05-16 08:16:46 +00:00
Serhiy Storchaka 0152dc4ff5
gh-119064: Use os_helper.FakePath instead of pathlib.Path in tests (GH-119065) 2024-05-16 10:25:10 +03:00
Wulian233 0142a2292c
Fix typos in test_buffer.py and update numpy issue links (#118963) 2024-05-15 22:16:34 -07:00
Serhiy Storchaka 5b88d95cc5
gh-118760: Fix errors in calling Tkinter bindings on Windows (GH-118782)
For unknown reasons some arguments for Tkinter binding can be created
as a 1-tuple containing a Tcl_Obj when wantobjects is 2.
2024-05-15 19:49:00 +03:00
Thomas Grainger 7d722b7d3a
Remove references to private symbols from zipimport module docstring (GH-119015) 2024-05-15 11:21:52 -05:00
Steve Dower 94591dca51
gh-118486: Simplify test_win32_mkdir_700 to check the exact ACL (GH-119056) 2024-05-15 11:59:41 +01:00
Barney Gale 7d8725ac6f
GH-74033: Drop deprecated `pathlib.Path` keyword arguments (#118793)
Remove support for supplying keyword arguments to `pathlib.Path()`. This
has been deprecated since Python 3.12.
2024-05-14 20:14:07 +00:00
Barney Gale fbe6a0988f
GH-101357: Suppress `OSError` from `pathlib.Path.exists()` and `is_*()` (#118243)
Suppress all `OSError` exceptions from `pathlib.Path.exists()` and `is_*()`
rather than a selection of more common errors as we do presently. Also
adjust the implementations to call `os.path.exists()` etc, which are much
faster on Windows thanks to GH-101196.
2024-05-14 17:53:15 +00:00
Erlend E. Aasland d8e0e00919
gh-118928: sqlite3: disallow sequences of params with named placeholders (#118929)
Follow-up of gh-101693. The previous DeprecationWarning is replaced with 
raising sqlite3.ProgrammingError.

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-05-14 16:10:55 +00:00
Alex Waygood a9328e2b6e
typing tests: remove some unnecessary uses of `exec()` (#119005) 2024-05-14 07:16:14 -07:00
Serhiy Storchaka 331d385af9
Add yet few cases for urlparse/urlunparse roundtrip tests (GH-119031)
Add yet few cases for urlparse/urlunparse tests
2024-05-14 16:59:21 +03:00
Serhiy Storchaka e237b25a4f
gh-67693: Fix urlunparse() and urlunsplit() for URIs with path starting with multiple slashes and no authority (GH-113563) 2024-05-14 12:24:37 +03:00
Tian Gao f526314194
gh-58933: Make pdb return to caller frame correctly when f_trace is not set (#118979) 2024-05-13 13:38:21 +01:00
Jacob Walls 9c15202441
gh-87106: Fix inspect.signature.bind() handling of positional-only arguments with **kwargs (GH-103404) 2024-05-13 10:56:09 +03:00
Nikita Sobolev ec1398e117
gh-118899: Add tests for `NotImplemented` attribute access (#118902) 2024-05-12 14:00:49 +00:00
Savannah Ostrowski 5b941e57c7
GH-118844: Fix build failures when combining --disable-gil with --enable-experimental-jit (GH-118935) 2024-05-11 16:19:31 -07:00
Nice Zombies abead548af
gh-117655: Prevent `test_strptime` from raising a DeprecationWarning (GH-117668)
* Fix `test_strptime` raises a DeprecationWarning
* Ignore deprecation warnings where appropriate.
* Update Lib/test/datetimetester.py

This is follow on work to silence unnecessary warnings from the test suite that changes for https://github.com/python/cpython/issues/70647 added.
2024-05-11 14:46:07 -07:00
d.grigonis cd4cfa6ed2
gh-118932: ChainMap.__contains__ performance improvement (gh-118946) 2024-05-11 15:55:23 -05:00
Tian Gao 35c436186b
gh-118921: Add `copy()` method for `FrameLocalsProxy` (#118923) 2024-05-10 15:53:10 -07:00
Hugo van Kemenade a019347947
gh-118924: Remove `sqlite3.version` and `sqlite3.version_info` (#118925) 2024-05-10 20:42:34 +00:00
Sam Gross b309c8ebff
gh-118846: Fix free-threading test failures when run sequentially (#118864)
The free-threaded build currently immortalizes some objects once the
first thread is started. This can lead to test failures depending on the
order in which tests are run. This PR addresses those failures by
suppressing immortalization or skipping the affected tests.
2024-05-10 16:29:29 -04:00
Victor Stinner aa36f83c16
gh-118702: Implement vectorcall for BaseException (#118703)
* BaseException_vectorcall() now creates a tuple from 'args' array.
* Creation an exception using BaseException_vectorcall() is now a
  single function call, rather than having to call
  BaseException_new() and then BaseException_init().
  Calling BaseException_init() is inefficient since it overrides
  the 'args' attribute.
* _PyErr_SetKeyError() now uses PyObject_CallOneArg() to create the
  KeyError instance to use BaseException_vectorcall().
2024-05-10 21:08:24 +02:00
Jelle Zijlstra ec9d12be96
Rename typing._collect_parameters (#118900)
Unfortunately, released versions of typing_extensions
monkeypatch this function without the extra parameter, which makes
it so things break badly if current main is used with typing_extensions.

Fortunately, the monkeypatching is not needed on Python 3.13, because CPython
now implements PEP 696. By renaming the function, we prevent the monkeypatch
from breaking typing.py internals.

We keep the old name (raising a DeprecationWarning) to help other external users who call it.
2024-05-10 16:55:49 +00:00
Mark Shannon f5c6b9977a
GH-118910: Less boilerplate in the tier 2 optimizer (#118913) 2024-05-10 17:43:23 +01:00
Barney Gale f772d0d08a
GH-78707: Drop deprecated `pathlib.PurePath.[is_]relative_to()` arguments (#118780)
Remove support for supplying additional positional arguments to
`PurePath.relative_to()` and `is_relative_to()`. This has been deprecated
since Python 3.12.
2024-05-10 15:53:46 +00:00
Jelle Zijlstra 13d7cf997b
gh-118895: Call PyType_Ready() on typing.NoDefault (#118897) 2024-05-10 08:42:00 -07:00
Dobatymo e85e8deaf3
gh-118209: Add Windows structured exception handling to mmap module (GH-118213) 2024-05-10 10:47:30 +01:00
Jelle Zijlstra 68fbc00dc8
gh-118851: Default ctx arguments to AST constructors to Load() (#118854)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-05-09 15:30:14 -07:00
Sam Gross 1b1db2fd9a
gh-118846: Fix PGO tests in free-threaded build (#118862)
Avoid immortalizing objects in tests that verify garbage collection of
classes or modules.

This fixes test_ordered_dict and test_struct.
2024-05-09 16:06:20 -04:00
Kirill Podoprigora c3643a1214
gh-118817: Fix `asyncio REPL` on Windows (#118819) 2024-05-09 08:20:46 -07:00
Jelle Zijlstra 35b5eaa176
gh-118767: Improve tests and docs for bool(NotImplemented) (#118813) 2024-05-09 13:52:08 +00:00
Steve Dower 82acc5f211
gh-118802: Fix ACL use in test for non-English Windows (GH-118831) 2024-05-09 13:59:18 +01:00
Radislav Chugunov 7c87ce777b
gh-103956: Fix `trace` output in case of missing source line (GH-103958)
Print only filename with lineno if linecache.getline() returns an empty string.
2024-05-09 12:09:44 +00:00
Nikita Sobolev da090f1658
gh-118805: Remove type, choices, metavar params of `BooleanOptionalAction` (#118806)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-05-09 11:46:45 +00:00
Hugo van Kemenade c68acb1384
gh-118798: Remove deprecated isdst parameter from `email.utils.localtime` (#118799) 2024-05-09 03:17:02 -06:00
Nikita Sobolev fa9b9cb113
gh-118033: Fix `__weakref__` not set for generic dataclasses (#118099) 2024-05-09 11:36:17 +03:00
Raymond Hettinger e8cbcf4955
GH-101588: Remove deprecated pickle/copy/deepcopy from itertools (gh-118816) 2024-05-09 03:31:47 -05:00
Kirill Podoprigora 027e6d88fb
[tests]: Mark ``test_statistics.test_kde_random`` with a ``requires_resource('cpu')`` decorator (#118801)
Mark test_kde_random with a requires_resource('cpu') decorator
2024-05-09 11:16:37 +03:00
Nikita Sobolev 2f4db5a04d
gh-118803: Remove `ByteString` from `typing` and `collections.abc` (#118804) 2024-05-09 00:37:55 +01:00
Yutian Li 8d84120b41
Fixing a typo in test_cmd_line.py (#118728) 2024-05-08 19:58:48 +00:00
Jelle Zijlstra 3c079a0203
gh-118767: Make bool(NotImplemented) raise TypeError (#118775) 2024-05-08 11:12:00 -07:00
Jelle Zijlstra aac6b019fe
gh-118772: Allow TypeVars without a default to follow those with a default when constructing aliases (#118774) 2024-05-08 09:54:51 -07:00
Thomas Wouters 2268289a47 Python 3.13.0b1 2024-05-08 11:21:00 +02:00
trag1c c4f9823be2
gh-118671: Updated dead ActiveState links (#118730)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
2024-05-08 01:06:38 -06:00
Tim Peters 2f0a338be6
gh-118610: Centralize power caching in `_pylong.py` (#118611)
A new `compute_powers()` function computes all and only the powers of the base the various base-conversion functions need, as efficiently as reasonably possible (turns out that invoking `**`is needed at most once). This typically gives a few % speedup, but the primary point is to simplify the base-conversion functions, which no longer need their own, ad hoc, and less efficient power-caching schemes.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-05-07 19:09:09 -05:00
Pablo Galindo Salgado 37959e25cb
gh-118518: Check for perf version and not kernel version in test_perf_profiler (#118640) 2024-05-07 20:41:07 +01:00
Sam Gross 2c19987db5
gh-118729: Temporarily skip `test_multiprocessing_pool_circular_import` (#118732)
The `pool_in_threads.py` test file may crash in free-threaded builds,
which can lead to the Tsan test hanging. Skip it for now until we fix
the underlying issue.
2024-05-07 21:27:28 +02:00
Pablo Galindo Salgado a94ac56628
gh-111201: Allow pasted code to contain multiple statements in the REPL (#118712)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-05-07 16:01:49 +00:00
Lysandros Nikolaou e5413ec783
gh-118682: Revert forcing str commands, allow class commands in pyrepl (#118709) 2024-05-07 14:31:56 +00:00
Jelle Zijlstra 71080b8a0f
gh-118660: Add second type parameter to (Async)ContextManager (#118681)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-05-07 14:16:05 +00:00
Pablo Galindo Salgado 7d90b8aadb
gh-111201: Allow bracketed paste to work (GH-118700) 2024-05-07 12:54:56 +00:00
Nikita Sobolev ad3d877a12
Remove several unused imports in `_pyrepl` (#118668) 2024-05-07 13:43:18 +01:00
Serhiy Storchaka 65f5e586a1
gh-66410: Do not stringify arguments of Tkinter callback (GH-98592)
Callbacks registered in the tkinter module now take arguments as
various Python objects (int, float, bytes, tuple), not just str.
To restore the previous behavior set tkinter module global wantobject to 1
before creating the Tk object or call the wantobject() method of the Tk object
with argument 1.
Calling it with argument 2 restores the current default behavior.
2024-05-07 12:07:32 +00:00
Nikita Sobolev b60d4c0d53
gh-118090: Improve error message for empty type param brackets (GH-118091) 2024-05-07 14:01:06 +02:00
Hugo van Kemenade 04859228aa
gh-118518: Rename `PYTHONPERFJITSUPPORT` and `-X perfjit` with underscores (#118693) 2024-05-07 11:47:21 +00:00
Alex Waygood 0f8a07d158
gh-118418: Deprecate failing to pass a value to the *type_params* parameter of some private `typing` APIs (#118695) 2024-05-07 11:12:28 +00:00
Nice Zombies 6f768b71ba
gh-118119: Re-use `sep` in `posixpath.expanduser()` (GH-118120) 2024-05-07 12:50:40 +02:00
chrysn 1e428426c8
gh-118650: Exclude `_repr_*` methods from Enum's _sunder_ reservation (GH-118651) 2024-05-07 12:35:51 +02:00
Youfu Zhang fe47d9bee3
gh-118314: Fix padding edge case in binascii.a2b_base64 strict mode (GH-118320)
Fix an edge case in `binascii.a2b_base64` strict mode, where
excessive padding was not detected when no padding is necessary.

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
2024-05-07 11:18:45 +02:00
wim glenn b7778d5902
Fix typo inaccuracy in _bootstrap_external.py (GH-118619) 2024-05-07 10:52:48 +02:00
Ali Hamdan de1428f8c2
gh-62090: Simplify argparse usage formatting (GH-105039)
Rationale
=========

argparse performs a complex formatting of the usage for argument grouping
and for line wrapping to fit the terminal width. This formatting has been
a constant source of bugs for at least 10 years (see linked issues below)
where defensive assertion errors are triggered or brackets and paranthesis
are not properly handeled.

Problem
=======

The current implementation of argparse usage formatting relies on regular
expressions to group arguments usage only to separate them again later
with another set of regular expressions. This is a complex and error prone
approach that caused all the issues linked below. Special casing certain
argument formats has not solved the problem. The following are some of
the most common issues:
- empty `metavar`
- mutually exclusive groups with `SUPPRESS`ed arguments
- metavars with whitespace
- metavars with brackets or paranthesis

Solution
========

The following two comments summarize the solution:
- https://github.com/python/cpython/issues/82091#issuecomment-1093832187
- https://github.com/python/cpython/issues/77048#issuecomment-1093776995

Mainly, the solution is to rewrite the usage formatting to avoid the
group-then-separate approach. Instead, the usage parts are kept separate
and only joined together at the end. This allows for a much simpler
implementation that is easier to understand and maintain. It avoids the
regular expressions approach and fixes the corresponding issues.

This closes the following GitHub issues:
-  #62090
-  #62549
-  #77048
-  #82091
-  #89743
-  #96310
-  #98666

These PRs become obsolete:
-  #15372
-  #96311
2024-05-07 09:28:51 +02:00
John Sirois 49258efada
gh-118107: Fix zipimporter ZIP64 handling. (GH-118108)
Add missing import to code that handles too large files and offsets.
Use list, not tuple, for a mutable sequence.

Add tests to prevent similar mistakes.

---------

Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
2024-05-07 09:23:27 +02:00
Tian Gao 0d9148823d
gh-118414: Fix assertion in YIELD_VALUE when tracing lines or instrs (#118683) 2024-05-06 21:22:59 -07:00
Eric Snow b2cd54a4fb
gh-117953: Always Run Extension Init Func in Main Interpreter First (gh-118157)
This change makes sure all extension/builtin modules have their init function run first by the main interpreter before proceeding with import in the original interpreter (main or otherwise).  This means when the import of a single-phase init module fails in an isolated subinterpreter, it won't tie any global state/callbacks to the subinterpreter.
2024-05-07 04:21:51 +00:00
James Hilton-Balfe e7dafdc224
gh-110209: Add __class_getitem__ for generator and coroutine (#110212) 2024-05-06 18:41:32 -07:00
Barney Gale b4bdf83cc6
GH-116380: Revert move of pathlib globbing code to `pathlib._glob` (#118678)
The previous change made the `glob` module slower to import, because it
imported `pathlib._glob` and hence the rest of `pathlib`.

Reverts a40f557d7b.
2024-05-07 00:32:48 +00:00
Dino Viehland ff6cbb2503
gh-112075: use per-thread dict version pool (#118676)
use thread state set of dict versions
2024-05-07 00:22:26 +00:00
Sam Gross 723d4d2fe8
gh-118527: Intern code consts in free-threaded build (#118667)
We already intern and immortalize most string constants. In the
free-threaded build, other constants can be a source of reference count
contention because they are shared by all threads running the same code
objects.
2024-05-06 20:12:39 -04:00
Jeong, YunWon 8d8275b0cf
gh-118473: Fix set_asyncgen_hooks not to be partially set when arguments are invalid (#118474) 2024-05-06 17:02:52 -07:00
Dino Viehland e272195b3e
gh-118362: Skip tests when threading isn't available (#118666)
* Skip tests when threads aren't available

* Use ThreadPoolExecutor
2024-05-06 16:45:04 -07:00
Dino Viehland 636b8d94c9
gh-112075: Fix race in constructing dict for instance (#118499) 2024-05-06 23:31:09 +00:00
Jelle Zijlstra e0422198fb
gh-117486: Improve behavior for user-defined AST subclasses (#118212)
Now, such classes will no longer require changes in Python 3.13 in the normal case.
The test suite for robotframework passes with no DeprecationWarnings under this PR.

I also added a new DeprecationWarning for the case where `_field_types` exists
but is incomplete, since that seems likely to indicate a user mistake.
2024-05-06 15:57:27 -07:00
denballakh 040571f258
fix typo in `_pyrepl.pager`: `plainpager` -> `plain_pager` (#118675) 2024-05-06 22:56:28 +00:00
Jelle Zijlstra 8419f01673
gh-118647: Add defaults to typing.Generator and typing.AsyncGenerator (#118648)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2024-05-06 22:35:06 +00:00
Łukasz Langa 9fd33af5ac
Test premium Mac builders (#118672) 2024-05-07 00:08:17 +02:00
Mark Shannon 616b745b89
GH-115709: Invalidate executors when a local variable is changed via frame.f_locals (#118639)
Also fix unrelated assert in debug Tier2/JIT builds.
2024-05-06 21:21:06 +00:00
Dino Viehland 00d913c671
gh-118415: Fix issues with local tracing being enabled/disabled on a function (#118496) 2024-05-06 13:06:09 -07:00
Łukasz Langa 9bf00322ba
gh-118628: Don't display pyrepl warning on Windows (#118665) 2024-05-06 19:35:22 +00:00
Tian Gao e5353d49dc
GH-83151: Add closure support to pdb (GH-111094) 2024-05-06 11:34:13 -07:00
Dino Viehland 5a1618a2c8
gh-118362: Fix thread safety around lookups from the type cache in the face of concurrent mutators (#118454)
Add _PyType_LookupRef and use incref before setting attribute on type
Makes setting an attribute on a class and signaling type modified atomic
Avoid adding re-entrancy exposing the type cache in an inconsistent state by decrefing after type is updated
2024-05-06 10:50:35 -07:00
Thomas Grainger e5c699280d
GH-117714: implement athrow().close() and asend().close() using throw (GH-117906)
* GH-117714: replace athrow().close() and asend().close() stubs with implimentations

* test athrow().close() and asend().close() raises RuntimeError

* 📜🤖 Added by blurb_it.

* Update Objects/genobject.c

Co-authored-by: Petr Viktorin <encukou@gmail.com>

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2024-05-06 17:13:15 +00:00
Serhiy Storchaka 1ff626ebda
gh-71592: Add ability to trace Tcl commands executed by Tkinter (GH-118291)
This is an experimental feature, for internal use.

Setting tkinter._debug = True before creating the root window enables
printing every executed Tcl command (or a Tcl command equivalent to the
used Tcl C API).

This will help to convert a Tkinter example into Tcl script to check
whether the issue is caused by Tkinter or exists in the underlying Tcl/Tk
library.
2024-05-06 20:12:51 +03:00
Serhiy Storchaka 709ca90a00
gh-118271: Support more options for reading/writing images in Tkinter (GH-118273)
* Add PhotoImage.read() to read an image from a file.
* Add PhotoImage.data() to get the image data.
* Add background and grayscale parameters to PhotoImage.write().
2024-05-06 15:06:06 +00:00
Serhiy Storchaka 1b639a04ca
gh-118225: Support more options for copying images in Tkinter (GH-118228)
* Add the PhotoImage method copy_replace() to copy a region
  from one image to other image, possibly with pixel zooming and/or
  subsampling.
* Add from_coords parameter to PhotoImage methods copy(), zoom() and subsample().
* Add zoom and subsample parameters to PhotoImage method copy().
2024-05-06 17:33:15 +03:00
Xie Yanbo c3f4a6b524
Fix typo in Lib/zipfile/_path/__init__.py (#118622) 2024-05-06 13:58:27 +00:00
Serhiy Storchaka 0085c3ae8f
gh-116871: Improve name suggestions in tracebacks (GH-116930)
Only include underscored names in name suggestions for AttributeError and
ImportError if the original name was underscored.
2024-05-06 15:53:15 +03:00
Serhiy Storchaka d6fa1d4bee
gh-66543: Add mimetypes.guess_file_type() (GH-117258) 2024-05-06 15:50:52 +03:00
Pablo Galindo Salgado d3c7821335
gh-111201: Use a more common constant in completion tests in test_pyrepl (#118638) 2024-05-06 10:56:47 +00:00
Lysandros Nikolaou 8e750b83a8
gh-111201: Fix event queue tests for pyrepl (#118635) 2024-05-06 10:50:42 +01:00
Serhiy Storchaka 153b3f7530
gh-118465: Add __firstlineno__ attribute to class (GH-118475)
It is set by compiler with the line number of the first line of
the class definition.
2024-05-06 12:02:37 +03:00
Pieter Eendebak 05adfbba2a
gh-95382: Improve performance of json encoder with indent (GH-118105) 2024-05-06 11:04:39 +03:00
Terry Jan Reedy 7758be4318
gh-78955: Use user-selected color theme for Help => IDLE Doc (#9502) 2024-05-06 03:55:56 -04:00
Barney Gale d8d94911e2
Move pathlib implementation out of `__init__.py` (#118582)
Use the `__init__.py` file only for imports that define the API, following the example of asyncio.
2024-05-05 20:57:19 +01:00
Pablo Galindo Salgado f27f8c790a
gh-111201: A new Python REPL (GH-111567)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Marta Gómez Macías <mgmacias@google.com>
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-05-05 21:32:23 +02:00