summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_compile.py
Commit message (Collapse)AuthorAgeFilesLines
* [3.11] gh-109351: Fix crash when compiling AST with invalid NamedExpr ↵Miss Islington (bot)2023-09-131-0/+27
| | | | | | | | (GH-109352) (#109380) gh-109351: Fix crash when compiling AST with invalid NamedExpr (GH-109352) (cherry picked from commit 79101edb03b7381b514126c68acabfcbbba2f842) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* [3.11] gh-108416: Mark slow test methods with @requires_resource('cpu') ↵Serhiy Storchaka2023-09-031-0/+1
| | | | | | | (GH-108421) (GH-108799) Only mark tests which spend significant system or user time, by itself or in subprocesses. (cherry picked from commit f3ba0a74cd50274acdcd592d4ce8395b92492b7c)
* [3.11] gh-104615: don't make unsafe swaps in apply_static_swaps (GH-104620). ↵Carl Meyer2023-05-191-0/+18
| | | | | (#104636) (cherry picked from commit 0589c6a4d3d822cace42050198cb9a5e99c879ad)
* [3.11] gh-96670: Raise SyntaxError when parsing NULL bytes (GH-97594) (#104195)Lysandros Nikolaou2023-05-071-4/+4
|
* gh-94445: add compiler test for another case of excessive stack use (GH-99237)Miss Islington (bot)2022-11-081-0/+7
| | | | | (cherry picked from commit 027bc7e6bba93777c80300953579266818d339e7) Co-authored-by: Carl Meyer <carl@oddbird.net>
* [3.11] GH-95921: Fix positions for some chained comparisons (GH-96968) ↵Brandt Bucher2022-09-201-0/+26
| | | | | | | (GH-96973) (cherry picked from commit dfc73b57247aac575c83055d960c03bdc28b51fd) Automerge-Triggered-By: GH:brandtbucher
* [3.11] gh-95778: CVE-2020-10735: Prevent DoS by very large int() (#96500)Gregory P. Smith2022-09-021-0/+13
| | | | | | | | | | | | | | | | | | Integer to and from text conversions via CPython's bignum `int` type is not safe against denial of service attacks due to malicious input. Very large input strings with hundred thousands of digits can consume several CPU seconds. This PR comes fresh from a pile of work done in our private PSRT security response team repo. This backports https://github.com/python/cpython/pull/96499 aka 511ca9452033ef95bc7d7fc404b8161068226002 Signed-off-by: Christian Heimes [Red Hat] <christian@python.org> Tons-of-polishing-up-by: Gregory P. Smith [Google] <greg@krypto.org> Reviews via the private PSRT repo via many others (see the NEWS entry in the PR). <!-- gh-issue-number: gh-95778 --> * Issue: gh-95778 <!-- /gh-issue-number --> I wrote up [a one pager for the release managers](https://docs.google.com/document/d/1KjuF_aXlzPUxTK4BMgezGJ2Pn7uevfX7g0_mvgHlL7Y/edit#).
* GH-95150: Use position and exception tables for code hashing and equality ↵Miss Islington (bot)2022-08-011-3/+24
| | | | | | | (GH-95509) (cherry picked from commit c7e5bbaee88a71dc6e633e3cd451ed1798436382) Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
* [3.11] GH-94036: Fix more attribute location quirks (GH-95028) (GH-95156)Brandt Bucher2022-07-231-0/+60
| | | (cherry picked from commit 900bfc53cb133e8bc2b122362ec04256f623d5b0)
* [3.11] GH-91409: Don't overwrite valid locations with NOP locations ↵Brandt Bucher2022-07-201-0/+38
| | | | | (GH-95067) (GH-95068) (cherry picked from commit 742d4614e1a645d765dbf76c19bd9a818239b1cb)
* [3.11] GH-94694: Fix column offsets for multi-line method lookups (GH-94721)Brandt Bucher2022-07-101-0/+21
| | | (cherry picked from commit 264b3ddfd561d97204ffb30be6a7d1fb0555e560)
* [3.11] gh-94485: Set line number of module's RESUME instruction to 0 as ↵Łukasz Langa2022-07-051-1/+3
| | | | | | | | | specified by PEP 626 (GH-94552) (GH-94562) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> Co-authored-by: Mark Shannon <mark@hotpy.org> (cherry picked from commit 324d01944d16868b07df9e8eef6987766a31a36d)
* GH-94329: Don't raise on excessive stack consumption (GH-94421) (GH-94446)Miss Islington (bot)2022-06-301-0/+6
| | | | (cherry picked from commit b152bf448b321e3a4c0a7280e0b608840f5ac661)
* gh-90473: Decrease recursion limit and skip tests on WASI (GH-92803)Miss Islington (bot)2022-05-191-1/+3
| | | | | (cherry picked from commit 137fd3d88aa46669f5717734e823f4c594ab2843) Co-authored-by: Christian Heimes <christian@python.org>
* GH-88116: Use a compact format to represent end line and column offsets. ↵Mark Shannon2022-04-211-14/+19
| | | | | | | | | | | | (GH-91666) * Stores all location info in linetable to conform to PEP 626. * Remove column table from code objects. * Remove end-line table from code objects. * Document new location table format
* bpo-46841: Quicken code in-place (GH-31888)Brandt Bucher2022-03-211-2/+1
| | | | | | | | | | | | | | | | | | | * Moves the bytecode to the end of the corresponding PyCodeObject, and quickens it in-place. * Removes the almost-always-unused co_varnames, co_freevars, and co_cellvars member caches * _PyOpcode_Deopt is a new mapping from all opcodes to their un-quickened forms. * _PyOpcode_InlineCacheEntries is renamed to _PyOpcode_Caches * _Py_IncrementCountAndMaybeQuicken is renamed to _PyCode_Warmup * _Py_Quicken is renamed to _PyCode_Quicken * _co_quickened is renamed to _co_code_adaptive (and is now a read-only memoryview). * Do not emit unused nonzero opargs anymore in the compiler.
* bpo-46198: rename duplicate tests and remove unused code (GH-30297)Nikita Sobolev2022-03-101-1/+1
|
* bpo-46841: Use inline caching for `COMPARE_OP` (GH-31622)Brandt Bucher2022-03-011-1/+3
|
* bpo-46841: Use *inline* caching for `BINARY_OP` (GH-31543)Brandt Bucher2022-02-251-1/+3
|
* bpo-46329: Change calling sequence (again) (GH-31373)Mark Shannon2022-02-181-1/+1
| | | | * Change calling sequence: Add PUSH_NULL. Merge PRECALL_FUNCTION and PRECALL_METHOD into PRECALL.
* bpo-46724: Use `JUMP_ABSOLUTE` for all backward jumps. (GH-31326)Mark Shannon2022-02-151-0/+10
| | | | | | | | | * Make sure all backward jumps use JUMP_ABSOLUTE. * Add news. * Fix up news item. * Make test use consistent style.
* bpo-46329: Split calls into precall and call instructions. (GH-30855)Mark Shannon2022-01-281-4/+3
| | | | | | | | | | | | | | * Add PRECALL_FUNCTION opcode. * Move 'call shape' varaibles into struct. * Replace CALL_NO_KW and CALL_KW with KW_NAMES and CALL instructions. * Specialize for builtin methods taking using the METH_FASTCALL | METH_KEYWORDS protocol. * Allow kwnames for specialized calls to builtin types. * Specialize calls to tuple(arg) and str(arg).
* bpo-46409: Make generators in bytecode (GH-30633)Mark Shannon2022-01-201-2/+2
| | | | | | | | | | | | * Add RETURN_GENERATOR and JUMP_NO_INTERRUPT opcodes. * Trim frame and generator by word each. * Minor refactor of frame.c * Update test.test_sys to account for smaller frames. * Treat generator functions as normal functions when evaluating and specializing.
* bpo-45923: Handle call events in bytecode (GH-30364)Mark Shannon2022-01-061-15/+16
| | | | * Add a RESUME instruction to handle "call" events.
* bpo-44525: Split calls into PRECALL and CALL (GH-30011)Mark Shannon2021-12-141-3/+3
| | | | | | | | | | * Add 3 new opcodes for calls: PRECALL_METHOD, CALL_NO_KW, CALL_KW. * Update specialization to handle new CALL opcodes. * Specialize call to method descriptors. * Remove old CALL opcodes: CALL_FUNCTION, CALL_METHOD, CALL_METHOD_KW, CALL_FUNCTION_KW.
* bpo-45292: [PEP-654] add except* (GH-29581)Irit Katriel2021-12-141-0/+33
|
* bpo-42918: Improve build-in function compile() in mode 'single' (GH-29934)Weipeng Hong2021-12-101-0/+2
| | | Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* bpo-45636: Merge all numeric operators (GH-29482)Brandt Bucher2021-11-111-18/+20
|
* bpo-45056: Remove trailing unused constants from co_consts (GH-28109)Inada Naoki2021-09-021-0/+11
|
* bpo-44622: Set line number of END_ASYNC_FOR to match that of iterator. ↵Mark Shannon2021-07-151-1/+11
| | | | (GH-27160)
* bpo-43950: Add option to opt-out of PEP-657 (GH-27023)Ammar Askar2021-07-071-2/+2
| | | | | Co-authored-by: Pablo Galindo <Pablogsal@gmail.com> Co-authored-by: Batuhan Taskaya <batuhanosmantaskaya@gmail.com> Co-authored-by: Ammar Askar <ammar@ammaraskar.com>
* bpo-43950: use 0-indexed column offsets for bytecode positions (GH-27011)Batuhan Taskaya2021-07-041-10/+10
|
* bpo-43950: Add code.co_positions (PEP 657) (GH-26955)Pablo Galindo2021-07-021-0/+114
| | | | | | | | | | | | | | | This PR is part of PEP 657 and augments the compiler to emit ending line numbers as well as starting and ending columns from the AST into compiled code objects. This allows bytecodes to be correlated to the exact source code ranges that generated them. This information is made available through the following public APIs: * The `co_positions` method on code objects. * The C API function `PyCode_Addr2Location`. Co-authored-by: Batuhan Taskaya <isidentical@gmail.com> Co-authored-by: Ammar Askar <ammar@ammaraskar.com>
* bpo-44313: generate LOAD_ATTR/CALL_FUNCTION for top-level imported objects ↵Batuhan Taskaya2021-06-301-0/+36
| | | | (GH-26677)
* bpo-44297: Fix missing line number in generator expressions (GH-26801)Mark Shannon2021-06-211-0/+15
| | | * Make sure that line number is set when entering comprehension scope in compiler.
* bpo-43833: Emit warnings for numeric literals followed by keyword (GH-25466)Serhiy Storchaka2021-06-081-1/+1
| | | | | | | | Emit a deprecation warning if the numeric literal is immediately followed by one of keywords: and, else, for, if, in, is, or. Raise a syntax error with more informative message if it is immediately followed by other keyword or identifier. Automerge-Triggered-By: GH:pablogsal
* bpo-42609: Check recursion depth in the AST validator and optimizer (GH-23744)Serhiy Storchaka2021-04-251-7/+12
|
* bpo-43846: Use less stack for large literals and calls (GH-25403)Mark Shannon2021-04-151-0/+26
| | | | | | | | | * 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-43651: PEP 597: Fix EncodingWarning in some tests (GH-25145)Inada Naoki2021-04-041-1/+1
| | | | | | | | | | | | | | | | | | | * test_asyncio * test_bz2 * test_math * test_cmath * test_cmd_line * test_cmd_line_script * test_compile * test_contextlib * test_profile * ctypes/test/test_find * test_multiprocessing * test_configparser * test_csv * test_dbm_dumb * test_decimal * test_difflib * os.fdopen() calls io.text_encoding() to emit EncodingWarning for right place.
* Mark POP_TOP at end of expression statement as artificial, to conform to PEP ↵Mark Shannon2021-03-151-0/+8
| | | | 626. (GH-24860)
* bpo-39316: Make sure that attribute accesses and stores, including method ↵Mark Shannon2021-03-141-0/+45
| | | | calls, conform to PEP 626. (GH-24859)
* bpo-42217: compiler: merge same co_code and co_linetable objects (GH-23056)Inada Naoki2021-02-101-0/+11
|
* bpo-42615: Delete redundant jump instructions that only bypass empty blocks ↵Om G2020-12-161-0/+28
| | | | | | | | | | | | | | | | | | | | | | | (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-4/+4
| | | | statements conform to PEP 626. (GH-23743)
* bpo-42246: Don't forget the entry block when ensuring that all exits have a ↵Mark Shannon2020-12-041-0/+18
| | | | | 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-1/+34
| | | | | by PEP 626 (GH-23495) Make sure that line number is correct after a return, as defined by PEP 626.
* bpo-42349: Compiler clean up. More yak-shaving for PEP 626. (GH-23267)Mark Shannon2020-11-171-0/+24
| | | Make sure that CFG from compiler front-end is correct. Be a bit more aggressive in the compiler back-end.
* bpo-42246: Partial implementation of PEP 626. (GH-23113)Mark Shannon2020-11-121-2/+2
| | | * Implement new line number table format, as defined in PEP 626.
* bpo-41531: Fix compilation of dict literals with more than 0xFFFF elements ↵Pablo Galindo2020-08-131-0/+10
| | | | (GH-21850)
* bpo-40275: Use new test.support helper submodules in tests (GH-21151)Hai Shi2020-06-251-1/+3
| | | | | | | | | | | | | Use new test.support helper submodules in tests: * distutils tests * test_buffer * test_compile * test_filecmp * test_fileinput * test_readline * test_smtpnet * test_structmembers * test_tools