Commit graph

1334 commits

Author SHA1 Message Date
Serhiy Storchaka
d4234937a1
[3.11] gh-112716: Fix SystemError when __builtins__ is not a dict (GH-112770) (GH-113105)
It was raised in two cases:
* in the import statement when looking up __import__
* in pickling some builtin type when looking up built-ins iter, getattr, etc.

(cherry picked from commit 1161c14e8c)
2023-12-14 12:59:33 +00:00
Nikita Sobolev
e16922f070
[3.11] gh-109216: Fix possible memory leak in BUILD_MAP (#109323)
* [3.11] gh-109216: Fix possible memory leak in `BUILD_MAP`

* Add NEWS

* Update Python/ceval.c

Co-authored-by: Kumar Aditya <kumaraditya@python.org>

---------

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2023-10-12 12:52:03 +00:00
Miss Islington (bot)
f21c09ca03
[3.11] gh-110237: Check PyList_Append for errors in _PyEval_MatchClass (GH-110238) (#110512)
gh-110237: Check `PyList_Append` for errors in `_PyEval_MatchClass` (GH-110238)
(cherry picked from commit dd9d781da3)

Co-authored-by: denballakh <47365157+denballakh@users.noreply.github.com>
2023-10-08 00:29:46 +00:00
Victor Stinner
b55cf2c2d8
[3.11] gh-104690: thread_run() checks for tstate dangling pointer (#109056) (#109134)
gh-104690: thread_run() checks for tstate dangling pointer (#109056)

thread_run() of _threadmodule.c now calls
_PyThreadState_CheckConsistency() to check if tstate is a dangling
pointer when Python is built in debug mode.

Rename ceval_gil.c is_tstate_valid() to
_PyThreadState_CheckConsistency() to reuse it in _threadmodule.c.

(cherry picked from commit f63d37877a)
2023-09-08 11:10:33 +00:00
Brandt Bucher
fbb6def08a
[3.11] GH-104405: Add missing PEP 523 checks (GH-104441) 2023-05-12 23:03:47 +00:00
Mark Shannon
d149f15d63
[3.11] gh-101975: Fixed a potential SegFault on garbage collection (GH-102803) (GH-102807)
Authored-by: gaogaotiantian <gaogaotiantian@hotmail.com>
2023-03-20 14:42:15 +00:00
Miss Islington (bot)
1633aea0e4
[3.11] gh-101967: add a missing error check (GH-101968) (#102015)
gh-101967: add a missing error check (GH-101968)
(cherry picked from commit 89413bbccb)

Co-authored-by: Eclips4 <80244920+Eclips4@users.noreply.github.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2023-02-21 13:01:15 +00:00
Łukasz Langa
955ba2839b
[3.11] gh-101072: support default and kw default in PyEval_EvalCodeEx for 3.11+ (GH-101127) (#101636)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Matthieu Dartiailh <m.dartiailh@gmail.com>
2023-02-07 13:36:35 +00:00
Brandt Bucher
2182a71eed
[3.11] GH-99729: Unlink frames before clearing them (#100047) 2022-12-06 17:02:19 +00:00
Hood Chatham
a06fb519af
[3.11] GH-99460: Emscripten trampolines on optimized METH_O and METH_NOARGS code paths (gh-99461) (#99514)
Manual backport of GH-99461.
2022-11-16 08:09:34 -08:00
Brandt Bucher
1119ee4f7e
[3.11] GH-99298: Don't perform jumps before error handling (GH-99343) 2022-11-11 11:30:21 +00:00
Brandt Bucher
0a67f82eb1
[3.11] GH-93354: Fix PRECALL's adaptive backoff (GH-98011) 2022-10-12 16:04:47 -07:00
Miss Islington (bot)
6a646dd1ff
GH-96975: Skip incomplete frames in PyEval_GetFrame (GH-97018)
(cherry picked from commit 8fd2c3b75b)

Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
2022-09-22 10:17:53 -07:00
Brandt Bucher
fb87aaafba
Remove a stray DISPATCH() (GH-97004) 2022-09-22 09:18:37 -07:00
Miss Islington (bot)
32d80decbf
GH-96864: Check for error between line and opcode events (GH-96880)
(cherry picked from commit c10e33ac11)

Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
2022-09-20 10:49:01 -07:00
Miss Islington (bot)
c4cf745c72
GH-96754: Check whether the interpreter frame is complete before creating frame object. (GH-96776) (#96787)
(cherry picked from commit 12c5f328d2)

Co-authored-by: Mark Shannon <mark@hotpy.org>

Co-authored-by: Mark Shannon <mark@hotpy.org>
2022-09-13 11:56:27 +01:00
Miss Islington (bot)
7033dc8adc
GH-96678: Fix undefined behavior in ceval.c (GH-96708)
(cherry picked from commit 50a70a083d)

Co-authored-by: Mark Shannon <mark@hotpy.org>
2022-09-10 06:58:45 -07:00
Mark Shannon
5586da65e2
[3.11] GH-96636: Remove all uses of NOTRACE_DISPATCH (GH-96643) (#96688)
Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
(cherry picked from commit aa3b4cf779)
2022-09-09 09:24:44 -07:00
Miss Islington (bot)
a389fdb095
GH-96572: fix use after free in trace refs build mode (GH-96618)
(cherry picked from commit 67444902a0)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-09-06 11:28:18 -07:00
Miss Islington (bot)
00566a8124
GH-90081: Run python tracers at full speed (GH-95328) (#95363)
(cherry picked from commit b8b2990fb3)

Co-authored-by: Mark Shannon <mark@hotpy.org>

Co-authored-by: Mark Shannon <mark@hotpy.org>
2022-07-29 09:43:52 +01:00
Mark Shannon
e5ff5ec3ff
[3.11] GH-94739: Backport GH-94958 to 3.11 (#94965) 2022-07-25 12:11:06 +01:00
Brandt Bucher
5a48ab01e9
[3.11] GH-95113: Don't use EXTENDED_ARG_QUICK in unquickened code (GH-95121) (GH-95143)
(cherry picked from commit e402b26b7f)
2022-07-22 11:56:10 -07:00
Kumar Aditya
7a341724e4
[3.11] GH-93252: Fix error handling for failed Python calls (GH-94693) (GH-94708)
Automerge-Triggered-By: GH:tiran
2022-07-09 05:09:15 -07:00
Christian Heimes
36a3372d51
[3.11] gh-94215: Fix error handling for line-tracing events (GH-94681) (GH-94688)
* Re-enable crasher
* Fix error handling for line-tracing events
* blurb add
(cherry picked from commit 23ee4a8067)

Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
2022-07-08 15:25:53 +02:00
Łukasz Langa
5f4a16b291
[3.11] gh-94510: Raise on re-entrant calls to sys.setprofile and sys.settrace (GH-94511) (GH-94578)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
(cherry picked from commit 40d81fd63b)
2022-07-05 21:02:43 +02:00
Mark Shannon
113b309f18
[3.11] GH-93354: Use exponential backoff to avoid excessive specialization attempts (GH-93355) (GH-93379)
Co-authored-by: Mark Shannon <mark@hotpy.org>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2022-06-30 23:03:37 +02:00
Miss Islington (bot)
fdc008138e
gh-91719: Reload opcode on unknown error so that C can optimize the dispatching in ceval.c (GH-94364) (#94453)
(cherry picked from commit ea39b77de9)

Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
2022-06-30 09:11:05 -07:00
Christian Heimes
9140c413d0
[3.11] GH-93516: Drop broken assert, fixes GH-93769 (GH-94411) 2022-06-29 13:53:56 +01:00
Mark Shannon
3b4f5ed168
[3.11] GH-93516: Backport GH-93769 (GH-94231)
* Store offset of first traceable instruction to avoid having to recompute it all the time when tracing.
2022-06-28 16:30:22 +01:00
Mark Shannon
3ece6e6feb
[3.11] GH-93516: Backport GH-93769: Speedup line number checks when tracing (GH-94127)
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
2022-06-22 16:32:02 +01:00
Victor Stinner
96254a9acd
gh-93937, C API: Move PyFrame_GetBack() to Python.h (#93938) (#94000)
Move the follow functions and type from frameobject.h to pyframe.h,
so the standard <Python.h> provide frame getter functions:

* PyFrame_Check()
* PyFrame_GetBack()
* PyFrame_GetBuiltins()
* PyFrame_GetGenerator()
* PyFrame_GetGlobals()
* PyFrame_GetLasti()
* PyFrame_GetLocals()
* PyFrame_Type

Remove #include "frameobject.h" from many C files. It's no longer
needed.

(cherry picked from commit 27b9894033)
2022-06-20 15:47:41 +02:00
Eric Snow
36374251aa
[3.11] bpo-40514: Drop EXPERIMENTAL_ISOLATED_SUBINTERPRETERS (gh-93185) (GH-93306)
(cherry picked from commit caa279d6fd)

This was added for bpo-40514 (gh-84694) to test out a per-interpreter GIL.  However, it has since proven unnecessary to keep the experiment in the repo.  (It can be done as a branch in a fork like normal.)  So here we are removing:

* the configure option
* the macro
* the code enabled by the macro

Automerge-Triggered-By: GH:ericsnowcurrently
2022-05-27 17:56:30 -07:00
Miss Islington (bot)
307dacd651
gh-91924: Fix __lltrace__ for non-UTF-8 stdout encoding (GH-93199)
Fix __lltrace__ debug feature if the stdout encoding is not UTF-8.

If the stdout encoding is not UTF-8, the first call to
lltrace_resume_frame() indirectly sets lltrace to 0 when calling
unicode_check_encoding_errors() which calls
encodings.search_function().
(cherry picked from commit 5695c0e0a2)

Co-authored-by: Victor Stinner <vstinner@python.org>
2022-05-25 03:11:46 -07:00
Miss Islington (bot)
2e8b2d0ee2
GH-92236: Remove spurious "line" event when starting coroutine or generator. (GH-92722) (GH-92772)
(cherry picked from commit 22a1db378c)
2022-05-13 11:52:54 +01:00
Miss Islington (bot)
3d1ad42591
Update outdated LOAD_METHOD comments in Python/ceval.c (GH-92641)
(cherry picked from commit bdf9969197)

Co-authored-by: Crowthebird <78076854+thatbirdguythatuknownot@users.noreply.github.com>
2022-05-12 05:59:36 -07:00
Mark Shannon
f8a2fab212
GH-92239: Make sure that PEP 523 is supported, even when specializing first. (GH-92245) 2022-05-04 09:31:21 -06:00
Victor Stinner
d716a0dfe2
Use static inline function Py_EnterRecursiveCall() (#91988)
Currently, calling Py_EnterRecursiveCall() and
Py_LeaveRecursiveCall() may use a function call or a static inline
function call, depending if the internal pycore_ceval.h header file
is included or not. Use a different name for the static inline
function to ensure that the static inline function is always used in
Python internals for best performance. Similar approach than
PyThreadState_GET() (function call) and _PyThreadState_GET() (static
inline function).

* Rename _Py_EnterRecursiveCall() to _Py_EnterRecursiveCallTstate()
* Rename _Py_LeaveRecursiveCall() to _Py_LeaveRecursiveCallTstate()
* pycore_ceval.h: Rename Py_EnterRecursiveCall() to
  _Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() and
  _Py_LeaveRecursiveCall()
2022-05-04 13:30:23 +02:00
Dennis Sweeney
868b1afa05
gh-92063: Enforce types in specialized PRECALL opcodes (GH-92068)
* Check the types of PRECALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS

* fix PRECALL_NO_KW_METHOD_DESCRIPTOR_NOARGS as well

* fix PRECALL_NO_KW_METHOD_DESCRIPTOR_O

* fix PRECALL_NO_KW_METHOD_DESCRIPTOR_FAST
2022-04-30 12:35:33 -06:00
Dennis Sweeney
37c6db60f9
gh-91869: Fix tracing of specialized instructions with extended args (GH-91945) 2022-04-27 22:36:34 -06:00
Victor Stinner
64a54e511d
gh-91719: Add pycore_opcode.h internal header file (#91906)
Move the following API from Include/opcode.h (public C API) to a new
Include/internal/pycore_opcode.h header file (internal C API):

* EXTRA_CASES
* _PyOpcode_Caches
* _PyOpcode_Deopt
* _PyOpcode_Jump
* _PyOpcode_OpName
* _PyOpcode_RelativeJump
2022-04-26 00:14:30 +02:00
Guido van Rossum
2f233fceae
gh-89279: In ceval.c, redefine some macros for speed (#32387)
Macros Py_DECREF, Py_XDECREF, Py_IS_TYPE, _Py_atomic_load_32bit_impl
and _Py_DECREF_SPECIALIZED are redefined as macros
that completely replace the inline functions of the same name.
These three came out in the top four of functions that (in MSVC)
somehow weren't inlined.

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
2022-04-22 07:46:26 -07:00
Guido van Rossum
f8dc6186d1
GH-91719: Make MSVC generate somewhat faster switch code (#91718)
Apparently a switch on an 8-bit quantity where all cases are
present generates a more efficient jump (doing only one indexed
memory load instead of two).

So we make opcode and use_tracing uint8_t, and generate a macro
full of extra `case NNN:` lines for all unused opcodes.

See https://github.com/faster-cpython/ideas/issues/321#issuecomment-1103263673
2022-04-21 11:53:57 -07:00
Dennis Sweeney
d7d7e6c007
Cast to (destructor) to fix compiler warnings (GH-91711) 2022-04-20 16:15:45 +01:00
Dennis Sweeney
da6c78584b
gh-90667: Add specializations of Py_DECREF when types are known (GH-30872) 2022-04-19 19:02:19 +01:00
Dennis Sweeney
cec5d858f5
gh-91625: Don't ignore extended args of adaptive opcodes (GH-91626) 2022-04-17 14:04:29 -04:00
Dennis Sweeney
37965d2fb4
gh-78607: Replace __ltrace__ with __lltrace__ (GH-91619) 2022-04-16 18:57:00 -04:00
Dennis Sweeney
8560f4a0f2
gh-91462: Make lltrace output human-readable. (GH-91463)
* Transform opcodes into opnames
* Print the whole stack at each opcode, and eliminate prtrace output at each (push/pop/stackadj)
* Display info about the function at each resume_frame
2022-04-16 17:36:29 -04:00
Irit Katriel
ea2ae02607
gh-91276: Make JUMP_IF_TRUE_OR_POP/JUMP_IF_FALSE_OR_POP relative (GH-32215) 2022-04-15 20:19:24 +01:00
Dennis Sweeney
72965981d1
gh-90699: Use _Py_STR(empty) instead of PyUnicode_New(0, 0) for BUILD_STRING (GH-91476) 2022-04-15 23:21:35 +09:00
Irit Katriel
dd207a6ac5
bpo-47120: make POP_JUMP_IF_TRUE/FALSE/NONE/NOT_NONE relative (GH-32400) 2022-04-11 10:40:24 +01:00