summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
* bpo-40268: Rename _PyInterpreterState_GET_UNSAFE() (GH-19509)Victor Stinner2020-04-1412-24/+24
| | | | | | | 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-40268: Include explicitly pycore_interp.h (GH-19505)Victor Stinner2020-04-149-4/+14
| | | | pycore_pystate.h no longer includes pycore_interp.h: it's now included explicitly in files accessing PyInterpreterState.
* bpo-32894: Support unparsing of infinity numbers in ast_unparser.c (GH-17426)Batuhan Taşkaya2020-04-131-5/+53
|
* bpo-40268: Add pycore_runtime.h header file (GH-19493)Victor Stinner2020-04-132-4/+3
| | | | | | Move PyRuntimeState from pycore_pystate.h to pycore_runtime.h. Remove _PyGILState_check_enabled macro: access directly _PyRuntime.gilstate.check_enabled.
* bpo-40268: Add _PyInterpreterState_GetConfig() (GH-19492)Victor Stinner2020-04-139-38/+58
| | | | | | | | Don't access PyInterpreterState.config member directly anymore, but use new functions: * _PyInterpreterState_GetConfig() * _PyInterpreterState_SetConfig() * _Py_GetConfig()
* bpo-40246: Report a better error message for invalid string prefixes (GH-19476)Lysandros Nikolaou2020-04-121-0/+3
|
* bpo-39943: Add the const qualifier to pointers on non-mutable PyBytes data. ↵Serhiy Storchaka2020-04-121-1/+1
| | | | (GH-19472)
* bpo-39943: Add the const qualifier to pointers on non-mutable PyUnicode ↵Serhiy Storchaka2020-04-116-23/+21
| | | | data. (GH-19345)
* bpo-40082: trip_signal() uses the main interpreter (GH-19441)Victor Stinner2020-04-082-64/+69
| | | | | | | | | | | | | | | | | | | | | | 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-083-49/+105
| | | | | | | | | | | | | | | 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-082-3/+5
| | | | | | | | | 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-40089: Add _at_fork_reinit() method to locks (GH-19195)Victor Stinner2020-04-071-0/+20
| | | | | | | | | | | | | | | Add a private _at_fork_reinit() method to _thread.Lock, _thread.RLock, threading.RLock and threading.Condition classes: reinitialize the lock after fork in the child process; reset the lock to the unlocked state. Rename also the private _reset_internal_locks() method of threading.Event to _at_fork_reinit(). * Add _PyThread_at_fork_reinit() private function. It is excluded from the limited C API. * threading.Thread._reset_internal_locks() now calls _at_fork_reinit() on self._tstate_lock rather than creating a new Python lock object.
* bpo-40147: Fix a compiler warning on Windows in Python/compile.c (GH-19389)Zackery Spytz2020-04-061-4/+5
| | | Change the type of nkeywords to Py_ssize_t.
* closes bpo-40184: Only define pysiphash if the hash algorithm is SIPHASH24. ↵Batuhan Taşkaya2020-04-041-7/+7
| | | | (GH-19369)
* bpo-40141: Include the value in the column position for keyword AST nodes ↵Pablo Galindo2020-04-031-1/+1
| | | | (GH-19348)
* bpo-40147: Move the check for duplicate keywords to the compiler (GH-19289)Pablo Galindo2020-04-032-10/+30
|
* bpo-40141: Add line and column information to ast.keyword nodes (GH-19283)Pablo Galindo2020-04-012-5/+105
|
* bpo-39943: Clean up marshal.c. (GH-19236)Serhiy Storchaka2020-03-311-57/+31
| | | | | | * Add consts. * Remove redundant casts and checks. * Use concrete C API macros. * Avoid raising and silencing OverflowError for ints.
* Document most common signals (GH-19245)Victor Stinner2020-03-311-1/+1
| | | | Document individual signals (only the most common signals): description, default action, availability.
* bpo-32591: _PyErr_WarnUnawaitedCoroutine() sets source (GH-19247)Victor Stinner2020-03-311-3/+20
| | | | | | | | The _PyErr_WarnUnawaitedCoroutine() fallback now also sets the coroutine object as the source of the warning, as done by the Python implementation warnings._warn_unawaited_coroutine(). Moreover, don't truncate the coroutine name: Python supports arbitrary string length to format the message.
* bpo-39943: Remove unnecessary casts in import.c that remove constness (GH-19209)Andy Lester2020-03-301-2/+2
|
* bpo-38644: Use _PySys_Audit(): pass tstate explicitly (GH-19183)Victor Stinner2020-03-274-25/+31
| | | Add the dependency to tstate more explicit.
* bpo-38644: Make tstate more explicit inside pystate.c (GH-19182)Victor Stinner2020-03-261-47/+61
| | | | Fix PyInterpreterState_New(): Don't call PyErr_SetString() when there is no current Python thread state (if tstate is NULL).
* 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-38644: Add _PySys_Audit() which takes tstate (GH-19180)Victor Stinner2020-03-262-65/+112
| | | | | | | | | | | | | | | Add _PySys_Audit() function to the internal C API: similar to PySys_Audit(), but requires a mandatory tstate parameter. Cleanup sys_audit_tstate() code: remove code path for NULL tstate, since the function exits at entry if tstate is NULL. Remove also code path for NULL tstate->interp: should_audit() now ensures that it is not NULL (even if tstate->interp cannot be NULL in practice). PySys_AddAuditHook() now checks if tstate is not NULL to decide if tstate can be used or not, and tstate is set to NULL if the runtime is not initialized yet. Use _PySys_Audit() in sysmodule.c.
* bpo-38410: Properly handle PySys_Audit() failures (GH-16657)Zackery Spytz2020-03-262-10/+16
|
* bpo-40067: Improve error messages for multiple star expressions in ↵Furkan Önder2020-03-261-1/+1
| | | | | | assignments (GH-19168) Co-Authored-By: Batuhan Taşkaya <isidentical@gmail.com> Co-Authored-By: Pablo Galindo <Pablogsal@gmail.com>
* bpo-39947: Add PyThreadState_GetID() function (GH-19163)Victor Stinner2020-03-251-0/+8
| | | | Add PyThreadState_GetID() function: get the unique identifier of a Python thread state.
* bpo-39947: Add _PyThreadState_GetDict() function (GH-19160)Victor Stinner2020-03-251-9/+18
|
* bpo-39882: Add _Py_FatalErrorFormat() function (GH-19157)Victor Stinner2020-03-258-75/+125
|
* Use calloc-based functions, not malloc. (GH-19152)Andy Lester2020-03-253-12/+6
|
* bpo-40050: Fix importlib._bootstrap_external (GH-19135)Victor Stinner2020-03-241-1736/+1729
| | | | | | Remove two unused imports: _thread and _weakref. Avoid creating a new winreg builtin module if it's already available in sys.modules. The winreg module is now stored as "winreg" rather than "_winreg".
* bpo-20526: Fix PyThreadState_Clear(): don't decref frame (GH-19120)Victor Stinner2020-03-241-2/+10
| | | | | | | | PyThreadState.frame is a borrowed reference, not a strong reference: PyThreadState_Clear() must not call Py_CLEAR(tstate->frame). Remove test_threading.test_warnings_at_exit(): we cannot warranty that the Python thread state of daemon threads is cleared in a reliable way during Python shutdown.
* bpo-39999: Improve compatibility of the ast module. (GH-19056)Serhiy Storchaka2020-03-221-6/+6
| | | | | | | * Re-add removed classes Suite, slice, Param, AugLoad and AugStore. * Add docstrings for dummy classes. * Add docstrings for attribute aliases. * Set __module__ to "ast" instead of "_ast".
* bpo-22490: Remove __PYVENV_LAUNCHER__ from environment during launch (GH-9516)Ronald Oussoren2020-03-221-0/+11
| | | | | | | | | | | | | | | | | | | | | * bpo-22490: Remove "__PYVENV_LAUNCHER__" from the shell environment on macOS This changeset removes the environment varialbe "__PYVENV_LAUNCHER__" during interpreter launch as it is only needed to communicate between the stub executable in framework installs and the actual interpreter. Leaving the environment variable present may lead to misbehaviour when launching other scripts. * Actually commit the changes for issue 22490... * Correct typo Co-Authored-By: Nicola Soranzo <nicola.soranzo@gmail.com> * Run make patchcheck Co-authored-by: Jason R. Coombs <jaraco@jaraco.com> Co-authored-by: Nicola Soranzo <nicola.soranzo@gmail.com>
* bpo-40024: Add PyModule_AddType() helper function (GH-19088)Dong-hee Na2020-03-221-0/+19
|
* bpo-39946: Remove _PyThreadState_GetFrame (GH-19094)Victor Stinner2020-03-203-28/+7
| | | | | Remove _PyRuntime.getframe hook and remove _PyThreadState_GetFrame macro which was an alias to _PyRuntime.getframe. They were only exposed by the internal C API. Remove also PyThreadFrameGetter type.
* bpo-39947: Add PyThreadState_GetFrame() function (GH-19092)Victor Stinner2020-03-201-0/+8
| | | | Add PyThreadState_GetFrame() function: get the current frame of a Python thread state.
* bpo-40010: Optimize pending calls in multithreaded applications (GH-19091)Victor Stinner2020-03-201-4/+6
| | | | | | | | | | | | | | | If a thread different than the main thread schedules a pending call (Py_AddPendingCall()), the bytecode evaluation loop is no longer interrupted at each bytecode instruction to check for pending calls which cannot be executed. Only the main thread can execute pending calls. Previously, the bytecode evaluation loop was interrupted at each instruction until the main thread executes pending calls. * Add _Py_ThreadCanHandlePendingCalls() function. * SIGNAL_PENDING_CALLS() now only sets eval_breaker to 1 if the current thread can execute pending calls. Only the main thread can execute pending calls.
* bpo-40010: COMPUTE_EVAL_BREAKER() checks for subinterpreter (GH-19087)Victor Stinner2020-03-202-30/+3
| | | | | | | | | COMPUTE_EVAL_BREAKER() now also checks if the Python thread state belongs to the main interpreter. Don't break the evaluation loop if there are pending signals but the Python thread state it belongs to a subinterpeter. * Add _Py_IsMainThread() function. * Add _Py_ThreadCanHandleSignals() function.
* bpo-40010: Pass tstate to ceval GIL functions (GH-19077)Victor Stinner2020-03-202-138/+199
| | | | * Add eval_frame_handle_pending() helper function: cold code path. * Fix PyEval_ReleaseLock(): don't dereference tstate if it's NULL.
* bpo-39877: 4th take_gil() fix for daemon threads (GH-19080)Victor Stinner2020-03-191-22/+23
| | | | bpo-39877, bpo-40010: Add a third tstate_must_exit() check in take_gil() to prevent using tstate which has been freed.
* bpo-40010: Optimize signal handling in multithreaded applications (GH-19067)Victor Stinner2020-03-192-4/+23
| | | | | | | | | | | | | | | If a thread different than the main thread gets a signal, the bytecode evaluation loop is no longer interrupted at each bytecode instruction to check for pending signals which cannot be handled. Only the main thread of the main interpreter can handle signals. Previously, the bytecode evaluation loop was interrupted at each instruction until the main thread handles signals. Changes: * COMPUTE_EVAL_BREAKER() and SIGNAL_PENDING_SIGNALS() no longer set eval_breaker to 1 if the current thread cannot handle signals. * take_gil() now always recomputes eval_breaker.
* bpo-39562: Allow executing asynchronous comprehensions in the asyncio REPL ↵Batuhan Taşkaya2020-03-191-2/+5
| | | | | (GH-18968) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-40000: Improve error messages when validating invalid ast.Constant nodes ↵Batuhan Taşkaya2020-03-191-3/+5
| | | | | (GH-19055) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-39984: Move pending calls to PyInterpreterState (GH-19066)Victor Stinner2020-03-193-76/+101
| | | | | | | | | | | | | | | | | If Py_AddPendingCall() is called in a subinterpreter, the function is now scheduled to be called from the subinterpreter, rather than being called from the main interpreter. Each subinterpreter now has its own list of scheduled calls. * Move pending and eval_breaker fields from _PyRuntimeState.ceval to PyInterpreterState.ceval. * new_interpreter() now calls _PyEval_InitThreads() to create pending calls lock. * Fix Py_AddPendingCall() for subinterpreters. It now calls _PyThreadState_GET() which works in a subinterpreter if the caller holds the GIL, and only falls back on PyGILState_GetThisThreadState() if _PyThreadState_GET() returns NULL.
* bpo-39220: Do not optimise annotation if 'from __future__ import ↵Pablo Galindo2020-03-182-38/+50
| | | | | | annotations' is used (GH-17866) Do not apply AST-based optimizations if 'from __future__ import annotations' is used in order to prevent information lost in the final version of the annotations.
* bpo-39984: trip_signal() uses PyGILState_GetThisThreadState() (GH-19061)Victor Stinner2020-03-181-5/+9
| | | | | | | | | | | bpo-37127, bpo-39984: * trip_signal() and Py_AddPendingCall() now get the current Python thread state using PyGILState_GetThisThreadState() rather than _PyRuntimeState_GetThreadState() to be able to get it even if the GIL is released. * _PyEval_SignalReceived() now expects tstate rather than ceval. * Remove ceval parameter of _PyEval_AddPendingCall(): ceval is now get from tstate parameter.
* bpo-39984: Pass tstate to _PyEval_SignalAsyncExc() (GH-19049)Victor Stinner2020-03-184-22/+28
| | | | _PyEval_SignalAsyncExc() and _PyEval_FiniThreads() now expect tstate, instead of ceval.