summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
Commit message (Collapse)AuthorAgeFilesLines
...
* bpo-42823: Fix frame lineno when frame.f_trace is set (GH-24099)Mark Shannon2021-01-051-10/+11
| | | | | | | | | * Add test for frame.f_lineno with/without tracing. * Make sure that frame.f_lineno is correct regardless of whether frame.f_trace is set. * Update importlib * Add NEWS
* bpo-42246: Make sure that `f_lasti`, and thus `f_lineno`, is set correctly ↵Mark Shannon2020-12-171-1/+5
| | | | | | | | | after raising or reraising an exception (GH-23803) * Ensure that f_lasti is set correctly after an exception is raised to conform to PEP 626. * Update importlib * Add NEWS.
* bpo-42500: Fix recursion in or after except (GH-23568)Mark Shannon2020-12-021-9/+11
| | | * Use counter, rather boolean state when handling soft overflows.
* bpo-42202: Store func annotations as a tuple (GH-23316)Yurii Karabas2020-11-251-1/+1
| | | | | | | | | | | | | Reduce memory footprint and improve performance of loading modules having many func annotations. >>> sys.getsizeof({"a":"int","b":"int","return":"int"}) 232 >>> sys.getsizeof(("a","int","b","int","return","int")) 88 The tuple is converted into dict on the fly when `func.__annotations__` is accessed first. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Inada Naoki <songofacandy@gmail.com>
* bpo-42296: On Windows, fix CTRL+C regression (GH-23257)Victor Stinner2020-11-131-5/+33
| | | | | | | | | | | On Windows, fix a regression in signal handling which prevented to interrupt a program using CTRL+C. The signal handler can be run in a thread different than the Python thread, in which case the test deciding if the thread can handle signals is wrong. On Windows, _PyEval_SignalReceived() now always sets eval_breaker to 1 since it cannot test _Py_ThreadCanHandleSignals(), and eval_frame_handle_pending() always calls _Py_ThreadCanHandleSignals() to recompute eval_breaker.
* bpo-42246: Partial implementation of PEP 626. (GH-23113)Mark Shannon2020-11-121-43/+30
| | | * Implement new line number table format, as defined in PEP 626.
* bpo-42266: Handle monkey-patching descriptors in LOAD_ATTR cache (GH-23157)Pablo Galindo2020-11-051-7/+1
|
* bpo-42099: Fix reference to ob_type in unionobject.c and ceval (GH-22829)Neil Schemenauer2020-10-271-1/+1
| | | * Use Py_TYPE() rather than o->ob_type.
* bpo-42006: Stop using PyDict_GetItem, PyDict_GetItemString and ↵Serhiy Storchaka2020-10-261-2/+9
| | | | | | | | | | | _PyDict_GetItemId. (GH-22648) These functions are considered not safe because they suppress all internal errors and can return wrong result. PyDict_GetItemString and _PyDict_GetItemId can also silence current exception in rare cases. Remove no longer used _PyDict_GetItemId. Add _PyDict_ContainsId and rename _PyDict_Contains into _PyDict_Contains_KnownHash.
* bpo-42093: Add opcode cache for LOAD_ATTR (GH-22803)Pablo Galindo2020-10-201-5/+216
|
* bpo-41756: Add PyIter_Send function (#22443)Vladimir Matveev2020-10-101-14/+7
|
* bpo-41936. Remove macros Py_ALLOW_RECURSION/Py_END_ALLOW_RECURSION (GH-22552)Serhiy Storchaka2020-10-051-3/+0
|
* bpo-21955: Change my nickname in BINARY_ADD comment (GH-22481)Victor Stinner2020-10-011-1/+1
|
* bpo-41670: Remove outdated predict macro invocation. (GH-22026)Mark Shannon2020-09-291-2/+0
| | | Remove PREDICTion of POP_BLOCK from FOR_ITER.
* bpo-40941: Fix stackdepth compiler warnings (GH-22377)Victor Stinner2020-09-231-4/+4
| | | | Explicitly cast a difference of two pointers to int: PyFrameObject.f_stackdepth is an int.
* bpo-41834: Remove _Py_CheckRecursionLimit variable (GH-22359)Victor Stinner2020-09-231-13/+3
| | | | | | | | | | Remove the global _Py_CheckRecursionLimit variable: it has been replaced by ceval.recursion_limit of the PyInterpreterState structure. There is no need to keep the variable for the stable ABI, since Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() were not usable in Python 3.8 and older: these macros accessed PyThreadState members, whereas the PyThreadState structure is opaque in the limited C API.
* bpo-41756: Introduce PyGen_Send C API (GH-22196)Vladimir Matveev2020-09-191-17/+41
| | | | | | | | | | | | | The new API allows to efficiently send values into native generators and coroutines avoiding use of StopIteration exceptions to signal returns. ceval loop now uses this method instead of the old "private" _PyGen_Send C API. This translates to 1.6x increased performance of 'await' calls in micro-benchmarks. Aside from CPython core improvements, this new API will also allow Cython to generate more efficient code, benefiting high-performance IO libraries like uvloop.
* bpo-40941: Unify implicit and explicit state in the frame and generator ↵Mark Shannon2020-07-171-16/+27
| | | | | | | objects into a single value. (GH-20803) * Merge gen and frame state variables into one. * Replace stack pointer with depth in PyFrameObject. Makes code easier to read and saves a word of memory.
* bpo-41078: Rename pycore_tupleobject.h to pycore_tuple.h (GH-21056)Victor Stinner2020-06-221-9/+9
|
* bpo-40925: Remove unused stack macro SET_VALUE (GH-20783)Dong-hee Na2020-06-111-1/+0
|
* bpo-39465: Use _PyInterpreterState_GET() (GH-20788)Victor Stinner2020-06-101-2/+2
| | | | | | | | | | | | Replace _PyThreadState_GET() with _PyInterpreterState_GET() in: * get_small_int() * gcmodule.c: add also get_gc_state() function * _PyTrash_deposit_object() * _PyTrash_destroy_chain() * warnings_get_state() * Py_GetRecursionLimit() Cleanup listnode.c: add 'parser' variable.
* bpo-40679: Fix _PyEval_EvalCode() crash if qualname is NULL (GH-20615)Victor Stinner2020-06-041-22/+36
| | | | | | | | | | If name is NULL, name is now set to co->co_name. If qualname is NULL, qualname is now set to name. qualname must not be NULL: it is used to build error messages. Cleanup also the code: declare variables where they are initialized. Rename "name" local variables to "varname" to avoid overriding "name" parameter.
* PyOS_AfterFork_Child() pass tstate to _PyEval_ReInitThreads() (GH-20598)Victor Stinner2020-06-021-3/+2
|
* PyOS_AfterFork_Child() uses PyStatus (GH-20596)Victor Stinner2020-06-021-7/+6
| | | | | | | | PyOS_AfterFork_Child() helper functions now return a PyStatus: PyOS_AfterFork_Child() is now responsible to handle errors. * Move _PySignal_AfterFork() to the internal C API * Add #ifdef HAVE_FORK on _PyGILState_Reinit(), _PySignal_AfterFork() and _PyInterpreterState_DeleteExceptMain().
* bpo-40826: Add _Py_EnsureTstateNotNULL() macro (GH-20571)Victor Stinner2020-06-011-13/+12
| | | | Add _Py_EnsureTstateNotNULL(tstate) macro: call Py_FatalError() if tstate is NULL, the error message contains the current function name.
* bpo-40679: Use the function's qualname in certain TypeErrors (GH-20236)Dennis Sweeney2020-05-221-15/+16
| | | | Patch by Dennis Sweeney.
* Fix typo in code comment in main_loop label. (GH-20068)Chris Jerdonek2020-05-151-1/+1
|
* bpo-38787: Add PyCFunction_CheckExact() macro for exact type checks (GH-20024)scoder2020-05-121-2/+2
| | | | | … now that we allow subtypes of PyCFunction. Also add PyCMethod_CheckExact() and PyCMethod_Check() for checks against the PyCMethod subtype.
* bpo-39465: Don't access directly _Py_Identifier members (GH-20043)Victor Stinner2020-05-111-1/+1
| | | | | * Replace id->object with _PyUnicode_FromId(&id) * Use _Py_static_string_init(str) macro to initialize statically name_op in typeobject.c.
* bpo-40513: Per-interpreter GIL (GH-19943)Victor Stinner2020-05-051-2/+46
| | | | | | | | In the experimental isolated subinterpreters build mode, the GIL is now per-interpreter. Move gil from _PyRuntimeState.ceval to PyInterpreterState.ceval. new_interpreter() always get the config from the main interpreter.
* bpo-40522: _PyThreadState_Swap() sets autoTSSkey (GH-19939)Victor Stinner2020-05-051-0/+13
| | | | | | | | | | | | | | | | | | In the experimental isolated subinterpreters build mode, _PyThreadState_GET() gets the autoTSSkey variable and _PyThreadState_Swap() sets the autoTSSkey variable. * Add _PyThreadState_GetTSS() * _PyRuntimeState_GetThreadState() and _PyThreadState_GET() return _PyThreadState_GetTSS() * PyEval_SaveThread() sets the autoTSSkey variable to current Python thread state rather than NULL. * eval_frame_handle_pending() doesn't check that _PyThreadState_Swap() result is NULL. * _PyThreadState_Swap() gets the current Python thread state with _PyThreadState_GetTSS() rather than _PyRuntimeGILState_GetThreadState(). * PyGILState_Ensure() no longer checks _PyEval_ThreadsInitialized() since it cannot access the current interpreter.
* Revert "bpo-40513: Per-interpreter signals pending (GH-19924)" (GH-19932)Victor Stinner2020-05-051-29/+36
| | | This reverts commit 4e01946cafca0cf49f796c3118e0d65237bcad69.
* bpo-40513: Per-interpreter recursion_limit (GH-19929)Victor Stinner2020-05-051-10/+14
| | | | | | | | | | | Move recursion_limit member from _PyRuntimeState.ceval to PyInterpreterState.ceval. * Py_SetRecursionLimit() now only sets _Py_CheckRecursionLimit of ceval.c if the current Python thread is part of the main interpreter. * Inline _Py_MakeEndRecCheck() into _Py_LeaveRecursiveCall(). * Convert _Py_RecursionLimitLowerWaterMark() macro into a static inline function.
* bpo-40513: Per-interpreter gil_drop_request (GH-19927)Victor Stinner2020-05-051-39/+36
| | | | Move gil_drop_request member from _PyRuntimeState.ceval to PyInterpreterState.ceval.
* bpo-40513: Per-interpreter signals pending (GH-19924)Victor Stinner2020-05-051-5/+5
| | | | Move signals_pending from _PyRuntime.ceval to PyInterpreterState.ceval.
* bpo-40429: PyFrame_GetCode() result cannot be NULL (GH-19772)Victor Stinner2020-04-281-6/+8
| | | Add frame_nslots() to factorize duplicate code.
* bpo-40048: Fix _PyCode_InitOpcache() error path (GH-19691)Victor Stinner2020-04-241-1/+1
| | | | | | If _PyCode_InitOpcache() fails in _PyEval_EvalFrameDefault(), use "goto exit_eval_frame;" rather than "return NULL;" to exit the function in a consistent state. For example, tstate->frame is now reset properly.
* bpo-40268: Remove unused structmember.h includes (GH-19530)Victor Stinner2020-04-151-1/+0
| | | | | | If only offsetof() is needed: include stddef.h instead. When structmember.h is used, add a comment explaining that PyMemberDef is used.
* bpo-40268: Remove explicit pythread.h includes (#19529)Victor Stinner2020-04-151-1/+0
| | | | Remove explicit pythread.h includes: it is always included by Python.h.
* bpo-40268: Move struct _gc_runtime_state to pycore_gc.h (GH-19515)Victor Stinner2020-04-141-2/+3
|
* bpo-40232: Update PyOS_AfterFork_Child() to use _PyThread_at_fork_reinit() ↵Dong-hee Na2020-04-141-2/+3
| | | | (GH-19450)
* bpo-40268: Remove a few pycore_pystate.h includes (GH-19510)Victor Stinner2020-04-141-2/+2
|
* bpo-40268: Rename _PyInterpreterState_GET_UNSAFE() (GH-19509)Victor Stinner2020-04-141-1/+1
| | | | | | | Rename _PyInterpreterState_GET_UNSAFE() to _PyInterpreterState_GET() for consistency with _PyThreadState_GET() and to have a shorter name (help to fit into 80 columns). Add also "assert(tstate != NULL);" to the function.
* bpo-40082: trip_signal() uses the main interpreter (GH-19441)Victor Stinner2020-04-081-58/+59
| | | | | | | | | | | | | | | | | | | | | | Fix the signal handler: it now always uses the main interpreter, rather than trying to get the current Python thread state. The following function now accepts an interpreter, instead of a Python thread state: * _PyEval_SignalReceived() * _Py_ThreadCanHandleSignals() * _PyEval_AddPendingCall() * COMPUTE_EVAL_BREAKER() * SET_GIL_DROP_REQUEST(), RESET_GIL_DROP_REQUEST() * SIGNAL_PENDING_CALLS(), UNSIGNAL_PENDING_CALLS() * SIGNAL_PENDING_SIGNALS(), UNSIGNAL_PENDING_SIGNALS() * SIGNAL_ASYNC_EXC(), UNSIGNAL_ASYNC_EXC() Py_AddPendingCall() now uses the main interpreter if it fails to the current Python thread state. Convert _PyThreadState_GET() and PyInterpreterState_GET_UNSAFE() macros to static inline functions.
* bpo-37127: Remove _pending_calls.finishing (GH-19439)Victor Stinner2020-04-081-16/+0
|
* bpo-40226: PyInterpreterState_Delete() deletes pending calls (GH-19436)Victor Stinner2020-04-081-31/+50
| | | | | | | | | | | | | | | PyInterpreterState_New() is now responsible to create pending calls, PyInterpreterState_Delete() now deletes pending calls. * Rename _PyEval_InitThreads() to _PyEval_InitGIL() and rename _PyEval_InitGIL() to _PyEval_FiniGIL(). * _PyEval_InitState() and PyEval_FiniState() now create and delete pending calls. _PyEval_InitState() now returns -1 on memory allocation failure. * Add init_interp_create_gil() helper function: code shared by Py_NewInterpreter() and Py_InitializeFromConfig(). * init_interp_create_gil() now also calls _PyEval_FiniGIL(), _PyEval_InitGIL() and _PyGILState_Init() in subinterpreters, but these functions now do nothing when called from a subinterpreter.
* bpo-40170: Add _PyIndex_Check() internal function (GH-19426)Victor Stinner2020-04-081-2/+3
| | | | | | | | | Add _PyIndex_Check() function to the internal C API: fast inlined verson of PyIndex_Check(). Add Include/internal/pycore_abstract.h header file. Replace PyIndex_Check() with _PyIndex_Check() in C files of Objects and Python subdirectories.
* bpo-38644: Use _PySys_Audit(): pass tstate explicitly (GH-19183)Victor Stinner2020-03-271-8/+11
| | | Add the dependency to tstate more explicit.
* bpo-38644: Pass tstate explicitly in signalmodule.c (GH-19184)Victor Stinner2020-03-261-2/+2
| | | | PyOS_InterruptOccurred() now checks _Py_ThreadCanHandleSignals() before checking if SIGINT is tripped.
* bpo-38410: Properly handle PySys_Audit() failures (GH-16657)Zackery Spytz2020-03-261-4/+6
|