summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* bpo-39877: Fix take_gil() for daemon threads (GH-19054)Victor Stinner2020-03-181-2/+6
| | | | bpo-39877, bpo-39984: If the thread must exit, don't access tstate to prevent a potential crash: tstate memory has been freed.
* bpo-39984: _PyThreadState_DeleteCurrent() takes tstate (GH-19051)Victor Stinner2020-03-182-29/+41
| | | | | | | | | | * _PyThreadState_DeleteCurrent() now takes tstate rather than runtime. * Add ensure_tstate_not_null() helper to pystate.c. * Add _PyEval_ReleaseLock() function. * _PyThreadState_DeleteCurrent() now calls _PyEval_ReleaseLock(tstate) and frees PyThreadState memory after this call, not before. * PyGILState_Release(): rename "tcur" variable to "tstate".
* bpo-39984: Pass tstate to handle_signals() (GH-19050)Victor Stinner2020-03-181-11/+15
| | | | handle_signals() and make_pending_calls() now expect tstate rather than runtime.
* bpo-39988: Remove ast.AugLoad and ast.AugStore node classes. (GH-19038)Serhiy Storchaka2020-03-173-173/+45
|
* bpo-39984: Add PyInterpreterState.ceval (GH-19047)Victor Stinner2020-03-172-10/+18
| | | | | | | | | | | | | | | subinterpreters: Move _PyRuntimeState.ceval.tracing_possible to PyInterpreterState.ceval.tracing_possible: each interpreter now has its own variable. Changes: * Add _ceval_state structure. * Add PyInterpreterState.ceval field. * _PyEval_EvalFrameDefault(): add ceval2 variable (struct _ceval_state*). * Rename _PyEval_Initialize() to _PyEval_InitRuntimeState(). * Add _PyEval_InitState(). * Don't export internal _Py_FinishPendingCalls() and _PyEval_FiniThreads() functions anymore.
* bpo-39987: Simplify setting lineno in the compiler. (GH-19037)Serhiy Storchaka2020-03-174-4006/+3970
|
* bpo-35370: PyEval_SetTrace() logs unraisable error (GH-18977)Victor Stinner2020-03-161-2/+8
| | | | If PySys_Audit() fails in PyEval_SetProfile() or PyEval_SetTrace(), log the error as an unraisable exception.
* bpo-37207: Add _PyArg_NoKwnames() helper function (GH-18980)Dong-hee Na2020-03-161-1/+18
|
* bpo-39638: Keep ASDL signatures in the AST nodes (GH-18515)Batuhan Taşkaya2020-03-161-120/+277
|
* bpo-39969: Remove ast.Param node class as is no longer used (GH-19020)Batuhan Taşkaya2020-03-153-46/+19
|
* bpo-39965: Correctly raise SyntaxError if await is used outside async ↵Pablo Galindo2020-03-151-4/+8
| | | | functions when PyCF_ALLOW_TOP_LEVEL_AWAIT is set (GH-19010)
* bpo-39585: Delete a pending comment in _warning.c (GH-18414)Hai Shi2020-03-141-1/+2
|
* bpo-39947: Add PyThreadState_GetInterpreter() (GH-18981)Victor Stinner2020-03-131-0/+11
| | | | Add PyThreadState_GetInterpreter(tstate): get the interpreter of a Python thread state.
* bpo-39947: Add PyInterpreterState_Get() function (GH-18979)Victor Stinner2020-03-131-3/+3
| | | | | | * Rename _PyInterpreterState_Get() to PyInterpreterState_Get() and move it the limited C API. * Add _PyInterpreterState_Get() alias to PyInterpreterState_Get() for backward compatibility with Python 3.8.
* bpo-39947: Use _PyInterpreterState_GET_UNSAFE() (GH-18978)Victor Stinner2020-03-136-15/+15
| | | | | | | Replace _PyInterpreterState_Get() function call with _PyInterpreterState_GET_UNSAFE() macro which is more efficient but don't check if tstate or interp is NULL. _Py_GetConfigsAsDict() now uses _PyThreadState_GET().
* bpo-35370: Add _PyEval_SetTrace() function (GH-18975)Victor Stinner2020-03-132-44/+102
| | | | | | | | | * sys.settrace(), sys.setprofile() and _lsprof.Profiler.enable() now properly report PySys_Audit() error if "sys.setprofile" or "sys.settrace" audit event is denied. * Add _PyEval_SetProfile() and _PyEval_SetTrace() function: similar to PyEval_SetProfile() and PyEval_SetTrace() but take a tstate parameter and return -1 on error. * Add _PyObject_FastCallTstate() function.
* bpo-38500: Add _PyInterpreterState_SetEvalFrameFunc() (GH-17340)Victor Stinner2020-03-122-9/+20
| | | | | | | | | | | | PyInterpreterState.eval_frame function now requires a tstate (Python thread state) parameter. Add private functions to the C API to get and set the frame evaluation function: * Add tstate parameter to _PyFrameEvalFunction function type. * Add _PyInterpreterState_GetEvalFrameFunc() and _PyInterpreterState_SetEvalFrameFunc() functions. * Add tstate parameter to _PyEval_EvalFrameDefault().
* Remove unused args from two pylifecycle.c functions (GH-18867)Andy Lester2020-03-121-6/+5
| | | | * Remove unused tstate argument from init_set_builtins_open() * Replace fd (int) with tstate (PyThreadState *) in in _Py_FatalError_PrintExc()
* bpo-39847: EnterNonRecursiveMutex() uses GetTickCount64() (GH-18780)bobince2020-03-111-3/+3
| | | | | | | | | | | | | | | | The 32-bit (49-day) TickCount relied on in EnterNonRecursiveMutex can overflow in the gap between the 'target' time and the 'now' time WaitForSingleObjectEx returns, causing the loop to think it needs to wait another 49 days. This is most likely to happen when the machine is hibernated during WaitForSingleObjectEx. This makes acquiring a lock/event/etc from the _thread or threading module appear to never timeout. Replace with GetTickCount64 - this is OK now Python no longer supports XP which lacks it, and is in use for time.monotonic(). Co-authored-by: And Clover <and.clover@bromium.com>
* closes bpo-39922: Remove unused args from four functions. (GH-18893)Andy Lester2020-03-111-17/+17
|
* bpo-38631: _PyGILState_Init() returns PyStatus (GH-18908)Victor Stinner2020-03-102-3/+7
| | | | _PyGILState_Init() now returns PyStatus rather than calling Py_FatalError() on failure.
* bpo-34822: Simplify AST for subscription. (GH-9605)Serhiy Storchaka2020-03-106-607/+191
| | | | | | | | | * Remove the slice type. * Make Slice a kind of the expr type instead of the slice type. * Replace ExtSlice(slices) with Tuple(slices, Load()). * Replace Index(value) with a value itself. All non-terminal nodes in AST for expressions are now of the expr type.
* bpo-1294959: Add sys.platlibdir attribute (GH-18381)Victor Stinner2020-03-101-2/+9
| | | | | | | | | | | | | Add --with-platlibdir option to the configure script: name of the platform-specific library directory, stored in the new sys.platlitdir attribute. It is used to build the path of platform-specific dynamic libraries and the path of the standard library. It is equal to "lib" on most platforms. On Fedora and SuSE, it is equal to "lib64" on 64-bit systems. Co-Authored-By: Jan Matějek <jmatejek@suse.com> Co-Authored-By: Matěj Cepl <mcepl@cepl.eu> Co-Authored-By: Charalampos Stratakis <cstratak@redhat.com>
* bpo-39877: Deprecate PyEval_InitThreads() (GH-18892)Victor Stinner2020-03-101-6/+1
| | | | Deprecated PyEval_InitThreads() and PyEval_ThreadsInitialized(). Calling PyEval_InitThreads() now does nothing.
* bpo-39877: PyGILState_Ensure() don't call PyEval_InitThreads() (GH-18891)Victor Stinner2020-03-092-20/+20
| | | | | | | | PyGILState_Ensure() doesn't call PyEval_InitThreads() anymore when a new Python thread state is created. The GIL is created by Py_Initialize() since Python 3.7, it's not needed to call PyEval_InitThreads() explicitly. Add an assertion to ensure that the GIL is already created.
* bpo-19466: Py_Finalize() clears daemon threads earlier (GH-18848)Victor Stinner2020-03-092-7/+22
| | | | | | | | Clear the frames of daemon threads earlier during the Python shutdown to call objects destructors. So "unclosed file" resource warnings are now emitted for daemon threads in a more reliable way. Cleanup _PyThreadState_DeleteExcept() code: rename "garbage" to "list".
* bpo-39877: take_gil() checks tstate_must_exit() twice (GH-18890)Victor Stinner2020-03-091-1/+18
| | | | take_gil() now also checks tstate_must_exit() after acquiring the GIL: exit the thread if Py_Finalize() has been called.
* bpo-36287: Make ast.dump() not output optional fields and attributes with ↵Serhiy Storchaka2020-03-091-0/+94
| | | | | | | default values. (GH-18843) The default values for optional fields and attributes of AST nodes are now set as class attributes (e.g. Constant.kind is set to None).
* bpo-39877: Refactor take_gil() function (GH-18885)Victor Stinner2020-03-092-66/+53
| | | | | | | | | * Remove ceval parameter of take_gil(): get it from tstate. * Move exit_thread_if_finalizing() call inside take_gil(). Replace exit_thread_if_finalizing() with tstate_must_exit(): the caller is now responsible to call PyThread_exit_thread(). * Move is_tstate_valid() assertion inside take_gil(). Remove is_tstate_valid(): inline code into take_gil(). * Move gil_created() assertion inside take_gil().
* bpo-39877: Py_Initialize() pass tstate to PyEval_InitThreads() (GH-18884)Victor Stinner2020-03-092-9/+26
|
* bpo-39877: Remove useless PyEval_InitThreads() calls (GH-18883)Victor Stinner2020-03-091-4/+2
| | | | Py_Initialize() calls PyEval_InitThreads() since Python 3.7. It's no longer needed to call it explicitly.
* bpo-38249: Expand Py_UNREACHABLE() to __builtin_unreachable() in the release ↵Serhiy Storchaka2020-03-093-6/+10
| | | | | mode. (GH-16329) Co-authored-by: Victor Stinner <vstinner@python.org>
* bpo-38691: importlib ignores PYTHONCASEOK if -E is used (GH-18627)idomic2020-03-091-2626/+2634
| | | | | The importlib module now ignores the PYTHONCASEOK environment variable when the -E or -I command line options are being used.
* closes bpo-39898: Remove unused arg from append_formattedvalue. (GH-18840)Andy Lester2020-03-081-4/+4
|
* bpo-39877: Fix PyEval_RestoreThread() for daemon threads (GH-18811)Victor Stinner2020-03-083-26/+69
| | | | | | | | | | | | | | | | | | | | * exit_thread_if_finalizing() does now access directly _PyRuntime variable, rather than using tstate->interp->runtime since tstate can be a dangling pointer after Py_Finalize() has been called. * exit_thread_if_finalizing() is now called *before* calling take_gil(). _PyRuntime.finalizing is an atomic variable, we don't need to hold the GIL to access it. * Add ensure_tstate_not_null() function to check that tstate is not NULL at runtime. Check tstate earlier. take_gil() does not longer check if tstate is NULL. Cleanup: * PyEval_RestoreThread() no longer saves/restores errno: it's already done inside take_gil(). * PyEval_AcquireLock(), PyEval_AcquireThread(), PyEval_RestoreThread() and _PyEval_EvalFrameDefault() now check if tstate is valid with the new is_tstate_valid() function which uses _PyMem_IsPtrFreed().
* bpo-39890: Don't mutate the AST when compiling starred assignments (GH-18833)Brandt Bucher2020-03-081-2/+4
|
* closes bpo-39886: Remove unused arg from config_get_stdio_errors. (GH-18823)Andy Lester2020-03-071-2/+2
|
* closes bpo-39878: Remove unused arguments from static functions. (GH-18822)Andy Lester2020-03-071-10/+10
| | | | | calc_number_widths -> PyObject *number fill_number -> Py_ssize_t d_end
* bpo-39882: Py_FatalError() logs the function name (GH-18819)Victor Stinner2020-03-065-37/+44
| | | | | | | | | | | | The Py_FatalError() function is replaced with a macro which logs automatically the name of the current function, unless the Py_LIMITED_API macro is defined. Changes: * Add _Py_FatalErrorFunc() function. * Remove the function name from the message of Py_FatalError() calls which included the function name. * Update tests.
* bpo-39877: _PyRuntimeState.finalizing becomes atomic (GH-18816)Victor Stinner2020-03-064-9/+12
| | | | | | | | | | | | Convert _PyRuntimeState.finalizing field to an atomic variable: * Rename it to _finalizing * Change its type to _Py_atomic_address * Add _PyRuntimeState_GetFinalizing() and _PyRuntimeState_SetFinalizing() functions * Remove _Py_CURRENTLY_FINALIZING() function: replace it with testing directly _PyRuntimeState_GetFinalizing() value Convert _PyRuntimeState_GetThreadState() to static inline function.
* bpo-39573: Use Py_IS_TYPE() macro to check for types (GH-18809)Andy Lester2020-03-061-1/+1
| | | Co-authored-by: Victor Stinner <vstinner@python.org>
* closes bpo-39872: Remove unused args from symtable_exit_block and ↵Andy Lester2020-03-061-16/+15
| | | | symtable_visit_annotations. (GH-18800)
* closes bpo-39870: Remove unused arg from sys_displayhook_unencodable. (GH-18796)Andy Lester2020-03-061-3/+3
| | | Also move int err to its innermost scope.
* Add a comment to _Py_RestoreSignals() (GH-18792)Victor Stinner2020-03-051-0/+2
| | | subprocess _posix_spawn() should stay in sync with _Py_RestoreSignals().