Commit Graph

29195 Commits

Author SHA1 Message Date
Brett Simmers 853163d3b5
gh-116322: Enable the GIL while loading C extension modules (#118560)
Add the ability to enable/disable the GIL at runtime, and use that in
the C module loading code.

We can't know before running a module init function if it supports
free-threading, so the GIL is temporarily enabled before doing so. If
the module declares support for running without the GIL, the GIL is
later disabled. Otherwise, the GIL is permanently enabled, and will
never be disabled again for the life of the current interpreter.
2024-05-06 23:07:23 -04:00
James Hilton-Balfe e7dafdc224
gh-110209: Add __class_getitem__ for generator and coroutine (#110212) 2024-05-06 18:41:32 -07: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
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
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
Erlend E. Aasland 325a1da18d
gh-115119: Default to --with-system-libmpdec=yes (#118539)
Co-authored-by: Zachary Ware <zachary.ware@gmail.com>
2024-05-06 21:16:08 +02: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
Petr Viktorin 417dd3aca7
gh-116322: Rename PyModule_ExperimentalSetGIL to PyUnstable_Module_SetGIL (GH-118645) 2024-05-06 18:59:36 +02: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
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
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
Pablo Galindo Salgado 2eb99914c4
Add Lysandros Nikolaou to the News entry of gh-111201 (#118616) 2024-05-05 22:13:50 +00: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
Guido van Rossum 40cc809902
gh-117549: Don't use designated initializers in headers (#118580)
The designated initializer syntax in static inline functions in pycore_backoff.h
causes problems for C++ or MSVC users who aren't yet using C++20.
While internal, pycore_backoff.h is included (indirectly, via pycore_code.h)
by some key 3rd party software that does so for speed.
2024-05-05 19:28:55 +00:00
Guido van Rossum 9c13d9e37a
gh-74929: Rudimentary docs for PEP 667 (#118581)
This is *not* sufficient for the final 3.13 release, but it will do for beta 1:

- What's new entry
- Updated changelog entry (news blurb)
- Mention the proxy for f_globals in the datamodel and Python frame object docs

This doesn't have any C API details (what's new refers to the PEP).
2024-05-05 15:31:26 +00:00
Tian Gao 5a0022a1d7
GH-111744: Make breakpoint() enter the debugger immediately (GH-118579) 2024-05-05 07:05:01 -07:00
Nikita Sobolev 1511bc95c4
gh-101137: Add `text/x-rst` to `mimetypes` (#118593) 2024-05-05 13:39:50 +00:00
Ryan Batchelder b6f0ab5b1c
gh-83505: Add markdown mimetype mapping (#17995) 2024-05-05 13:09:59 +00:00
Hugo van Kemenade 3b32575ed6
gh-118131: Command-line interface for the `random` module (#118132) 2024-05-05 06:30:03 +00:00
Serhiy Storchaka 711c80bfca
gh-118164: Break a loop between _pydecimal and _pylong and optimize int to str conversion (GH-118483)
For converting large ints to strings, CPython invokes a function in _pylong.py,
which uses the decimal module to implement an asymptotically waaaaay
sub-quadratic algorithm. But if the C decimal module isn't available, CPython
uses _pydecimal.py instead. Which in turn frequently does str(int). If the int
is very large, _pylong ends up doing the work, which in turn asks decimal to do
"big" arithmetic, which in turn calls str(big_int), which in turn ... it can
become infinite mutual recursion.

This change introduces a different int->str function that doesn't use decimal.
It's asymptotically worse, "Karatsuba time" instead of quadratic time, so
still a huge improvement. _pylong switches to that when the C decimal isn't
available. It is also used for not too large integers (less than 450_000 bits),
where it is faster (up to 2 times for 30_000 bits) than the asymptotically
better implementation that uses the C decimal.

Co-authored-by: Tim Peters <tim.peters@gmail.com>
2024-05-05 08:20:06 +03:00
Pablo Galindo Salgado 1b22d801b8
gh-118518: Allow perf to work without frame pointers (#112254) 2024-05-05 03:07:29 +02:00
Tim Peters 999f0c5122
gh-118164: str(10**10000) hangs if the C _decimal module is missing (#118503)
* Initial stab.

* Test the tentative fix. Hangs "forever" without this change.

* Move the new test to a better spot.

* New comment to explain why _convert_to_str allows any poewr of 10.

* Fixed a comment, and fleshed out an existing test that appeared unfinished.

* Added temporary asserts. Or maybe permanent ;-)

* Update Lib/_pydecimal.py

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>

* Remove the new _convert_to_str().

Serhiy and I independently concluded that exact powers of 10
aren't possible in these contexts, so just checking the
string length is sufficient.

* At least for now, add the asserts to the other block too.

* 📜🤖 Added by blurb_it.

---------

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2024-05-04 18:22:33 -05:00
Davide Rizzo 08d169f14a
gh-109617: fix ncurses incompatibility on macOS with Xcode 15 (#111258)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-05-04 23:41:47 +02:00
Tian Gao f34e965e52
GH-111744: Support opcode events in bdb (GH-111834) 2024-05-04 07:44:49 -07:00
Tian Gao b034f14a4b
gh-74929: Implement PEP 667 (GH-115153) 2024-05-04 12:12:10 +01:00
Tian Gao 00da0afa0d
gh-113081: Print colorized exception just like built-in traceback in pdb (#113082) 2024-05-04 12:26:40 +02:00
Irit Katriel 85af789961
gh-111997: C-API for signalling monitoring events (#116413) 2024-05-04 08:23:50 +00:00
Tian Gao 9c14ed0618
gh-107674: Improve performance of `sys.settrace` (GH-117133)
* Check tracing in RESUME_CHECK

* Only change to RESUME_CHECK if not tracing
2024-05-03 19:49:24 +01:00
Tian Gao 998c3856c1
gh-83856: Honor atexit for all multiprocessing start methods (GH-114279)
Use atexit for all multiprocessing start methods to cleanup.
See the GH-114279 PR discussion and related issue for details as to why.
2024-05-03 11:45:46 -07:00
Erlend E. Aasland dd8f05fee2
gh-115119: Update macOS installer to build with libmpdec 4.0.0 (GH-118382)
Co-authored-by: Ned Deily <nad@python.org>
2024-05-03 16:49:40 +00:00
Erlend E. Aasland 1324502752
gh-115119: Update Windows installer to mpdecimal 4.0.0 (#118506) 2024-05-03 18:00:43 +02:00
Brett Simmers c2627d6eea
gh-116322: Add Py_mod_gil module slot (#116882)
This PR adds the ability to enable the GIL if it was disabled at
interpreter startup, and modifies the multi-phase module initialization
path to enable the GIL when loading a module, unless that module's spec
includes a slot indicating it can run safely without the GIL.

PEP 703 called the constant for the slot `Py_mod_gil_not_used`; I went
with `Py_MOD_GIL_NOT_USED` for consistency with gh-104148.

A warning will be issued up to once per interpreter for the first
GIL-using module that is loaded. If `-v` is given, a shorter message
will be printed to stderr every time a GIL-using module is loaded
(including the first one that issues a warning).
2024-05-03 11:30:55 -04:00
Sam Gross 2dae505e87
gh-117514: Add `sys._is_gil_enabled()` function (#118514)
The function returns `True` or `False` depending on whether the GIL is
currently enabled. In the default build, it always returns `True`
because the GIL is always enabled.
2024-05-03 11:09:57 -04:00
Carl Meyer c8deb1e4b4
gh-118513: Fix sibling comprehensions with a name bound in one and global in the other (#118526)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
2024-05-03 14:05:19 +00:00
Alexander Kanavin 37ccf16786
gh-101732: Modules/_ssl.c: use Y2038 compatible openssl function when available (GH-118425) 2024-05-03 15:34:05 +02:00
Jelle Zijlstra ca269e58c2
gh-116126: Implement PEP 696 (#116129)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2024-05-03 06:17:32 -07:00
Tian Gao 4e2caf2aa0
gh-118500: Add pdb support for zipapp (#118501) 2024-05-02 21:53:27 +01:00
infohash b28a3339e4
gh-90848: Fixed create_autospec ignoring configure_mock style kwargs (#118163) 2024-05-02 18:36:35 +01:00
Pablo Galindo Salgado 6bcbee09df
gh-93502: Add new C-API functions to trace object creation and destruction (#115945) 2024-05-02 19:30:00 +02:00
Raphael Gaschignard 2770d5caca
gh-105879: Add support for keyword arguments to eval and exec (#105885)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-05-02 08:55:29 -07:00
Sergey B Kirpichev 9789440de3
gh-82062: Fix support of parameter defaults on methods in extension modules (GH-115270)
Now inspect.signature() supports references to the module globals in
parameter defaults on methods in extension modules.  Previously it was
only supported in functions.  The workaround was to specify the fully
qualified name, including the module name.
2024-05-02 17:44:33 +03:00
Steve Dower 81939dad77
gh-118486: Support mkdir(mode=0o700) on Windows (GH-118488) 2024-05-02 15:20:43 +01:00
Crowthebird 7c97dc8c95
gh-118216: Don't consider dotted `__future__` imports (#118267) 2024-05-02 06:32:20 -07:00
Guido van Rossum a524152b8c
gh-118335: Make REGEN_JIT_COMMAND empty if tier2 interpreter enabled (#118493)
Also patch up news blurb for gh-118339
(add warning that PYTHON_UOPS is now PYTHON_JIT).
2024-05-01 16:36:29 -07:00