Commit graph

1048 commits

Author SHA1 Message Date
Kirill Podoprigora
b455a5a55c
[3.12] gh-121657: Display correct error message for yield from outsid… (GH-121769)
(cherry picked from commit 178e44de8f)

Co-authored-by: Gregor <36135323+gege-hoho@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-07-15 21:26:10 +02:00
Jelle Zijlstra
d62cbba235
[3.12] gh-120722: Set position on RETURN_VALUE in lambda (GH-120724) (#120739)
(cherry picked from commit d8f27cb114)
2024-06-19 13:19:39 +00:00
Irit Katriel
5a6cc3c67f
[3.12] gh-93691: fix too broad source locations of for statement iterators (GH-120330 (#120405)
[3.12] gh-93691: fix too broad source locations of for statement iterators (GH-120330).
(cherry picked from commit 97b69db167)
2024-06-13 11:38:36 +01:00
Victor Stinner
b3b5278475
[3.12] gh-120155: Fix optimize_and_assemble_code_unit() error handling (#120231)
gh-120155: Fix optimize_and_assemble_code_unit() error handling

Don't use 'g' before it's being initialized: don't use the 'error'
label if consts_dict_keys_inorder() failed.

Fix the Coverity issue:

Error: UNINIT (CWE-457):
Python-3.12.2/Python/compile.c:7670:5: skipped_decl: Jumping over declaration of ""g"".
Python-3.12.2/Python/compile.c:7714:5: uninit_use_in_call: Using uninitialized value ""g.g_block_list"" when calling ""_PyCfgBuilder_Fini"".
Python-3.12.2/Python/compile.c:7714:5: uninit_use_in_call: Using uninitialized value ""g.g_entryblock"" when calling ""_PyCfgBuilder_Fini"".
  7712|       Py_XDECREF(consts);
  7713|       instr_sequence_fini(&optimized_instrs);
  7714|->     _PyCfgBuilder_Fini(&g);
  7715|       return co;
  7716|   }
2024-06-07 17:17:06 +02:00
Jelle Zijlstra
dc40226ea1
[3.12] gh-119311: Fix name mangling with PEP 695 generic classes (#119464) (#119644)
* [3.12] gh-119311: Fix name mangling with PEP 695 generic classes (#119464)

Fixes #119311. Fixes #119395.

(cherry picked from commit a9a74da4a0)
2024-06-04 19:55:45 +00:00
Miss Islington (bot)
3706eef02a
[3.12] gh-118513: Fix sibling comprehensions with a name bound in one and global in the other (GH-118526) (#118548)
gh-118513: Fix sibling comprehensions with a name bound in one and global in the other (GH-118526)
(cherry picked from commit c8deb1e4b4)

Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
2024-05-03 14:40:05 +00:00
Irit Katriel
ebef3c5ba4
[3.12] gh-116767: fix crash on 'async with' with many context managers (GH-118348) (#118477)
gh-116767: fix crash on 'async with' with many context managers (GH-118348)

Account for `add_stopiteration_handler` pushing a block for `async with`.
To allow generator functions that previously almost hit the `CO_MAXBLOCKS`
limit by nesting non-async blocks, the limit is increased by 1.
This increase allows one more block in non-generator functions.

(cherry picked from commit c1bf4874c1)
2024-05-01 18:23:29 +01:00
Irit Katriel
6359141867
[3.12] gh-116034: fix location info on the error of a failed assertion (#116054) 2024-02-29 12:36:54 +00:00
Irit Katriel
3eae45f94d
[3.12] gh-105658: fix excess trace events for except block ending with a conditional block (#109384) (#109411)
gh-105658: fix excess trace events for except block ending with a conditional block (#109384)

(cherry picked from commit 4a54074a0f)
2023-09-15 00:41:03 +02:00
Miss Islington (bot)
2004e12d8d
[3.12] gh-109195: fix source location for super load before LOAD_SUPER_ATTR (GH-109289) (#109291)
gh-109195: fix source location for super load before LOAD_SUPER_ATTR (GH-109289)
(cherry picked from commit ceeb4173ae)

Co-authored-by: Carl Meyer <carl@oddbird.net>
2023-09-12 16:20:41 +02:00
Miss Islington (bot)
1a15d20b75
[3.12] gh-108654: restore comprehension locals before handling exception (GH-108659) (#108700)
gh-108654: restore comprehension locals before handling exception (GH-108659)
(cherry picked from commit d52c4482a8)

Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
2023-08-31 15:32:17 +02:00
Miss Islington (bot)
cc18a8b78a
[3.12] gh-105908: fix barry_as_FLUFL future import (GH-105909) (#105930)
(cherry picked from commit 28187a9c4f)

Co-authored-by: Crowthebird <78076854+thatbirdguythatuknownot@users.noreply.github.com>
2023-06-20 03:05:20 +00:00
Miss Islington (bot)
65404930bd
[3.12] gh-105375: Improve error handling in compiler_enter_scope() (GH-105494) (#105581)
(cherry picked from commit 6c832ddcf2)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-06-09 17:23:45 +00:00
Miss Islington (bot)
6d0354167f
[3.12] gh-105164: Detect annotations inside match blocks (GH-105177) (#105313)
(cherry picked from commit 69d1245685)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-06-05 13:42:31 +00:00
Jelle Zijlstra
a5f244d627
gh-104656: Rename typeparams AST node to type_params (#104657) 2023-05-21 21:25:09 -07:00
Jelle Zijlstra
cd9748409a
gh-104686: Fix tracing for decorated classes (#104708) 2023-05-21 16:20:19 -07:00
Carl Meyer
70c7796477
gh-104619: never leak comprehension locals to outer locals() (#104637) 2023-05-18 18:50:24 -07:00
Carl Meyer
86e6f16ccb
gh-104602: ensure all cellvars are known up front (#104603)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-05-19 00:07:35 +00:00
Carl Meyer
0589c6a4d3
gh-104615: don't make unsafe swaps in apply_static_swaps (#104620) 2023-05-18 21:22:03 +00:00
Jelle Zijlstra
662aede68b
gh-104374: Remove access to class scopes for inlined comprehensions (#104528)
Co-authored-by: Carl Meyer <carl@oddbird.net>
2023-05-18 05:22:17 +00:00
Carl Meyer
f40890b124
gh-103865: add monitoring support to LOAD_SUPER_ATTR (#103866) 2023-05-16 10:29:00 -06:00
Jelle Zijlstra
24d8b88420
gh-103763: Implement PEP 695 (#103764)
This implements PEP 695, Type Parameter Syntax. It adds support for:

- Generic functions (def func[T](): ...)
- Generic classes (class X[T](): ...)
- Type aliases (type X = ...)
- New scoping when the new syntax is used within a class body
- Compiler and interpreter changes to support the new syntax and scoping rules 

Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: Eric Traut <eric@traut.com>
Co-authored-by: Larry Hastings <larry@hastings.org>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-05-15 20:36:23 -07:00
Irit Katriel
8a3702f0c7
gh-104482: Fix error handling bugs in ast.c (#104483) 2023-05-15 21:53:55 +01:00
Carl Meyer
ac66cc17f2
gh-104377: fix cell in comprehension that is free in outer scope (#104394) 2023-05-11 16:48:21 -07:00
Carl Meyer
c3b595e73e
gh-97933: (PEP 709) inline list/dict/set comprehensions (#101441)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-05-09 11:02:14 -06:00
Irit Katriel
ca95edf177
gh-104240: return code unit metadata from codegen (#104300) 2023-05-09 14:33:40 +01:00
Irit Katriel
2c2dc61e8d
gh-104240: make _PyCompile_CodeGen support different compilation modes (#104241) 2023-05-07 18:47:28 +01:00
Irit Katriel
80b714835d
gh-87092: Expose assembler to unit tests (#103988) 2023-05-01 22:29:30 +01:00
Irit Katriel
fbf3596c3e
gh-87092: change assembler to use instruction sequence instead of CFG (#103933) 2023-04-29 12:06:04 +01:00
Carl Meyer
0dc8b50d33
gh-87729: add LOAD_SUPER_ATTR instruction for faster super() (#103497)
This speeds up `super()` (by around 85%, for a simple one-level
`super().meth()` microbenchmark) by avoiding allocation of a new
single-use `super()` object on each use.
2023-04-24 22:22:14 +00:00
Shantanu
ae25855045
gh-103492: Clarify SyntaxWarning with literal comparison (#103493) 2023-04-24 15:42:57 -06:00
Irit Katriel
1c01f8d797
gh-101517: fix line number propagation in code generated for except* (#103550) 2023-04-24 21:58:51 +01:00
Irit Katriel
6751a4af95
gh-87092: fix a few cases of incorrect error handling in compiler (#103456)
gh-87092: fix a few cases of incorrect error handling
2023-04-24 19:30:49 +01:00
Mark Shannon
411b169281
GH-103082: Implementation of PEP 669: Low Impact Monitoring for CPython (GH-103083)
* The majority of the monitoring code is in instrumentation.c

* The new instrumentation bytecodes are in bytecodes.c

* legacy_tracing.c adapts the new API to the old sys.setrace and sys.setprofile APIs
2023-04-12 12:04:55 +01:00
Irit Katriel
9db2db4fa4
gh-87092: fix refleak in peepholer test harness (#103448) 2023-04-11 21:08:29 +01:00
Irit Katriel
33822d037a
gh-87092: move assembler related code from compile.c to assemble.c (#103277) 2023-04-11 11:15:09 +01:00
Irit Katriel
80163e17d3
gh-87092: move CFG related code from compile.c to flowgraph.c (#103021) 2023-03-31 18:17:59 +01:00
Brandt Bucher
0444ae2487
GH-100982: Break up COMPARE_AND_BRANCH (GH-102801) 2023-03-23 15:25:09 -07:00
Irit Katriel
3468c768ce
gh-102859: Remove JUMP_IF_FALSE_OR_POP and JUMP_IF_TRUE_OR_POP (#102870) 2023-03-22 18:10:48 +00:00
Irit Katriel
8d015fa000
gh-102860: improve performance of compiler's instr_sequence_to_cfg (#102861) 2023-03-21 19:13:49 +00:00
Irit Katriel
634cb61909
gh-87092: refactor assemble() to a number of separate functions, which do not need the compiler struct (#102562) 2023-03-13 15:59:20 +00:00
Irit Katriel
54060ae91d
gh-87092: compiler's CFG construction moved to after codegen stage (#102320) 2023-03-07 18:16:32 +00:00
Irit Katriel
71db5dbcd7
gh-102371: move _Py_Mangle from compile.c to symtable.c (#102372) 2023-03-02 18:38:22 +00:00
Irit Katriel
4c87537efb
gh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives (in Python/) (#102193) 2023-02-28 11:50:52 +00:00
Irit Katriel
9f799ab020
gh-87092: Make jump target label equal to the offset of the target in the instructions sequence (#102093) 2023-02-28 11:29:32 +00:00
Steve Dower
a99eb5cd99
gh-101907: Stop using _Py_OPCODE and _Py_OPARG macros (GH-101912)
* gh-101907: Removes use of non-standard C++ extension from Include/cpython/code.h

* Make cases_generator correct on Windows
2023-02-20 14:56:48 +00:00
penguin_wwy
df7ccf6138
gh-101928: fix crash in compiler on multi-line lambda in function call (#101933) 2023-02-16 11:31:41 +00:00
Irit Katriel
81e3aa835c
gh-101799: implement PREP_RERAISE_STAR as an intrinsic function (#101800) 2023-02-14 11:54:13 +00:00
Mark Shannon
160f2fe2b9
GH-87849: Simplify stack effect of SEND and specialize it for generators and coroutines. (GH-101788) 2023-02-13 11:24:55 +00:00
Guido van Rossum
65b7b6bd23
gh-98831: Use opcode metadata for stack_effect() (#101704)
* Write output and metadata in a single run
  This halves the time to run the cases generator
  (most of the time goes into parsing the input).
* Declare or define opcode metadata based on NEED_OPCODE_TABLES
* Use generated metadata for stack_effect()
* compile.o depends on opcode_metadata.h
* Return -1 from _PyOpcode_num_popped/pushed for unknown opcode
2023-02-08 16:23:19 -08:00