Commit graph

7832 commits

Author SHA1 Message Date
Donghee Na
5ec52c35eb
[3.12] gh-112087: Fix reduce logic for the empty reverse iterator for list (gh-115471) 2024-02-14 18:44:26 +00:00
Miss Islington (bot)
5c21f3d9e5
[3.12] gh-113560: Improve docstrings for set.issubset() and set.issuperset() (GH-113562) (GH-114644)
(cherry picked from commit 11c582235d)

Co-authored-by: Charlie Zhao <zhaoyu_hit@qq.com>
2024-01-27 11:29:26 +00:00
Miss Islington (bot)
b201a6a1f1
[3.12] gh-106293: Fix typos in Objects/object_layout.md (GH-106294) (#114158)
(cherry picked from commit 60ca37fdee)

Co-authored-by: Mano Sriram <mano.sriram0@gmail.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2024-01-16 23:35:20 +00:00
Alex Waygood
d3f2051eec
[3.12] Document the co_lines method on code objects (#113682) (#113686)
(cherry-picked from commit f1f8392432)

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2024-01-03 20:09:15 +00:00
Hugo van Kemenade
2ddee2e245
[3.12] gh-110383: Improve accuracy of str.split() and str.rsplit() docstrings (GH-113355) (#113379)
Co-authored-by: Erlend E. Aasland <erlend@python.org>
2023-12-22 00:43:28 -07:00
Victor Stinner
f27271619e
[3.12] gh-112125: Fix None.__ne__(None) returning NotImplemented instead of … (#112827)
gh-112125: Fix None.__ne__(None) returning NotImplemented instead of False (#112504)

(cherry picked from commit 9c3458e058)

Co-authored-by: andrewluotechnologies <44252973+andrewluotechnologies@users.noreply.github.com>
2023-12-07 13:41:00 +00:00
Miss Islington (bot)
29a5ff0068
[3.12] gh-112625: Protect bytearray from being freed by misbehaving iterator inside bytearray.join (GH-112626) (GH-112693)
(cherry picked from commit 0e732d0997)

Co-authored-by: chilaxan <chilaxan@gmail.com>
2023-12-04 08:46:40 +00:00
Miss Islington (bot)
7eff607deb
[3.12] gh-111058: Change coro.cr_frame/gen.gi_frame to be None for a closed coroutine/generator. (GH-112428) (#112589) 2023-12-01 14:13:15 +00:00
Miss Islington (bot)
0aceac557d
[3.12] gh-109894: Fix initialization of static MemoryError in subinterpreter (gh-110911) (gh-111238)
Fixes GH-109894

* set `interp.static_objects.last_resort_memory_error.args` to empty tuple to avoid crash on `PyErr_Display()` call
* allow `_PyExc_InitGlobalObjects()` to be called on subinterpreter init

---------

(cherry picked from commit 47d3e2ed93)

Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2023-11-27 19:41:53 -07:00
Eric Snow
4f71f1680d
[3.12] gh-106931: Intern Statically Allocated Strings Globally (gh-107272) (gh-110713)
We tried this before with a dict and for all interned strings.  That ran into problems due to interpreter isolation.  However, exclusively using a per-interpreter cache caused some inconsistency that can eliminate the benefit of interning.  Here we circle back to using a global cache, but only for statically allocated strings.  We also use a more-basic _Py_hashtable_t for that global cache instead of a dict.

Ideally we would only have the global cache, but the optional isolation of each interpreter's allocator means that a non-static string object must not outlive its interpreter.  Thus we would have to store a copy of each such interned string in the global cache, tied to the main interpreter.

(cherry-picked from commit b72947a8d2)
2023-11-27 23:51:12 +00:00
Tian Gao
3210e3c6cc
[3.12] GH-109052: Use the base opcode when comparing code objects (GH-112329) 2023-11-23 10:18:17 -08:00
Miss Islington (bot)
cf8c830755
[3.12] gh-112266: Remove (if defined) part from __dict__ and __weakref__ docstrings (GH-112268) (#112270)
gh-112266: Remove `(if defined)` part from `__dict__` and `__weakref__` docstrings (GH-112268)
(cherry picked from commit f8129146ef)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-11-19 18:59:50 +00:00
Miss Islington (bot)
4f976c3b9a
[3.12] gh-110543: Fix CodeType.replace in presence of comprehensions (GH-110586) (#111866)
gh-110543: Fix CodeType.replace in presence of comprehensions (GH-110586)
(cherry picked from commit 0b718e6407)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-11-08 20:48:18 +00:00
Miss Islington (bot)
0bbdfe611a
[3.12] GH-94438: Restore ability to jump over None tests (GH-111243)
(cherry picked from commit 6640f1d8d2)
Co-authored-by: Savannah Ostrowski <sostrowski@microsoft.com>
2023-10-24 06:39:26 +00:00
Miss Islington (bot)
27d5ea291c
[3.12] gh-110782: Fix crash when TypeVar is constructed with keyword args (GH-110784) (#110787)
gh-110782: Fix crash when TypeVar is constructed with keyword args (GH-110784)
(cherry picked from commit d2a536b170)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-10-12 23:24:37 +00:00
Alex Waygood
25bf0564c4
[3.12] Fix typos in docs and comments (#109619) (#109621)
Fix typos in docs and comments (#109619)

Co-authored-by: Heinz-Alexander Fuetterer <35225576+afuetterer@users.noreply.github.com>
2023-10-02 17:34:49 +00:00
Miss Islington (bot)
d533ab17ec
[3.12] gh-108732: include comprehension locals in frame.f_locals (GH-109026) (#109097)
gh-108732: include comprehension locals in frame.f_locals (GH-109026)
(cherry picked from commit f2584eade3)

Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-09-12 15:50:29 +02:00
Shantanu
2979cee1af
[3.12] gh-108915: Removes extra backslashes in str.split docstring (GH-109044). (#109061)
* [3.12] gh-108915: Removes extra backslashes in str.split docstring (GH-109044).
(cherry picked from commit e7d5433f94)

Co-authored-by: Daniel Weiss <134341009+justdan6@users.noreply.github.com>

* re-clinic

---------

Co-authored-by: Daniel Weiss <134341009+justdan6@users.noreply.github.com>
2023-09-08 15:19:38 +02:00
Miss Islington (bot)
09877a15d5
[3.12] gh-108295: Fix crashes with TypeVar weakrefs (GH-108517) (#108527)
gh-108295: Fix crashes with TypeVar weakrefs (GH-108517)
(cherry picked from commit 482fad7f01)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-08-27 16:12:57 +02:00
Miss Islington (bot)
3e20303717
[3.12] gh-107913: Fix possible losses of OSError error codes (GH-107930) (#108523)
gh-107913: Fix possible losses of OSError error codes (GH-107930)

Functions like PyErr_SetFromErrno() and SetFromWindowsErr() should be
called immediately after using the C API which sets errno or the Windows
error code.
(cherry picked from commit 2b15536fa9)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-08-27 01:24:40 +02:00
Serhiy Storchaka
9864f9a7c7
[3.12] gh-86457: Fix signature for code.replace() (GH-23199) (#107744)
* [3.12] gh-86457: Fix signature for code.replace() (GH-23199)

Also add support of @text_signature in Argument Clinic..
(cherry picked from commit 0e6e32fb84)

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

* Update 2023-08-07-16-30-48.gh-issue-95065.-im4R5.rst
2023-08-16 14:27:32 +02:00
Eric Snow
aa9707dda9
[3.12] gh-107080: Fix Py_TRACE_REFS Crashes Under Isolated Subinterpreters (#107751)
* Unrevert "[3.12] gh-107080: Fix Py_TRACE_REFS Crashes Under Isolated Subinterpreters (gh-107567) (#107599)".

This reverts commit 6e4eec7606 (gh-107648).

* Initialize each interpreter's refchain properly.

* Skip test_basic_multiple_interpreters_deleted_no_reset on tracerefs builds.
2023-08-16 12:03:05 +02:00
Miss Islington (bot)
431ce239d2
[3.12] gh-107810: Improve DeprecationWarning for metaclasses with custom tp_new (GH-107834) (#107864)
gh-107810: Improve DeprecationWarning for metaclasses with custom tp_new (GH-107834)

(cherry picked from commit 16dcce2176)

Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
2023-08-11 16:12:50 +02:00
Eric Snow
6e4eec7606
[3.12] gh-107630: Revert "[3.12] gh-107080: Fix Py_TRACE_REFS Crashes Under Isolated Subinterpreters (gh-107567) (#107599)" (#107648)
Revert "[3.12] gh-107080: Fix Py_TRACE_REFS Crashes Under Isolated Subinterpreters (gh-107567) (#107599)"

This reverts commit 58af2293c5.
2023-08-05 13:44:54 +02:00
Miss Islington (bot)
58af2293c5
[3.12] gh-107080: Fix Py_TRACE_REFS Crashes Under Isolated Subinterpreters (gh-107567) (#107599)
gh-107080: Fix Py_TRACE_REFS Crashes Under Isolated Subinterpreters (gh-107567)

The linked list of objects was a global variable, which broke isolation between interpreters, causing crashes. To solve this, we've moved the linked list to each interpreter.
(cherry picked from commit 58ef741867)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2023-08-04 00:18:29 +02:00
Miss Islington (bot)
b68faa3fa3
[3.12] gh-106092: Fix use-after-free crash in frame_dealloc (GH-106875) (#107532)
gh-106092: Fix use-after-free crash in frame_dealloc (GH-106875)

It was possible for the trashcan to delay the deallocation of a
PyFrameObject until after its corresponding _PyInterpreterFrame has
already been freed.  So frame_dealloc needs to avoid dereferencing the
f_frame pointer unless it first checks that the pointer still points
to the interpreter frame within the frame object.

(cherry picked from commit 557b05c7a5)

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Co-authored-by: Anders Kaseorg <andersk@mit.edu>
2023-08-01 12:42:55 +02:00
Miss Islington (bot)
8f080a290b
[3.12] gh-102509: Start initializing ob_digit of _PyLongValue (GH-102510) (#107464)
gh-102509: Start initializing `ob_digit` of `_PyLongValue` (GH-102510)
(cherry picked from commit fc130c47da)

Co-authored-by: Illia Volochii <illia.volochii@gmail.com>
2023-07-31 14:27:59 +02:00
Mark Shannon
0902afbae2
[3.12] GH-106895: Raise a ValueError when attempting to disable events that cannot be disabled. (GH-107337) (GH-107351) 2023-07-28 10:53:33 +01:00
Miss Islington (bot)
57ef065eb3
[3.12] gh-101524: Only Use Public C-API in the _xxsubinterpreters Module (gh-105258) (gh-107303)
The _xxsubinterpreters module was meant to only use public API.  Some internal C-API usage snuck in over the last few years (e.g. gh-28969).  This fixes that.
(cherry picked from commit e6373c0d8b)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2023-07-27 13:15:47 -06:00
Miss Islington (bot)
3923639a77
[3.12] gh-102304: Rename _Py_IncRefTotal_DO_NOT_USE_THIS() (GH-107193) (#107199)
gh-102304: Rename _Py_IncRefTotal_DO_NOT_USE_THIS() (GH-107193)

* Rename _Py_IncRefTotal_DO_NOT_USE_THIS() to _Py_INCREF_IncRefTotal()
* Rename _Py_DecRefTotal_DO_NOT_USE_THIS() to _Py_DECREF_DecRefTotal()
* Remove temporary _Py_INC_REFTOTAL() and _Py_DEC_REFTOTAL() macros
(cherry picked from commit 8ebc9fc321)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-07-24 22:59:51 +02:00
Miss Islington (bot)
d0176ed911
[3.12] gh-105699: Fix an Interned Strings Crasher (gh-106930) (#106963)
gh-105699: Fix an Interned Strings Crasher (gh-106930)

A static (process-global) str object must only have its "interned" state cleared when no longer interned in any interpreters.  They are the only ones that can be shared by interpreters so we don't have to worry about any other str objects.

We trigger clearing the state with the main interpreter, since no other interpreters may exist at that point and _PyUnicode_ClearInterned() is only called during interpreter finalization.

We do not address here the fact that a string will only be interned in the first interpreter that interns it.  In any subsequent interpreters str.state.interned is already set so _PyUnicode_InternInPlace() will skip it.  That needs to be addressed separately from fixing the crasher.
(cherry picked from commit 87e7cb09e4)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2023-07-21 22:28:22 +02:00
Miss Islington (bot)
957f14d0de
[3.12] gh-105699: Fix a Crasher Related to a Deprecated Global Variable (gh-106923) (#106964)
gh-105699: Fix a Crasher Related to a Deprecated Global Variable (gh-106923)

There was a slight race in _Py_ClearFileSystemEncoding() (when called from _Py_SetFileSystemEncoding()), between freeing the value and setting the variable to NULL, which occasionally caused crashes when multiple isolated interpreters were used.  (Notably, I saw at least 10 different, seemingly unrelated spooky-action-at-a-distance, ways this crashed. Yay, free threading!)  We avoid the problem by only setting the global variables with the main interpreter (i.e. runtime init).
(cherry picked from commit 0ba07b2108)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2023-07-21 22:27:52 +02:00
Miss Islington (bot)
d671c6567a
[3.12] gh-106719: Fix __annotations__ getter and setter in the type and module types (GH-106720) (GH-106848)
gh-106719: Fix __annotations__ getter and setter in the type and module types (GH-106720)

No longer suppress arbitrary errors. Simplify the code.
(cherry picked from commit e1c295e3da)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-07-18 10:01:22 +03:00
Miss Islington (bot)
4f3edd6b53
[3.12] gh-105235: Prevent reading outside buffer during mmap.find() (GH-105252) (#106708)
gh-105235: Prevent reading outside buffer during mmap.find() (GH-105252)

* Add a special case for s[-m:] == p in _PyBytes_Find

* Add tests for _PyBytes_Find

* Make sure that start <= end in mmap.find
(cherry picked from commit ab86426a34)

Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
2023-07-14 22:15:14 -04:00
Miss Islington (bot)
58f9c8889d
[3.12] gh-106403: Restore weakref support for TypeVar and friends (GH-106418) (#106635)
gh-106403: Restore weakref support for TypeVar and friends (GH-106418)
(cherry picked from commit 945d3cbf2e)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-07-11 16:15:30 +00:00
Miss Islington (bot)
41057b2ffe
[3.12] gh-105227: Add PyType_GetDict() (GH-105747) (#106600)
gh-105227: Add PyType_GetDict() (GH-105747)

This compensates for static builtin types having `tp_dict` set to `NULL`.

(cherry picked from commit a840806d33)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2023-07-10 17:12:15 +00:00
Miss Islington (bot)
bb17e6f5de
[3.12] gh-105340: include hidden fast-locals in locals() (GH-105715) (#106470)
gh-105340: include hidden fast-locals in locals() (GH-105715)

* gh-105340: include hidden fast-locals in locals()
(cherry picked from commit 104d7b760f)

Co-authored-by: Carl Meyer <carl@oddbird.net>
2023-07-05 23:31:37 +00:00
Miss Islington (bot)
c4298d5c64
[3.12] gh-105486: Change the repr of ParamSpec list of args in GenericAlias (GH-105488) (#106297)
gh-105486: Change the `repr` of `ParamSpec` list of args in `GenericAlias` (GH-105488)
(cherry picked from commit eb7d6e7ad8)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-07-01 00:32:44 +00:00
Miss Islington (bot)
2405929c35
[3.12] Fix possible refleak in CodeType.replace() (GH-106243) (GH-106244)
Fix possible refleak in CodeType.replace() (GH-106243)

A reference to c_code was leaked if PySys_Audit() failed.
(cherry picked from commit 3c70d467c1)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-06-29 21:41:01 +03:00
Miss Islington (bot)
e0fa531d7a
[3.12] gh-106033: Get rid of PyDict_GetItem in _PyFunction_FromConstructor (GH-106044) (GH-106228)
gh-106033: Get rid of PyDict_GetItem in _PyFunction_FromConstructor (GH-106044)
(cherry picked from commit 08c08d21b0)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-06-29 13:45:39 +03:00
Serhiy Storchaka
9cd366462b
[3.12] gh-106033: Get rid of new occurrences of PyDict_GetItem and Py… (#106041)
[3.12] gh-106033: Get rid of new occurrences of PyDict_GetItem and PyObject_HasAttr (GH-106034)

These functions are broken by design because they discard any exceptions raised
inside, including MemoryError and KeyboardInterrupt.  They should not be
used in new code.
(cherry picked from commit 1d33d53780)
2023-06-24 16:36:34 -07:00
Miss Islington (bot)
2eed1f5868
[3.12] gh-103968: PyType_FromMetaclass: Allow metaclasses with tp_new=NULL (GH-105386) (GH-105697)
gh-103968: PyType_FromMetaclass: Allow metaclasses with tp_new=NULL (GH-105386)
(cherry picked from commit 2b90796be6)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2023-06-12 16:24:21 +00:00
Miss Islington (bot)
ed038953fc
[3.12] gh-105375: Improve error handling in PyUnicode_BuildEncodingMap() (GH-105491) (#105661)
Bail on first error to prevent exceptions from possibly being overwritten.
(cherry picked from commit 555be81026)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-06-11 20:01:18 +00:00
Miss Islington (bot)
7c298d2dc5
[3.12] Miscellaneous improvements to the typing docs (GH-105529) (#105567)
Miscellaneous improvements to the typing docs (GH-105529)

Mostly, these are changes so that we use shorter sentences and shorter paragraphs. In particular, I've tried to make the first sentence introducing each object in the typing API short and declarative.
(cherry picked from commit 8e755923c9)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-06-09 15:37:33 +00:00
Miss Islington (bot)
77c03a3b72
[3.12] gh-100227: Lock Around Modification of the Global Allocators State (gh-105516) (gh-105532)
The risk of a race with this state is relatively low, but we play it safe anyway. We do avoid using the lock in performance-sensitive cases where the risk of a race is very, very low.
(cherry picked from commit 68dfa49627)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2023-06-08 22:35:53 +00:00
Miss Islington (bot)
2d9ead219e
[3.12] GH-105162: Account for INSTRUMENTED_RESUME in gen.close/throw. (GH-105187) (#105378)
GH-105162: Account for `INSTRUMENTED_RESUME` in gen.close/throw. (GH-105187)
(cherry picked from commit 601ae09f0c)

Co-authored-by: Mark Shannon <mark@hotpy.org>
2023-06-06 14:06:44 +00:00
Miss Islington (bot)
3e7ddc29a3
[3.12] gh-98963: Restore the ability to have a dict-less property. (GH-105262) (#105297)
gh-98963: Restore the ability to have a dict-less property. (GH-105262)

Ignore doc string assignment failures in `property` as has been the
behavior of all past Python releases.  (the docstring is discarded)
(cherry picked from commit 418befd75d)

This fixes a behavior regression in 3.12beta1 where an AttributeError was being raised in a situation it has never been in the past. It keeps the existing unusual single situation where AttributeError does get raised.

Existing widely deployed projects depend on this not raising an exception.

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-06-05 03:45:12 +00:00
Miss Islington (bot)
d57ee813eb
[3.12] gh-104614: Make Sure ob_type is Always Set Correctly by PyType_Ready() (gh-105122) (gh-105211)
When I added the relevant condition to type_ready_set_bases() in gh-103912, I had missed that the function also sets tp_base and ob_type (if necessary).  That led to problems for third-party static types.

We fix that here, by making those extra operations distinct and by adjusting the condition to be more specific.
(cherry picked from commit 1469393)

Co-authored-by: Eric Snow ericsnowcurrently@gmail.com
2023-06-01 23:06:38 +00:00
Miss Islington (bot)
c38ceb032d
[3.12] gh-105020: Share tp_bases and tp_mro Between Interpreters For All Static Builtin Types (gh-105115) (gh-105124)
In gh-103912 we added tp_bases and tp_mro to each PyInterpreterState.types.builtins entry.  However, doing so ignored the fact that both PyTypeObject fields are public API, and not documented as internal (as opposed to tp_subclasses).  We address that here by reverting back to shared objects, making them immortal in the process.
(cherry picked from commit 7be667d)

Co-authored-by: Eric Snow ericsnowcurrently@gmail.com
2023-06-01 22:24:55 +00:00
Irit Katriel
b45df737d4
[3.12] gh-105071: add PyUnstable_Exc_PrepReraiseStar to expose except* implementation in the unstable API (GH-105072) (#105095)
(cherry picked from commit b7aadb4583)
2023-05-30 16:50:23 +01:00