bytecode 0.16.1__tar.gz → 0.16.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. {bytecode-0.16.1 → bytecode-0.16.2}/.github/workflows/release.yml +2 -2
  2. {bytecode-0.16.1/src/bytecode.egg-info → bytecode-0.16.2}/PKG-INFO +3 -2
  3. {bytecode-0.16.1 → bytecode-0.16.2}/doc/changelog.rst +8 -0
  4. {bytecode-0.16.1 → bytecode-0.16.2}/src/bytecode/cfg.py +8 -2
  5. {bytecode-0.16.1 → bytecode-0.16.2}/src/bytecode/instr.py +7 -7
  6. {bytecode-0.16.1 → bytecode-0.16.2}/src/bytecode/version.py +2 -2
  7. {bytecode-0.16.1 → bytecode-0.16.2/src/bytecode.egg-info}/PKG-INFO +3 -2
  8. {bytecode-0.16.1 → bytecode-0.16.2}/tests/test_cfg.py +14 -0
  9. {bytecode-0.16.1 → bytecode-0.16.2}/.coveragerc +0 -0
  10. {bytecode-0.16.1 → bytecode-0.16.2}/.github/FUNDING.yml +0 -0
  11. {bytecode-0.16.1 → bytecode-0.16.2}/.github/dependabot.yml +0 -0
  12. {bytecode-0.16.1 → bytecode-0.16.2}/.github/workflows/cis.yml +0 -0
  13. {bytecode-0.16.1 → bytecode-0.16.2}/.github/workflows/docs.yml +0 -0
  14. {bytecode-0.16.1 → bytecode-0.16.2}/.github/workflows/frameworks.yml +0 -0
  15. {bytecode-0.16.1 → bytecode-0.16.2}/.gitignore +0 -0
  16. {bytecode-0.16.1 → bytecode-0.16.2}/.pre-commit-config.yaml +0 -0
  17. {bytecode-0.16.1 → bytecode-0.16.2}/.readthedocs.yaml +0 -0
  18. {bytecode-0.16.1 → bytecode-0.16.2}/COPYING +0 -0
  19. {bytecode-0.16.1 → bytecode-0.16.2}/MANIFEST.in +0 -0
  20. {bytecode-0.16.1 → bytecode-0.16.2}/README.rst +0 -0
  21. {bytecode-0.16.1 → bytecode-0.16.2}/TODO.rst +0 -0
  22. {bytecode-0.16.1 → bytecode-0.16.2}/codecov.yml +0 -0
  23. {bytecode-0.16.1 → bytecode-0.16.2}/doc/Makefile +0 -0
  24. {bytecode-0.16.1 → bytecode-0.16.2}/doc/api.rst +0 -0
  25. {bytecode-0.16.1 → bytecode-0.16.2}/doc/byteplay_codetransformer.rst +0 -0
  26. {bytecode-0.16.1 → bytecode-0.16.2}/doc/cfg.rst +0 -0
  27. {bytecode-0.16.1 → bytecode-0.16.2}/doc/conf.py +0 -0
  28. {bytecode-0.16.1 → bytecode-0.16.2}/doc/index.rst +0 -0
  29. {bytecode-0.16.1 → bytecode-0.16.2}/doc/make.bat +0 -0
  30. {bytecode-0.16.1 → bytecode-0.16.2}/doc/requirements.txt +0 -0
  31. {bytecode-0.16.1 → bytecode-0.16.2}/doc/todo.rst +0 -0
  32. {bytecode-0.16.1 → bytecode-0.16.2}/doc/usage.rst +0 -0
  33. {bytecode-0.16.1 → bytecode-0.16.2}/pyproject.toml +0 -0
  34. {bytecode-0.16.1 → bytecode-0.16.2}/scripts/frameworks/boto3/run.sh +0 -0
  35. {bytecode-0.16.1 → bytecode-0.16.2}/scripts/frameworks/boto3/setup.sh +0 -0
  36. {bytecode-0.16.1 → bytecode-0.16.2}/setup.cfg +0 -0
  37. {bytecode-0.16.1 → bytecode-0.16.2}/src/bytecode/__init__.py +0 -0
  38. {bytecode-0.16.1 → bytecode-0.16.2}/src/bytecode/bytecode.py +0 -0
  39. {bytecode-0.16.1 → bytecode-0.16.2}/src/bytecode/concrete.py +0 -0
  40. {bytecode-0.16.1 → bytecode-0.16.2}/src/bytecode/flags.py +0 -0
  41. {bytecode-0.16.1 → bytecode-0.16.2}/src/bytecode/py.typed +0 -0
  42. {bytecode-0.16.1 → bytecode-0.16.2}/src/bytecode/utils.py +0 -0
  43. {bytecode-0.16.1 → bytecode-0.16.2}/src/bytecode.egg-info/SOURCES.txt +0 -0
  44. {bytecode-0.16.1 → bytecode-0.16.2}/src/bytecode.egg-info/dependency_links.txt +0 -0
  45. {bytecode-0.16.1 → bytecode-0.16.2}/src/bytecode.egg-info/requires.txt +0 -0
  46. {bytecode-0.16.1 → bytecode-0.16.2}/src/bytecode.egg-info/top_level.txt +0 -0
  47. {bytecode-0.16.1 → bytecode-0.16.2}/tests/__init__.py +0 -0
  48. {bytecode-0.16.1 → bytecode-0.16.2}/tests/cell_free_vars_cases.py +0 -0
  49. {bytecode-0.16.1 → bytecode-0.16.2}/tests/exception_handling_cases.py +0 -0
  50. {bytecode-0.16.1 → bytecode-0.16.2}/tests/frameworks/function.py +0 -0
  51. {bytecode-0.16.1 → bytecode-0.16.2}/tests/frameworks/module.py +0 -0
  52. {bytecode-0.16.1 → bytecode-0.16.2}/tests/frameworks/sitecustomize.py +0 -0
  53. {bytecode-0.16.1 → bytecode-0.16.2}/tests/long_lines_example.py +0 -0
  54. {bytecode-0.16.1 → bytecode-0.16.2}/tests/test_bytecode.py +0 -0
  55. {bytecode-0.16.1 → bytecode-0.16.2}/tests/test_code.py +0 -0
  56. {bytecode-0.16.1 → bytecode-0.16.2}/tests/test_concrete.py +0 -0
  57. {bytecode-0.16.1 → bytecode-0.16.2}/tests/test_flags.py +0 -0
  58. {bytecode-0.16.1 → bytecode-0.16.2}/tests/test_instr.py +0 -0
  59. {bytecode-0.16.1 → bytecode-0.16.2}/tests/test_misc.py +0 -0
  60. {bytecode-0.16.1 → bytecode-0.16.2}/tests/util_annotation.py +0 -0
  61. {bytecode-0.16.1 → bytecode-0.16.2}/tox.ini +0 -0
