summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
Commit message (Collapse)AuthorAgeFilesLines
* [3.10] bpo-45056: Remove trailing unused constants from co_consts (GH-28109) ↵Łukasz Langa2021-09-081-0/+33
| | | | | | | (GH-28125) (cherry picked from commit 55c4a92fc1abfe388335071f1d64b3addfa5793f) Co-authored-by: Inada Naoki <songofacandy@gmail.com>
* bpo-45039: Consistently use ADDOP_LOAD_CONST in compiler rather than ↵Miss Islington (bot)2021-08-311-2/+4
| | | | | | | ADDOP_O(c, LOAD_CONST,...) (GH-28015) (cherry picked from commit 70ccee418d1f9d34ed15cfe7104221f9cfd27d03) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
* bpo-45000: Raise SyntaxError when try to delete __debug__ (GH-27947) (GH-27957)Dong-hee Na2021-08-261-0/+4
| | | (cherry picked from commit 551da597a0996b0fb3af425f48aa5bc63ea6b963)
* Remove unused variable. (GH-27677) (#27680)Mark Shannon2021-08-091-3/+0
|
* bpo-44840: Compiler: Move duplication of exit blocks with no line numbers to ↵Mark Shannon2021-08-091-16/+24
| | | | | after CFG optimization. (GH-27656) (#27673) (cherry picked from commit b854557b49083d8625a433eb36aacb0c87d67c52)
* [3.10] bpo-44600: Fix line numbers for pattern matching cleanup code ↵Miss Islington (bot)2021-07-261-4/+12
| | | | | | | | | | (GH-27346) (GH-27356) (cherry picked from commit 4214f470f0cb9b6fef9a90758756fbc00ba95b5a) Co-authored-by: Charles Burkland <charles.aburkland@gmail.com> Automerge-Triggered-By: GH:brandtbucher
* bpo-44626: Merge basic blocks earlier to enable better handling of exit ↵Mark Shannon2021-07-161-16/+48
| | | | | blocks without line numbers (GH-27138) (GH-27182) (cherry picked from commit a86f7dae0acf918d54086cb85e5a0b0bedeedce7)
* bpo-44622: Set line number of END_ASYNC_FOR to match that of iterator. ↵Mark Shannon2021-07-151-1/+3
| | | | | (GH-27160) (GH-27163) (cherry picked from commit f333ab0f2edec26a769ed558263ac662e5475451)
* [3.10] bpo-44589: raise a SyntaxError when mapping patterns have duplicate ↵Miss Islington (bot)2021-07-151-4/+41
| | | | | | | | | | literal keys (GH-27131) (GH-27157) (cherry picked from commit 2693132292b2acf381ac6fa729bf3acf41d9d72b) Co-authored-by: Jack DeVries <58614260+jdevries3133@users.noreply.github.com> Automerge-Triggered-By: GH:brandtbucher
* bpo-44616: Mark all clean up instructions at end of named exception block as ↵Mark Shannon2021-07-141-3/+2
| | | | | artificial (GH-27109) (GH-27135) (cherry picked from commit e5862f79c16e28f1ec51d179698739a9b2d8c1d2)
* bpo-44297: Fix missing line number in generator expressions (GH-26821)Mark Shannon2021-06-211-0/+1
| | | | | * Make sure that line number is set when entering comprehension scope in compiler. (cherry picked from commit 82e5c28af7049c4f5343c808f172cbe2e145f49b)
* [3.10] bpo-44298: Backport #26513 to 3.10 (#26516)Mark Shannon2021-06-031-4/+14
| | | | | * Backport 937cebc93 to 3.10 * Update importlib
* [3.10] bpo-43933: Force RETURN_VALUE bytecodes to have line numbers (GH-26061)Mark Shannon2021-05-131-0/+29
| | | * Guarantee that line number is set for returns.
* bpo-44063: set the missing end locations on the compiler (GH-25956) (#25972)Miss Islington (bot)2021-05-071-5/+13
| | | | | (cherry picked from commit b2ec37a7224318d466e0877790ed740ce8b4867d) Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>
* Correct location for syntax error in try-except (GH-25939)Mark Shannon2021-05-061-1/+1
|
* bpo-43754: Fix compiler warning in Python/compile.c (GH-25855)Pablo Galindo2021-05-031-1/+1
| | | | | This fixes the following warning: 'initializing': conversion from 'Py_ssize_t' to 'int', possible loss of data [D:\a\cpython\cpython\PCbuild\pythoncore.vcxproj]
* bpo-43754: Eliminate bindings for partial pattern matches (GH-25229)Brandt Bucher2021-05-021-229/+364
|
* bpo-43933: Set frame.f_lineno during call to __exit__ (GH-25719)Mark Shannon2021-04-301-4/+8
| | | * Set line number of __exit__ call in a with statement to be that of the with keyword.
* bpo-43892: Validate the first term of complex literal value patterns (GH-25735)Brandt Bucher2021-04-301-37/+19
|
* bpo-42739: Don't use sentinels to mark end of line table. (GH-25657)Mark Shannon2021-04-291-4/+0
| | | | | * Add length parameter to PyLineTable_InitAddressRange and doen't use sentinel values at end of table. Makes the line number table more robust. * Update PyCodeAddressRange to match PEP 626.
* bpo-43892: Make match patterns explicit in the AST (GH-25585)Nick Coghlan2021-04-291-157/+224
| | | Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
* bpo-42737: annotations with complex targets no longer causes any runtime ↵Batuhan Taskaya2021-04-251-0/+6
| | | | effects (GH-23952)
* bpo-43914: Highlight invalid ranges in SyntaxErrors (#25525)Pablo Galindo2021-04-231-3/+10
| | | | | | | | | | | | | | | | | To improve the user experience understanding what part of the error messages associated with SyntaxErrors is wrong, we can highlight the whole error range and not only place the caret at the first character. In this way: >>> foo(x, z for z in range(10), t, w) File "<stdin>", line 1 foo(x, z for z in range(10), t, w) ^ SyntaxError: Generator expression must be parenthesized becomes >>> foo(x, z for z in range(10), t, w) File "<stdin>", line 1 foo(x, z for z in range(10), t, w) ^^^^^^^^^^^^^^^^^^^^ SyntaxError: Generator expression must be parenthesized
* bpo-38605: Revert making 'from __future__ import annotations' the default ↵Pablo Galindo2021-04-211-9/+22
| | | | | | (GH-25490) This reverts commits 044a1048ca93d466965afc027b91a5a9eb9ce23c and 1be456ae9d53bb1cba2b24fc86175c282d1c2169, adapting the code to changes that happened after it.
* bpo-41323: compiler: Reuse tuple in constant tuple folding (GH-25419)Inada Naoki2021-04-161-13/+26
|
* bpo-43846: Use less stack for large literals and calls (GH-25403)Mark Shannon2021-04-151-50/+144
| | | | | | | | | * Modify compiler to reduce stack consumption for large expressions. * Add more tests for stack usage. * Add NEWS item. * Raise SystemError for truly excessive stack use.
* bpo-43495 : Push missing frame block in compile.c (GH-24865)tomKPZ2021-04-071-1/+10
|
* Correct micro release number and add a couple of asserts. (GH-25224)Mark Shannon2021-04-071-3/+3
|
* bpo-43683: Handle generator entry in bytecode (GH-25138)Mark Shannon2021-04-061-1/+46
| | | | | | * Handle check for sending None to starting generator and coroutine into bytecode. * Document new bytecode and make it fail gracefully if mis-compiled.
* bpo-27129: Use instruction offsets, not byte offsets, in bytecode and ↵Mark Shannon2021-04-011-1/+0
| | | | | | | internally. (GH-25069) * Use instruction offset, rather than bytecode offset. Streamlines interpreter dispatch a bit, and removes most EXTENDED_ARGs for jumps. * Change some uses of PyCode_Addr2Line to PyFrame_GetLineNumber
* bpo-43244: Add pycore_compile.h header file (GH-25000)Victor Stinner2021-03-231-28/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | Remove the compiler functions using "struct _mod" type, because the public AST C API was removed: * PyAST_Compile() * PyAST_CompileEx() * PyAST_CompileObject() * PyFuture_FromAST() * PyFuture_FromASTObject() These functions were undocumented and excluded from the limited C API. Rename functions: * PyAST_CompileObject() => _PyAST_Compile() * PyFuture_FromASTObject() => _PyFuture_FromAST() Moreover, _PyFuture_FromAST() is no longer exported (replace PyAPI_FUNC() with extern). _PyAST_Compile() remains exported for test_peg_generator. Remove also compatibility functions: * PyAST_Compile() * PyAST_CompileEx() * PyFuture_FromAST()
* bpo-43244: Remove symtable.h header file (GH-24910)Victor Stinner2021-03-191-7/+7
| | | | | | | | | | | | | | | | | | Rename Include/symtable.h to to Include/internal/pycore_symtable.h, don't export symbols anymore (replace PyAPI_FUNC and PyAPI_DATA with extern) and rename functions: * PyST_GetScope() to _PyST_GetScope() * PySymtable_BuildObject() to _PySymtable_Build() * PySymtable_Free() to _PySymtable_Free() Remove PySymtable_Build(), Py_SymtableString() and Py_SymtableStringObject() functions. The Py_SymtableString() function was part the stable ABI by mistake but it could not be used, since the symtable.h header file was excluded from the limited C API. The Python symtable module remains available and is unchanged.
* bpo-43244: Add pycore_ast.h header file (GH-24908)Victor Stinner2021-03-171-6/+5
| | | | | | | | Move _PyAST_GetDocString() and _PyAST_ExprAsUnicode() functions the internal C API: from Include/ast.h to a new Include/internal/pycore_ast.h header file. Don't export these functions anymore: replace PyAPI_FUNC() with extern. Remove also unused includes.
* bpo-43497: Emit SyntaxWarnings for assertions with tuple constants. (GH-24867)tsukasa-au2021-03-161-4/+8
| | | | | | | | | | | | | | | | | | | * bpo-43497: Emit SyntaxWarnings for assertions with tuple constants. Add a test that shows that a tuple constant (a tuple, where all of its members are also compile-time constants) produces a SyntaxWarning. Then fix this failure. * Make SyntaxWarnings also work when "optimized". * Split tests for SyntaxWarning to SyntaxError conversion SyntaxWarnings emitted by the compiler when configured to be errors are actually raised as SyntaxError exceptions. Move these tests into their own method and add a test to ensure they are raised. Previously we only tested that they were not raised for a "valid" assertion statement.
* Mark POP_TOP at end of expression statement as artificial, to conform to PEP ↵Mark Shannon2021-03-151-0/+2
| | | | 626. (GH-24860)
* bpo-39316: Make sure that attribute accesses and stores, including method ↵Mark Shannon2021-03-141-1/+17
| | | | calls, conform to PEP 626. (GH-24859)
* Fix typo in compile.c (GH-24812)Ikko Ashimine2021-03-101-1/+1
| | | guranteed -> guaranteed
* bpo-43358: Fix bad free in assemble function (GH-24697)Alex Henrie2021-03-021-2/+2
|
* bpo-42128: Structural Pattern Matching (PEP 634) (GH-22917)Brandt Bucher2021-02-261-26/+713
| | | | | Co-authored-by: Guido van Rossum <guido@python.org> Co-authored-by: Talin <viridia@gmail.com> Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* bpo-42217: compiler: merge same co_code and co_linetable objects (GH-23056)Inada Naoki2021-02-101-17/+27
|
* Only eliminate jumps to successor block if jump is unconditional. (GH-24417)Mark Shannon2021-02-021-17/+4
| | | | * Prevents elimination of the sole test of a value in statements like: if x or True: ...
* bpo-40455: Fix gcc10+ warning about writing into a section of offset 0 ↵Pablo Galindo2021-01-301-3/+2
| | | | (GH-24384)
* bpo-38631: Replace compiler fatal errors with exceptions (GH-24369)Victor Stinner2021-01-301-34/+52
| | | | | | | | * Replace Py_FatalError() calls with regular SystemError exceptions. * compiler_exit_scope() calls _PyErr_WriteUnraisableMsg() to log the PySequence_DelItem() failure. * compiler_unit_check() uses _PyMem_IsPtrFreed(). * compiler_make_closure(): remove "(reftype == FREE)" comment since reftype can also be LOCAL or GLOBAL_EXPLICIT.
* Fix a reference leak in the compiler for compiler_lambda() (GH-24382)Pablo Galindo2021-01-291-1/+3
|
* bpo-42979: Use _Py_CheckSlotResult() to check slots result (GH-24356)Victor Stinner2021-01-291-7/+11
| | | | | | | | | | | | | | | When Python is built in debug mode (with C assertions), calling a type slot like sq_length (__len__() in Python) now fails with a fatal error if the slot succeeded with an exception set, or failed with no exception set. The error message contains the slot, the type name, and the current exception (if an exception is set). * Check the result of all slots using _Py_CheckSlotResult(). * No longer pass op_name to ternary_op() in release mode. * Replace operator with dunder Python method name in error messages. For example, replace "*" with "__mul__". * Fix compiler_exit_scope() when an exception is set. * Fix bytearray.extend() when an exception is set: don't call bytearray_setslice() with an exception set.
* bpo-33387: update documentation for exception handling opcode changes (GH-24334)Irit Katriel2021-01-261-2/+0
| | | | | * bpo-33387: remove obsolete comment * bpo-33387: update SETUP_WITH opcode documentation
* Mark instructions at end of class scope as artificial. (GH-24222)Mark Shannon2021-01-151-0/+2
|
* Eliminate NOPs in extended blocks. (GH-24209)Mark Shannon2021-01-131-5/+13
|
* bpo-42908: Mark cleanup code at end of try-except and with artificial (#24202)Mark Shannon2021-01-131-31/+104
| | | | | | | | | * Mark bytecodes at end of try-except as artificial. * Make sure that the CFG is consistent throughout optimiization. * Extend line-number propagation logic so that implicit returns after 'try-except' or 'with' have the correct line numbers. * Update importlib
* bpo-42823: Fix frame lineno when frame.f_trace is set (GH-24099)Mark Shannon2021-01-051-0/+6
| | | | | | | | | * 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