|
1 | | -import sys |
2 | 1 | import types |
3 | 2 | from collections import defaultdict |
4 | 3 | from dataclasses import dataclass |
|
23 | 22 | from bytecode.concrete import ConcreteInstr |
24 | 23 | from bytecode.flags import CompilerFlags |
25 | 24 | from bytecode.instr import UNSET, Instr, Label, SetLineno, TryBegin, TryEnd |
26 | | -from bytecode.utils import PY310, PY311, PY313 |
| 25 | +from bytecode.utils import PY313 |
27 | 26 |
|
28 | 27 | T = TypeVar("T", bound="BasicBlock") |
29 | 28 | U = TypeVar("U", bound="ControlFlowGraph") |
@@ -447,18 +446,10 @@ def _compute_exception_handler_stack_usage( |
447 | 446 | def _is_stacksize_computation_relevant( |
448 | 447 | self, block_id: int, fingerprint: Tuple[int, Optional[bool]] |
449 | 448 | ) -> bool: |
450 | | - if PY311: |
451 | | - # The computation is relevant if the block was not visited previously |
452 | | - # with the same starting size and exception handler status than the |
453 | | - # one in use |
454 | | - return fingerprint not in self.common.blocks_startsizes[block_id] |
455 | | - else: |
456 | | - # The computation is relevant if the block was only visited with smaller |
457 | | - # starting sizes than the one in use |
458 | | - if sizes := self.common.blocks_startsizes[block_id]: |
459 | | - return fingerprint[0] > max(f[0] for f in sizes) |
460 | | - else: |
461 | | - return True |
| 449 | + # The computation is relevant if the block was not visited previously |
| 450 | + # with the same starting size and exception handler status than the |
| 451 | + # one in use |
| 452 | + return fingerprint not in self.common.blocks_startsizes[block_id] |
462 | 453 |
|
463 | 454 |
|
464 | 455 | class ControlFlowGraph(_bytecode.BaseBytecode): |
@@ -521,11 +512,10 @@ def compute_stacksize( |
521 | 512 | ) |
522 | 513 |
|
523 | 514 | # Starting with Python 3.10, generator and coroutines start with one object |
524 | | - # on the stack (None, anything is an error). |
| 515 | + # on the stack (None, anything else is an error). |
525 | 516 | initial_stack_size = 0 |
526 | 517 | if ( |
527 | 518 | not PY313 # under 3.13+ RETURN_GENERATOR make this explicit |
528 | | - and PY310 |
529 | 519 | and self.flags |
530 | 520 | & ( |
531 | 521 | CompilerFlags.GENERATOR |
@@ -628,7 +618,7 @@ def _get_instructions( |
628 | 618 | # argument rather than a Label. This is fine for comparison |
629 | 619 | # purposes which is our sole goal here. |
630 | 620 | c_instr = ConcreteInstr( |
631 | | - instr.name, |
| 621 | + instr._name, |
632 | 622 | self.get_block_index(target_block), |
633 | 623 | location=instr.location, |
634 | 624 | ) |
|
0 commit comments