@@ -74,7 +74,7 @@ jobs:
74
74
  runs-on: ubuntu-latest
75
75
  steps:
76
76
  - name: Download all the dists
77
- uses: actions/download-artifact@v4.1.8
77
+ uses: actions/download-artifact@v4.2.1
78
78
  with:
79
79
  pattern: cibw-*
80
80
  path: dist
@@ -101,7 +101,7 @@ jobs:
101
101
 
102
102
  steps:
103
103
  - name: Download all the dists
104
- uses: actions/download-artifact@v4.1.8
104
+ uses: actions/download-artifact@v4.2.1
105
105
  with:
106
106
  pattern: cibw-*
107
107
  path: dist
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: bytecode
3
- Version: 0.16.1
3
+ Version: 0.16.2
4
4
  Summary: Python module to generate and modify bytecode
5
5
  Author-email: Victor Stinner <victor.stinner@gmail.com>
6
6
  Maintainer-email: "Matthieu C. Dartiailh" <m.dartiailh@gmail.com>
@@ -47,6 +47,7 @@ Requires-Python: >=3.8
47
47
  Description-Content-Type: text/x-rst
48
48
  License-File: COPYING
49
49
  Requires-Dist: typing_extensions; python_version < "3.10"
50
+ Dynamic: license-file
50
51
 
51
52
  ********
52
53
  bytecode
@@ -1,6 +1,14 @@
1
1
  ChangeLog
2
2
  =========
3
3
 
4
+ 2025-04-14: Version 0.16.2
5
+ --------------------------
6
+
7
+ Bugfixes:
8
+
9
+ - fix ControlFlowGraph dead block detection by accounting for fall-through
10
+ edges. PR #161
11
+
4
12
  2025-01-21: Version 0.16.1
5
13
  --------------------------
6
14
 
@@ -731,12 +731,18 @@ class ControlFlowGraph(_bytecode.BaseBytecode):
731
731
  if id(block) in seen_block_ids:
