summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
...
* 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-40602: Optimize _Py_hashtable for pointer keys (GH-20051)Victor Stinner2020-05-121-79/+128
| | | | | | | | | | | | | | | Optimize _Py_hashtable_get() and _Py_hashtable_get_entry() for pointer keys: * key_size == sizeof(void*) * hash_func == _Py_hashtable_hash_ptr * compare_func == _Py_hashtable_compare_direct Changes: * Add get_func and get_entry_func members to _Py_hashtable_t * Convert _Py_hashtable_get() and _Py_hashtable_get_entry() functions to static nline functions. * Add specialized get and get entry for pointer keys.
* bpo-40593: Improve syntax errors for invalid characters in source code. ↵Serhiy Storchaka2020-05-121-3/+0
| | | | (GH-20033)
* bpo-40602: _Py_hashtable_new() uses PyMem_Malloc() (GH-20046)Victor Stinner2020-05-121-3/+4
| | | | | | | _Py_hashtable_new() now uses PyMem_Malloc/PyMem_Free allocator by default, rather than PyMem_RawMalloc/PyMem_RawFree. PyMem_Malloc is faster than PyMem_RawMalloc for memory blocks smaller than or equal to 512 bytes.
* bpo-40602: Rename hashtable.h to pycore_hashtable.h (GH-20044)Victor Stinner2020-05-122-1/+525
| | | | | | | * Move Modules/hashtable.h to Include/internal/pycore_hashtable.h * Move Modules/hashtable.c to Python/hashtable.c * Python is now linked to hashtable.c. _tracemalloc is no longer linked to hashtable.c. Previously, marshal.c got hashtable.c via _tracemalloc.c which is built as a builtin module.
* 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-40528: Improve and clear several aspects of the ASDL definition code for ↵Batuhan Taskaya2020-05-061-86/+69
| | | | the AST (GH-19952)
* bpo-40527: Fix command line argument parsing (GH-19955)Victor Stinner2020-05-061-7/+16
|
* bpo-40513: Per-interpreter GIL (GH-19943)Victor Stinner2020-05-053-5/+73
| | | | | | | | 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-40513: new_interpreter() init GIL earlier (GH-19942)Victor Stinner2020-05-051-4/+4
| | | Fix also code to handle init_interp_main() failure.
* bpo-40522: _PyThreadState_Swap() sets autoTSSkey (GH-19939)Victor Stinner2020-05-052-0/+30
| | | | | | | | | | | | | | | | | | 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-052-30/+37
| | | This reverts commit 4e01946cafca0cf49f796c3118e0d65237bcad69.
* bpo-29587: _PyErr_ChainExceptions() checks exception (GH-19902)Victor Stinner2020-05-051-1/+11
| | | | | | | | | | | | | | | | | | | _PyErr_ChainExceptions() now ensures that the first parameter is an exception type, as done by _PyErr_SetObject(). * The following function now check PyExceptionInstance_Check() in an assertion using a new _PyBaseExceptionObject_cast() helper function: * PyException_GetTraceback(), PyException_SetTraceback() * PyException_GetCause(), PyException_SetCause() * PyException_GetContext(), PyException_SetContext() * PyExceptionClass_Name() now checks PyExceptionClass_Check() with an assertion. * Remove XXX comment and add gi_exc_state variable to _gen_throw(). * Remove comment from test_generators
* 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-40514: Add --with-experimental-isolated-subinterpreters (GH-19926)Victor Stinner2020-05-051-0/+10
| | | | | | | Add --with-experimental-isolated-subinterpreters build option to configure: better isolate subinterpreters, experimental build mode. When used, force the usage of the libc malloc() memory allocator, since pymalloc relies on the unique global interpreter lock (GIL).
* bpo-40513: Per-interpreter gil_drop_request (GH-19927)Victor Stinner2020-05-052-45/+43
| | | | 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-40246: Revert reporting of invalid string prefixes (GH-19888)Lysandros Nikolaou2020-05-041-3/+0
| | | | Due to backwards compatibility concerns regarding keywords immediately followed by a string without whitespace between them (like in `bg="#d00" if clear else"#fca"`) will fail to parse, commit 41d5b94af44e34ac05d4cd57460ed104ccf96628 has to be reverted.
* bpo-40417: Fix deprecation warning in PyImport_ReloadModule (GH-19750)Robert Rouhani2020-05-011-7/+7
| | | | | I can add another commit with the new test case I wrote to verify that the warning was being printed before my change, stopped printing after my change, and that the function does not return null after my change. Automerge-Triggered-By: @brettcannon
* bpo-40412: Nullify inittab_copy during finalization (GH-19746)Gregory Szorc2020-05-011-0/+1
| | | | | | | | | Otherwise we leave a dangling pointer to free'd memory. If we then initialize a new interpreter in the same process and call PyImport_ExtendInittab, we will (likely) crash when calling PyMem_RawRealloc(inittab_copy, ...) since the pointer address is bogus. Automerge-Triggered-By: @brettcannon
* bpo-40453: Add PyConfig._isolated_subinterpreter (GH-19820)Victor Stinner2020-05-012-3/+13
| | | | | | | | | An isolated subinterpreter cannot spawn threads, spawn a child process or call os.fork(). * Add private _Py_NewInterpreter(isolated_subinterpreter) function. * Add isolated=True keyword-only parameter to _xxsubinterpreters.create(). * Allow again os.fork() in "non-isolated" subinterpreters.
* bpo-40334: Support type comments (GH-19780)Guido van Rossum2020-04-301-5/+1
| | | | | | | | | | This implements full support for # type: <type> comments, # type: ignore <stuff> comments, and the func_type parsing mode for ast.parse() and compile(). Closes https://github.com/we-like-parsers/cpython/issues/95. (For now, you need to use the master branch of mypy, since another issue unique to 3.9 had to be fixed there, and there's no mypy release yet.) The only thing missing is `feature_version=N`, which is being tracked in https://github.com/we-like-parsers/cpython/issues/124.
* bpo-40421: Add PyFrame_GetBack() function (GH-19765)Victor Stinner2020-04-293-15/+32
| | | | | | New PyFrame_GetBack() function: get the frame next outer frame. Replace frame->f_back with PyFrame_GetBack(frame) in most code but frameobject.c, ceval.c and genobject.c.
* bpo-40429: PyThreadState_GetFrame() returns a strong ref (GH-19781)Victor Stinner2020-04-292-4/+6
| | | | The PyThreadState_GetFrame() function now returns a strong reference to the frame.
* bpo-40428: Remove PyTuple_ClearFreeList() function (GH-19769)Victor Stinner2020-04-291-8/+5
| | | | | | | | | | | | | | | | | | | Remove the following function from the C API: * PyAsyncGen_ClearFreeLists() * PyContext_ClearFreeList() * PyDict_ClearFreeList() * PyFloat_ClearFreeList() * PyFrame_ClearFreeList() * PyList_ClearFreeList() * PySet_ClearFreeList() * PyTuple_ClearFreeList() Make these functions private, move them to the internal C API and change their return type to void. Call explicitly PyGC_Collect() to free all free lists. Note: PySet_ClearFreeList() did nothing.
* bpo-40429: PyFrame_GetCode() now returns a strong reference (GH-19773)Victor Stinner2020-04-283-8/+12
|
* bpo-40429: PyFrame_GetCode() result cannot be NULL (GH-19772)Victor Stinner2020-04-282-10/+8
| | | Add frame_nslots() to factorize duplicate code.
* bpo-40421: Add PyFrame_GetCode() function (GH-19757)Victor Stinner2020-04-283-16/+22
| | | | | | | | | PyFrame_GetCode(frame): return a borrowed reference to the frame code. Replace frame->f_code with PyFrame_GetCode(frame) in most code, except in frameobject.c, genobject.c and ceval.c. Also add PyFrame_GetLineNumber() to the limited C API.
* bpo-40334: Support CO_FUTURE_BARRY_AS_BDFL in the new parser (GH-19721)Pablo Galindo2020-04-271-2/+2
| | | This commit also allows to pass flags to the new parser in all interfaces and fixes a bug in the parser generator that was causing to inline rules with actions, making them disappear.
* 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-40334: Use old compiler when compile mode is func_type (GH-19692)Guido van Rossum2020-04-231-1/+1
| | | | | This is invoked by mypy, using ast.parse(source, "<func_type>", "func_type"). Since the new grammar doesn't yet support the func_type_input start symbol we must use the old compiler in this case to prevent a crash. https://bugs.python.org/issue40334
* bpo-40334: Improve various PEG-Parser related stuff (GH-19669)Lysandros Nikolaou2020-04-231-1/+1
| | | The changes in this commit are all related to @vstinner's original review comments of the initial PEP 617 implementation PR.
* bpo-40334: Don't downcast from Py_ssize_t to int (GH-19671)Pablo Galindo2020-04-231-1/+1
|
* bpo-40334: Rename PyConfig.use_peg to _use_peg_parser (GH-19670)Victor Stinner2020-04-234-16/+14
| | | | | | | | | | | * Rename PyConfig.use_peg to _use_peg_parser * Document PyConfig._use_peg_parser and mark it a deprecated * Mark -X oldparser option and PYTHONOLDPARSER env var as deprecated in the documentation. * Add use_old_parser() and skip_if_new_parser() to test.support * Remove sys.flags.use_peg: use_old_parser() uses _testinternalcapi.get_configs() instead. * Enhance test_embed tests * subprocess._args_from_interpreter_flags() copies -X oldparser
* bpo-40334: PEP 617 implementation: New PEG parser for CPython (GH-19503)Pablo Galindo2020-04-228-57/+182
| | | | Co-authored-by: Guido van Rossum <guido@python.org> Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
* bpo-39562: Prevent collision of future and compiler flags (GH-19230)Batuhan Taşkaya2020-04-221-1/+1
| | | | | | The constant values of future flags in the __future__ module is updated in order to prevent collision with compiler flags. Previously PyCF_ALLOW_TOP_LEVEL_AWAIT was clashing with CO_FUTURE_DIVISION.
* bpo-40313: speed up bytes.hex() (GH-19594)sweeneyde2020-04-211-12/+49
| | | Automerge-Triggered-By: @gpshead
* Add spaces around the ":=" operator in ast_unparse.c (GH-19568)Hakan Çelik2020-04-181-1/+1
|
* bpo-40302: Replace PY_INT64_T with int64_t (GH-19573)Victor Stinner2020-04-171-3/+3
| | | | | | | | | * Replace PY_INT64_T with int64_t * Replace PY_UINT32_T with uint32_t * Replace PY_UINT64_T with uint64_t sha3module.c no longer checks if PY_UINT64_T is defined since it's always defined and uint64_t is always available on platforms supported by Python.
* Optimize _Py_strhex_impl() (GH-19535)Victor Stinner2020-04-151-24/+26
| | | | | | | Avoid a temporary buffer to create a bytes string: use PyBytes_FromStringAndSize() to directly allocate a bytes object. Cleanup also the code: PEP 7 formatting, move variable definitions closer to where they are used. Fix assertion checking "j" index.
* bpo-40268: Remove unused imports in pylifecycle.c (GH-19533)Victor Stinner2020-04-154-61/+50
| | | | | | | | | | Remove unused imports in files: * initconfig.c * main.c * preconfig.h * pylifecycle.c * python.c * pythonrun.c
* bpo-40268: Remove unused osdefs.h includes (GH-19532)Victor Stinner2020-04-157-8/+5
| | | When the include is needed, add required symbol in a comment.
* bpo-40268: Remove unused pycore_pymem.h includes (GH-19531)Victor Stinner2020-04-157-11/+10
|
* bpo-40268: Remove unused structmember.h includes (GH-19530)Victor Stinner2020-04-157-9/+7
| | | | | | 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-155-8/+0
| | | | Remove explicit pythread.h includes: it is always included by Python.h.
* bpo-39481: PEP 585 for dataclasses, mailbox, contextvars (GH-19425)Ethan Smith2020-04-141-9/+9
|
* bpo-39522: Always initialise kind attribute in constant ast nodes (GH-19525)Pablo Galindo2020-04-141-0/+1
|
* bpo-39522: Use _PyUnicodeWriter_WriteStr instead of PyUnicode_AS_DATA (GH-19523)Batuhan Taşkaya2020-04-141-2/+4
|
* bpo-395222: Correctly unparse unicode prefix in ast_unparse.c (GH-19512)Batuhan Taşkaya2020-04-141-0/+2
|
* bpo-40170: Convert PyObject_IS_GC() macro to a function (GH-19464)Hai Shi2020-04-141-1/+2
|