summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
Commit message (Collapse)AuthorAgeFilesLines
...
* bpo-42634: Mark reraise after except blocks as artificial. (GH-23877)Mark Shannon2020-12-211-0/+2
| | | | | | | * Mark reraise after except blocks as artificial. * Update importlib * Update dis test.
* bpo-42246: Make sure that `f_lasti`, and thus `f_lineno`, is set correctly ↵Mark Shannon2020-12-171-4/+4
| | | | | | | | | 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-42645: Make sure that return/break/continue are only traced once when ↵Mark Shannon2020-12-161-4/+13
| | | | | | | | | exiting via a finally block. (GH-23780) * Make sure that return/break/continue are only traced once when exiting via a finally block. * Add test for return in try-finally. * Update importlib
* bpo-42615: Delete redundant jump instructions that only bypass empty blocks ↵Om G2020-12-161-0/+42
| | | | | | | | | | | | | | | | | | | | | | | (GH-23733) * Delete jump instructions that bypass empty blocks * Add news entry * Explicitly check for unconditional jump opcodes Using the is_jump function results in the inclusion of instructions like returns for which this optimization is not really valid. So, instead explicitly check that the instruction is an unconditional jump. * Handle conditional jumps, delete jumps gracefully * Ensure b_nofallthrough and b_reachable are valid * Add test for redundant jumps * Regenerate importlib.h and edit Misc/ACKS * Fix bad whitespace
* bpo-42246: Remove DO_NOT_EMIT_BYTECODE macros, so that while loops and if ↵Mark Shannon2020-12-151-85/+27
| | | | statements conform to PEP 626. (GH-23743)
* bpo-42635: Mark JUMP_ABSOLUTE at end of 'for' loop as artificial to avoid ↵Mark Shannon2020-12-141-0/+2
| | | | spurious line events. (GH-23761)
* Don't generate spurious line number in try-except-finally. (#23760)Mark Shannon2020-12-141-0/+2
|
* bpo-42246: Don't forget the entry block when ensuring that all exits have a ↵Mark Shannon2020-12-041-0/+6
| | | | | line number (GH-23636) Don't forget the entry block when ensuring that all exits have a line number.
* bpo-42246: Make sure that line number is correct after a return, as required ↵Mark Shannon2020-12-021-11/+126
| | | | | by PEP 626 (GH-23495) Make sure that line number is correct after a return, as defined by PEP 626.
* bpo-42202: Store func annotations as a tuple (GH-23316)Yurii Karabas2020-11-251-43/+27
| | | | | | | | | | | | | 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-42349: Compiler clean up. More yak-shaving for PEP 626. (GH-23267)Mark Shannon2020-11-171-60/+127
| | | Make sure that CFG from compiler front-end is correct. Be a bit more aggressive in the compiler back-end.
* bpo-42246: Fix memory leak in compiler (GH-23256)Mark Shannon2020-11-131-7/+13
| | | | | * Fix potential memory leak in assembler init. * Fix reference leak when encountering error during compilation of function body.
* bpo-42246: Eliminate jumps to exit blocks by copying those blocks. (#23251)Mark Shannon2020-11-121-78/+85
| | | * Compiler: eliminate jumps to short exit blocks by copying.
* bpo-42246: Partial implementation of PEP 626. (GH-23113)Mark Shannon2020-11-121-99/+103
| | | * Implement new line number table format, as defined in PEP 626.
* bpo-42161: Use _PyLong_GetZero() and _PyLong_GetOne() (GH-22995)Victor Stinner2020-10-271-2/+4
| | | | Use _PyLong_GetZero() and _PyLong_GetOne() in Objects/ and Python/ directories.
* bpo-42006: Stop using PyDict_GetItem, PyDict_GetItemString and ↵Serhiy Storchaka2020-10-261-3/+3
| | | | | | | | | | | _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-38605: Make 'from __future__ import annotations' the default (GH-20434)Batuhan Taskaya2020-10-061-12/+2
| | | | | The hard part was making all the tests pass; there are some subtle issues here, because apparently the future import wasn't tested very thoroughly in previous Python versions. For example, `inspect.signature()` returned type objects normally (except for forward references), but strings with the future import. We changed it to try and return type objects by calling `typing.get_type_hints()`, but fall back on returning strings if that function fails (which it may do if there are future references in the annotations that require passing in a specific namespace to resolve).
* bpo-39934: Account for control blocks in 'except' in compiler. (GH-22395)Mark Shannon2020-09-251-8/+11
| | | * Account for control blocks in 'except' in compiler. Fixes #39934.
* bpo-40941: Fix fold_tuple_on_constants() compiler warnings (GH-22378)Victor Stinner2020-09-231-4/+2
| | | | | | Add explicit casts to fix compiler warnings in fold_tuple_on_constants(). The limit of constants per code is now INT_MAX, rather than UINT_MAX.
* bpo-41746: Add type information to asdl_seq objects (GH-22223)Pablo Galindo2020-09-161-40/+37
| | | | | | | | | | | | | * Add new capability to the PEG parser to type variable assignments. For instance: ``` | a[asdl_stmt_seq*]=';'.small_stmt+ [';'] NEWLINE { a } ``` * Add new sequence types from the asdl definition (automatically generated) * Make `asdl_seq` type a generic aliasing pointer type. * Create a new `asdl_generic_seq` for the generic case using `void*`. * The old `asdl_seq_GET`/`ast_seq_SET` macros now are typed. * New `asdl_seq_GET_UNTYPED`/`ast_seq_SET_UNTYPED` macros for dealing with generic sequences. * Changes all possible `asdl_seq` types to use specific versions everywhere.
* bpo-41531: Fix compilation of dict literals with more than 0xFFFF elements ↵Pablo Galindo2020-08-131-1/+1
| | | | (GH-21850)
* bpo-41463: Generate information about jumps from 'opcode.py' rather than ↵Mark Shannon2020-08-041-59/+73
| | | | | duplicating it in 'compile.c' (GH-21714) Generate information about jumps from 'opcode.py' rather than duplicate it in 'compile.c'
* bpo-41323: Perform 'peephole' optimizations directly on the CFG. (GH-21517)Mark Shannon2020-07-301-21/+353
| | | * Move 'peephole' optimizations into compile.c and perform them directly on the CFG.
* bpo-41218: Only mark async code with CO_COROUTINE. (#21357)Matthias Bussonnier2020-07-061-4/+6
| | | | | 3.8.3 had a regression where compiling with ast.PyCF_ALLOW_TOP_LEVEL_AWAIT woudl agressively mark things are coroutine even if there were not.
* bpo-39151: Simplify DFS in the assembler (GH-17733)Pablo Galindo2020-06-281-33/+18
|
* bpo-40939: Remove the old parser (GH-20768)Pablo Galindo2020-06-111-15/+0
| | | This commit removes the old parser, the deprecated parser module, the old parser compatibility flags and environment variables and all associated support code and documentation.
* Make sure that keyword arguments are merged into the arguments dictionary ↵Mark Shannon2020-06-011-0/+3
| | | | when dict unpacking and keyword arguments are interleaved. (GH-20553)
* bpo-40334: Don't downcast from Py_ssize_t to int (GH-19671)Pablo Galindo2020-04-231-1/+1
|
* bpo-40334: PEP 617 implementation: New PEG parser for CPython (GH-19503)Pablo Galindo2020-04-221-0/+67
| | | | Co-authored-by: Guido van Rossum <guido@python.org> Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
* bpo-40268: Add _PyInterpreterState_GetConfig() (GH-19492)Victor Stinner2020-04-131-3/+1
| | | | | | | | Don't access PyInterpreterState.config member directly anymore, but use new functions: * _PyInterpreterState_GetConfig() * _PyInterpreterState_SetConfig() * _Py_GetConfig()
* 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.
* bpo-40147: Move the check for duplicate keywords to the compiler (GH-19289)Pablo Galindo2020-04-031-0/+29
|
* 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-39882: Add _Py_FatalErrorFormat() function (GH-19157)Victor Stinner2020-03-251-16/+12
|
* Use calloc-based functions, not malloc. (GH-19152)Andy Lester2020-03-251-8/+4
|
* 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-39220: Do not optimise annotation if 'from __future__ import ↵Pablo Galindo2020-03-181-1/+5
| | | | | | 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-39988: Remove ast.AugLoad and ast.AugStore node classes. (GH-19038)Serhiy Storchaka2020-03-171-100/+43
|
* bpo-39987: Simplify setting lineno in the compiler. (GH-19037)Serhiy Storchaka2020-03-171-50/+18
|
* bpo-39969: Remove ast.Param node class as is no longer used (GH-19020)Batuhan Taşkaya2020-03-151-18/+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)
* closes bpo-39922: Remove unused args from four functions. (GH-18893)Andy Lester2020-03-111-17/+17
|
* bpo-34822: Simplify AST for subscription. (GH-9605)Serhiy Storchaka2020-03-101-157/+45
| | | | | | | | | * 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-39890: Don't mutate the AST when compiling starred assignments (GH-18833)Brandt Bucher2020-03-081-2/+4
|
* bpo-39639: Remove the AST "Suite" node and associated code (GH-18513)Batuhan Taşkaya2020-03-041-4/+0
| | | | | | | | The AST "Suite" node is no longer used and it can be removed from the ASDL definition and related structures (compiler, visitors, ...). Co-Authored-By: Victor Stinner <vstinner@python.org> Co-authored-by: Brett Cannon <54418+brettcannon@users.noreply.github.com> Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-32856: Optimize the assignment idiom in comprehensions. (GH-16814)Serhiy Storchaka2020-02-121-18/+52
| | | | | Now `for y in [expr]` in comprehensions is as fast as a simple assignment `y = expr`.
* bpo-39573: Use Py_TYPE() macro in Python and Include directories (GH-18391)Victor Stinner2020-02-071-1/+1
| | | Replace direct access to PyObject.ob_type with Py_TYPE().
* bpo-39320: Handle unpacking of **values in compiler (GH-18141)Mark Shannon2020-01-271-32/+58
| | | | | | | | | | | | | * Add DICT_UPDATE and DICT_MERGE bytecodes. Use them for ** unpacking. * Remove BUILD_MAP_UNPACK and BUILD_MAP_UNPACK_WITH_CALL, as they are now unused. * Update magic number for ** unpacking opcodes. * Update dis.rst to incorporate new bytecodes. * Add blurb entry.
* bpo-39320: Handle unpacking of *values in compiler (GH-17984)Mark Shannon2020-01-231-96/+107
| | | | | | | | * Add three new bytecodes: LIST_TO_TUPLE, LIST_EXTEND, SET_UPDATE. Use them to implement star unpacking expressions. * Remove four bytecodes BUILD_LIST_UNPACK, BUILD_TUPLE_UNPACK, BUILD_SET_UNPACK and BUILD_TUPLE_UNPACK_WITH_CALL opcodes as they are now unused. * Update magic number and dis.rst for new bytecodes.
* Fix compiler warning on Windows (GH-18012)Ammar Askar2020-01-151-1/+1
| | | | | | | | Python-ast.h contains a macro named Yield that conflicts with the Yield macro in Windows system headers. While Python-ast.h has an "undef Yield" directive to prevent this, it means that Python-ast.h must be included before Windows header files or we run into a re-declaration warning. In commit c96be811fa7d an include for pycore_pystate.h was added which indirectly includes Windows header files. In this commit we re-order the includes to fix this warning.