732
732
  continue
733
733
  seen_block_ids.add(id(block))
734
+ fall_through = True
734
735
  for i in block:
735
- if isinstance(i, Instr) and isinstance(i.arg, BasicBlock):
736
- stack.append(i.arg)
736
+ if isinstance(i, Instr):
737
+ if isinstance(i.arg, BasicBlock):
738
+ stack.append(i.arg)
739
+ if i.is_final():
740
+ fall_through = False
737
741
  elif isinstance(i, TryBegin):
738
742
  assert isinstance(i.target, BasicBlock)
739
743
  stack.append(i.target)
744
+ if fall_through and block.next_block:
745
+ stack.append(block.next_block)
740
746
 
741
747
  return [b for b in self if id(b) not in seen_block_ids]
742
748
 
@@ -336,15 +336,15 @@ STATIC_STACK_EFFECTS: Dict[str, Tuple[int, int]] = {
336
336
  "CHECK_EXC_MATCH": (-2, 2), # (TOS1, TOS) -> (TOS1, bool)
337
337
  "CHECK_EG_MATCH": (-2, 2), # (TOS, TOS1) -> non-matched, matched or TOS1, None)
338
338
  "PREP_RERAISE_STAR": (-2, 1), # (TOS1, TOS) -> new exception group)
339
- **{k: (-1, 1) for k in (o for o in _opcode.opmap if (o.startswith("UNARY_")))},
340
- **{
341
- k: (-2, 1)
342
- for k in (
339
+ **dict.fromkeys((o for o in _opcode.opmap if o.startswith("UNARY_")), (-1, 1)),
340
+ **dict.fromkeys(
341
+ (
343
342
  o
344
343
  for o in _opcode.opmap
345
- if (o.startswith("BINARY_") or o.startswith("INPLACE_"))
346
- )
347
- },
344
+ if o.startswith("BINARY_") or o.startswith("INPLACE_")
345
+ ),
346
+ (-2, 1),
347
+ ),
348
348
  # Python 3.12 changes not covered by dis.stack_effect
349
349
  "BINARY_SLICE": (-3, 1),
350
350
  # "STORE_SLICE" handled by dis.stack_effect
@@ -5,7 +5,7 @@ from collections import namedtuple
5
5
  #: A namedtuple of the version info for the current release.
6
6
  _version_info = namedtuple("_version_info", "major minor micro status")
7
7
 
8
- parts = "0.16.1".split(".", 3)
8
+ parts = "0.16.2".split(".", 3)
9
9
  version_info = _version_info(
10
10
  int(parts[0]),
11
11
  int(parts[1]),
@@ -16,4 +16,4 @@ version_info = _version_info(
16
16
  # Remove everything but the 'version_info' from this module.
17
17
  del namedtuple, _version_info, parts
18
18
 
19
- __version__ = "0.16.1"
19
+ __version__ = "0.16.2"
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: bytecode
3
- Version: 0.16.1
3
+ Version: 0.16.2
4
4
  Summary: Python module to generate and modify bytecode
5
5
  Author-email: Victor Stinner <victor.stinner@gmail.com>
6
6
  Maintainer-email: "Matthieu C. Dartiailh" <m.dartiailh@gmail.com>
@@ -47,6 +47,7 @@ Requires-Python: >=3.8
47
47
  Description-Content-Type: text/x-rst
48
48
  License-File: COPYING
49
49
  Requires-Dist: typing_extensions; python_version < "3.10"
50
+ Dynamic: license-file
50
51
 
51
52
  ********
52
53
  bytecode
@@ -712,6 +712,20 @@ class BytecodeBlocksFunctionalTests(TestCase):
712
712
  other_block = BasicBlock()
713
713
  self.assertRaises(ValueError, blocks.get_block_index, other_block)
714
714
 
715
+ def test_get_dead_blocks(self):
716
+ def condition():
717
+ pass
718
+
719
+ def test():
720
+ if condition():
721
+ print("1")
722
+ else:
723
+ print("2")
724
+
725
+ bytecode = Bytecode.from_code(test.__code__)
726
+ cfg = ControlFlowGraph.from_bytecode(bytecode)
727
+ assert len(cfg.get_dead_blocks()) == 0
728
+
715
729
 
716
730
  class CFGStacksizeComputationTests(TestCase):
717
731
  def check_stack_size(self, func):
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes