bytecode 0.16.2__tar.gz → 0.18.0__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.
- {bytecode-0.16.2 → bytecode-0.18.0}/.github/workflows/cis.yml +7 -11
- {bytecode-0.16.2 → bytecode-0.18.0}/.github/workflows/docs.yml +2 -2
- {bytecode-0.16.2 → bytecode-0.18.0}/.github/workflows/frameworks.yml +3 -3
- {bytecode-0.16.2 → bytecode-0.18.0}/.github/workflows/release.yml +14 -15
- {bytecode-0.16.2 → bytecode-0.18.0}/.readthedocs.yaml +2 -2
- {bytecode-0.16.2/src/bytecode.egg-info → bytecode-0.18.0}/PKG-INFO +3 -5
- {bytecode-0.16.2 → bytecode-0.18.0}/doc/changelog.rst +48 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/pyproject.toml +15 -5
- {bytecode-0.16.2 → bytecode-0.18.0}/src/bytecode/bytecode.py +32 -18
- {bytecode-0.16.2 → bytecode-0.18.0}/src/bytecode/cfg.py +82 -57
- {bytecode-0.16.2 → bytecode-0.18.0}/src/bytecode/concrete.py +278 -388
- {bytecode-0.16.2 → bytecode-0.18.0}/src/bytecode/flags.py +22 -29
- {bytecode-0.16.2 → bytecode-0.18.0}/src/bytecode/instr.py +412 -194
- {bytecode-0.16.2 → bytecode-0.18.0}/src/bytecode/utils.py +1 -2
- {bytecode-0.16.2 → bytecode-0.18.0}/src/bytecode/version.py +2 -2
- {bytecode-0.16.2 → bytecode-0.18.0/src/bytecode.egg-info}/PKG-INFO +3 -5
- {bytecode-0.16.2 → bytecode-0.18.0}/tests/__init__.py +22 -58
- {bytecode-0.16.2 → bytecode-0.18.0}/tests/exception_handling_cases.py +20 -37
- {bytecode-0.16.2 → bytecode-0.18.0}/tests/frameworks/function.py +1 -1
- {bytecode-0.16.2 → bytecode-0.18.0}/tests/frameworks/module.py +3 -1
- {bytecode-0.16.2 → bytecode-0.18.0}/tests/test_bytecode.py +106 -170
- {bytecode-0.16.2 → bytecode-0.18.0}/tests/test_cfg.py +107 -118
- {bytecode-0.16.2 → bytecode-0.18.0}/tests/test_code.py +13 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/tests/test_concrete.py +150 -249
- {bytecode-0.16.2 → bytecode-0.18.0}/tests/test_flags.py +12 -43
- {bytecode-0.16.2 → bytecode-0.18.0}/tests/test_instr.py +67 -28
- {bytecode-0.16.2 → bytecode-0.18.0}/tests/test_misc.py +180 -154
- {bytecode-0.16.2 → bytecode-0.18.0}/tox.ini +1 -1
- {bytecode-0.16.2 → bytecode-0.18.0}/.coveragerc +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/.github/FUNDING.yml +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/.github/dependabot.yml +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/.gitignore +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/.pre-commit-config.yaml +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/COPYING +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/MANIFEST.in +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/README.rst +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/TODO.rst +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/codecov.yml +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/doc/Makefile +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/doc/api.rst +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/doc/byteplay_codetransformer.rst +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/doc/cfg.rst +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/doc/conf.py +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/doc/index.rst +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/doc/make.bat +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/doc/requirements.txt +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/doc/todo.rst +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/doc/usage.rst +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/scripts/frameworks/boto3/run.sh +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/scripts/frameworks/boto3/setup.sh +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/setup.cfg +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/src/bytecode/__init__.py +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/src/bytecode/py.typed +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/src/bytecode.egg-info/SOURCES.txt +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/src/bytecode.egg-info/dependency_links.txt +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/src/bytecode.egg-info/requires.txt +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/src/bytecode.egg-info/top_level.txt +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/tests/cell_free_vars_cases.py +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/tests/frameworks/sitecustomize.py +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/tests/long_lines_example.py +0 -0
- {bytecode-0.16.2 → bytecode-0.18.0}/tests/util_annotation.py +0 -0
|
@@ -20,9 +20,9 @@ jobs:
|
|
|
20
20
|
name: Lint code
|
|
21
21
|
runs-on: ubuntu-latest
|
|
22
22
|
steps:
|
|
23
|
-
- uses: actions/checkout@
|
|
23
|
+
- uses: actions/checkout@v6
|
|
24
24
|
- name: Set up Python
|
|
25
|
-
uses: actions/setup-python@
|
|
25
|
+
uses: actions/setup-python@v6
|
|
26
26
|
with:
|
|
27
27
|
python-version: "3.12"
|
|
28
28
|
- name: Install tools
|
|
@@ -42,26 +42,22 @@ jobs:
|
|
|
42
42
|
fail-fast: false
|
|
43
43
|
matrix:
|
|
44
44
|
include:
|
|
45
|
-
- python-version: "3.8"
|
|
46
|
-
toxenv: py38
|
|
47
|
-
- python-version: "3.9"
|
|
48
|
-
toxenv: py39
|
|
49
|
-
- python-version: "3.10"
|
|
50
|
-
toxenv: py310
|
|
51
45
|
- python-version: "3.11"
|
|
52
46
|
toxenv: py311
|
|
53
47
|
- python-version: "3.12"
|
|
54
48
|
toxenv: py312
|
|
55
49
|
- python-version: "3.13"
|
|
56
50
|
toxenv: py313
|
|
51
|
+
- python-version: "3.14"
|
|
52
|
+
toxenv: py314
|
|
57
53
|
steps:
|
|
58
|
-
- uses: actions/checkout@
|
|
54
|
+
- uses: actions/checkout@v6
|
|
59
55
|
- name: Get history and tags for SCM versioning to work
|
|
60
56
|
run: |
|
|
61
57
|
git fetch --prune --unshallow
|
|
62
58
|
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
|
|
63
59
|
- name: Set up Python ${{ matrix.python-version }}
|
|
64
|
-
uses: actions/setup-python@
|
|
60
|
+
uses: actions/setup-python@v6
|
|
65
61
|
with:
|
|
66
62
|
python-version: ${{ matrix.python-version }}
|
|
67
63
|
- name: Install dependencies
|
|
@@ -74,7 +70,7 @@ jobs:
|
|
|
74
70
|
run: |
|
|
75
71
|
tox
|
|
76
72
|
- name: Upload coverage to Codecov
|
|
77
|
-
uses: codecov/codecov-action@
|
|
73
|
+
uses: codecov/codecov-action@v6
|
|
78
74
|
if: github.event_name != 'schedule'
|
|
79
75
|
with:
|
|
80
76
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
@@ -19,13 +19,13 @@ jobs:
|
|
|
19
19
|
name: Docs building
|
|
20
20
|
runs-on: ubuntu-latest
|
|
21
21
|
steps:
|
|
22
|
-
- uses: actions/checkout@
|
|
22
|
+
- uses: actions/checkout@v6
|
|
23
23
|
- name: Get history and tags for SCM versioning to work
|
|
24
24
|
run: |
|
|
25
25
|
git fetch --prune --unshallow
|
|
26
26
|
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
|
|
27
27
|
- name: Set up Python
|
|
28
|
-
uses: actions/setup-python@
|
|
28
|
+
uses: actions/setup-python@v6
|
|
29
29
|
with:
|
|
30
30
|
python-version: '3.x'
|
|
31
31
|
- name: Install dependencies
|
|
@@ -21,15 +21,15 @@ jobs:
|
|
|
21
21
|
strategy:
|
|
22
22
|
fail-fast: false
|
|
23
23
|
matrix:
|
|
24
|
-
python-version: ["3.
|
|
24
|
+
python-version: ["3.11", "3.12", "3.13", "3.14"]
|
|
25
25
|
|
|
26
26
|
steps:
|
|
27
|
-
- uses: actions/checkout@
|
|
27
|
+
- uses: actions/checkout@v6
|
|
28
28
|
with:
|
|
29
29
|
fetch-depth: 0
|
|
30
30
|
|
|
31
31
|
- name: Set up Python
|
|
32
|
-
uses: actions/setup-python@
|
|
32
|
+
uses: actions/setup-python@v6
|
|
33
33
|
with:
|
|
34
34
|
python-version: ${{ matrix.python-version }}-dev
|
|
35
35
|
|
|
@@ -13,13 +13,13 @@ jobs:
|
|
|
13
13
|
runs-on: ubuntu-latest
|
|
14
14
|
steps:
|
|
15
15
|
- name: Checkout
|
|
16
|
-
uses: actions/checkout@
|
|
16
|
+
uses: actions/checkout@v6
|
|
17
17
|
- name: Get history and tags for SCM versioning to work
|
|
18
18
|
run: |
|
|
19
19
|
git fetch --prune --unshallow
|
|
20
20
|
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
|
|
21
21
|
- name: Setup Python
|
|
22
|
-
uses: actions/setup-python@
|
|
22
|
+
uses: actions/setup-python@v6
|
|
23
23
|
with:
|
|
24
24
|
python-version: '3.x'
|
|
25
25
|
- name: Build sdist
|
|
@@ -33,7 +33,7 @@ jobs:
|
|
|
33
33
|
pip install dist/*.tar.gz
|
|
34
34
|
python -X dev -m pytest tests
|
|
35
35
|
- name: Store artifacts
|
|
36
|
-
uses: actions/upload-artifact@
|
|
36
|
+
uses: actions/upload-artifact@v7
|
|
37
37
|
with:
|
|
38
38
|
name: cibw-sdist
|
|
39
39
|
path: dist/*
|
|
@@ -43,13 +43,13 @@ jobs:
|
|
|
43
43
|
runs-on: ubuntu-latest
|
|
44
44
|
steps:
|
|
45
45
|
- name: Checkout
|
|
46
|
-
uses: actions/checkout@
|
|
46
|
+
uses: actions/checkout@v6
|
|
47
47
|
- name: Get history and tags for SCM versioning to work
|
|
48
48
|
run: |
|
|
49
49
|
git fetch --prune --unshallow
|
|
50
50
|
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
|
|
51
51
|
- name: Setup Python
|
|
52
|
-
uses: actions/setup-python@
|
|
52
|
+
uses: actions/setup-python@v6
|
|
53
53
|
with:
|
|
54
54
|
python-version: '3.x'
|
|
55
55
|
- name: Build wheels
|
|
@@ -63,7 +63,7 @@ jobs:
|
|
|
63
63
|
pip install dist/*.whl
|
|
64
64
|
python -X dev -m pytest tests
|
|
65
65
|
- name: Store artifacts
|
|
66
|
-
uses: actions/upload-artifact@
|
|
66
|
+
uses: actions/upload-artifact@v7
|
|
67
67
|
with:
|
|
68
68
|
name: cibw-wheel
|
|
69
69
|
path: dist/*.whl
|
|
@@ -72,20 +72,20 @@ jobs:
|
|
|
72
72
|
if: github.event_name == 'push'
|
|
73
73
|
needs: [build_wheel, build_sdist]
|
|
74
74
|
runs-on: ubuntu-latest
|
|
75
|
+
environment:
|
|
76
|
+
name: pypi
|
|
77
|
+
url: https://pypi.org/p/bytecode
|
|
78
|
+
permissions:
|
|
79
|
+
id-token: write
|
|
75
80
|
steps:
|
|
76
81
|
- name: Download all the dists
|
|
77
|
-
uses: actions/download-artifact@
|
|
82
|
+
uses: actions/download-artifact@v8.0.1
|
|
78
83
|
with:
|
|
79
84
|
pattern: cibw-*
|
|
80
85
|
path: dist
|
|
81
86
|
merge-multiple: true
|
|
82
87
|
|
|
83
88
|
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
84
|
-
with:
|
|
85
|
-
user: __token__
|
|
86
|
-
password: ${{ secrets.pypi_password }}
|
|
87
|
-
# To test:
|
|
88
|
-
# repository_url: https://test.pypi.org/legacy/
|
|
89
89
|
|
|
90
90
|
github-release:
|
|
91
91
|
name: >-
|
|
@@ -101,15 +101,14 @@ jobs:
|
|
|
101
101
|
|
|
102
102
|
steps:
|
|
103
103
|
- name: Download all the dists
|
|
104
|
-
uses: actions/download-artifact@
|
|
104
|
+
uses: actions/download-artifact@v8.0.1
|
|
105
105
|
with:
|
|
106
106
|
pattern: cibw-*
|
|
107
107
|
path: dist
|
|
108
108
|
merge-multiple: true
|
|
109
109
|
- name: Sign the dists with Sigstore
|
|
110
|
-
uses: sigstore/gh-action-sigstore-python@
|
|
110
|
+
uses: sigstore/gh-action-sigstore-python@v3.3.0
|
|
111
111
|
with:
|
|
112
|
-
password: ${{ secrets.pypi_password }}
|
|
113
112
|
inputs: >-
|
|
114
113
|
./dist/*.tar.gz
|
|
115
114
|
./dist/*.whl
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bytecode
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.18.0
|
|
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>
|
|
@@ -36,14 +36,12 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
36
36
|
Classifier: Natural Language :: English
|
|
37
37
|
Classifier: Operating System :: OS Independent
|
|
38
38
|
Classifier: Programming Language :: Python :: 3
|
|
39
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
40
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
41
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
42
39
|
Classifier: Programming Language :: Python :: 3.11
|
|
43
40
|
Classifier: Programming Language :: Python :: 3.12
|
|
44
41
|
Classifier: Programming Language :: Python :: 3.13
|
|
42
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
45
43
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
46
|
-
Requires-Python: >=3.
|
|
44
|
+
Requires-Python: >=3.11
|
|
47
45
|
Description-Content-Type: text/x-rst
|
|
48
46
|
License-File: COPYING
|
|
49
47
|
Requires-Dist: typing_extensions; python_version < "3.10"
|
|
@@ -1,6 +1,54 @@
|
|
|
1
1
|
ChangeLog
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
+
03-06-2026: Version 0.18.0
|
|
5
|
+
--------------------------
|
|
6
|
+
|
|
7
|
+
- drop support for Python 3.9 and 3.10 PR #180
|
|
8
|
+
- Replace string literal type annotations with postponed evaluation using
|
|
9
|
+
``from __future__ import annotations`` PR #191
|
|
10
|
+
- multiple performance improvements
|
|
11
|
+
PRs #172, #193, #196, #194, #197, #198, #199, #200, #201,
|
|
12
|
+
#202, #203
|
|
13
|
+
|
|
14
|
+
Breaking changes:
|
|
15
|
+
|
|
16
|
+
- ``BasicBlock``, ``Bytecode``, and ``ConcreteBytecode`` now validate inserted
|
|
17
|
+
instructions at insertion time (``append``, ``extend``, ``insert``,
|
|
18
|
+
``__setitem__``) rather than during iteration. Code that relied on catching
|
|
19
|
+
``ValueError`` from ``list(block)`` or ``for instr in block:`` must wrap the
|
|
20
|
+
insertion call instead. PR #199
|
|
21
|
+
|
|
22
|
+
Bugfixes:
|
|
23
|
+
|
|
24
|
+
- Fix handling of END_ASYNC_FOR which is a backward jump PR #179
|
|
25
|
+
|
|
26
|
+
03-09-2025: Version 0.17.0
|
|
27
|
+
--------------------------
|
|
28
|
+
|
|
29
|
+
New features:
|
|
30
|
+
|
|
31
|
+
- Add support for Python 3.14 PR #166
|
|
32
|
+
|
|
33
|
+
Support for Python 3.14, comes with a number of changes reflecting changes in
|
|
34
|
+
CPython bytecode itself:
|
|
35
|
+
|
|
36
|
+
- introduced an enum for BINARY_OP argument which now supports subscribe.
|
|
37
|
+
When disassembling the enum is always used, when creating bytecode from
|
|
38
|
+
scratch integer values are coerced into the right enum member.
|
|
39
|
+
- support BUILD_TEMPLATE, BUILD_INTERPOLATION, LOAD_SMALL_INT, LOAD_FAST_BORROW
|
|
40
|
+
and LOAD_FAST_BORROW_LOAD_FAST_BORROW
|
|
41
|
+
- LOAD_COMMON_CONSTANT, LOAD_SPECIAL whose argument is described using dedicated
|
|
42
|
+
enums CommonConstant, SpecialMethod
|
|
43
|
+
- CONVERT_VALUE (FORMAT_VALUE in Python < 3.13) now use the FormatValue enum.
|
|
44
|
+
When disassembling the enum is always used, when creating bytecode from
|
|
45
|
+
scratch integer values are coerced into the right enum member.
|
|
46
|
+
|
|
47
|
+
Bugfixes:
|
|
48
|
+
|
|
49
|
+
- properly set the next_block attribute of the new block created by
|
|
50
|
+
ControlFlowGraph.split_block. PR #170
|
|
51
|
+
|
|
4
52
|
2025-04-14: Version 0.16.2
|
|
5
53
|
--------------------------
|
|
6
54
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name = "bytecode"
|
|
3
3
|
description = "Python module to generate and modify bytecode"
|
|
4
4
|
readme = "README.rst"
|
|
5
|
-
requires-python = ">=3.
|
|
5
|
+
requires-python = ">=3.11"
|
|
6
6
|
license = { file = "COPYING" }
|
|
7
7
|
authors = [{ name = "Victor Stinner", email = "victor.stinner@gmail.com" }]
|
|
8
8
|
maintainers = [{ name = "Matthieu C. Dartiailh", email = "m.dartiailh@gmail.com" }]
|
|
@@ -13,12 +13,10 @@
|
|
|
13
13
|
"Natural Language :: English",
|
|
14
14
|
"Operating System :: OS Independent",
|
|
15
15
|
"Programming Language :: Python :: 3",
|
|
16
|
-
"Programming Language :: Python :: 3.8",
|
|
17
|
-
"Programming Language :: Python :: 3.9",
|
|
18
|
-
"Programming Language :: Python :: 3.10",
|
|
19
16
|
"Programming Language :: Python :: 3.11",
|
|
20
17
|
"Programming Language :: Python :: 3.12",
|
|
21
18
|
"Programming Language :: Python :: 3.13",
|
|
19
|
+
"Programming Language :: Python :: 3.14",
|
|
22
20
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
23
21
|
]
|
|
24
22
|
dependencies = ["typing_extensions;python_version<'3.10'"]
|
|
@@ -36,6 +34,18 @@
|
|
|
36
34
|
requires = ["setuptools>=61.2", "wheel", "setuptools_scm[toml]>=3.4.3"]
|
|
37
35
|
build-backend = "setuptools.build_meta"
|
|
38
36
|
|
|
37
|
+
[dependency-groups]
|
|
38
|
+
dev = [
|
|
39
|
+
"mypy>=1.16.1",
|
|
40
|
+
"pytest>=8",
|
|
41
|
+
"pytest-cov>=6",
|
|
42
|
+
"ruff>=0.12.0",
|
|
43
|
+
]
|
|
44
|
+
test = [
|
|
45
|
+
"pytest>=8",
|
|
46
|
+
"pytest-cov",
|
|
47
|
+
]
|
|
48
|
+
|
|
39
49
|
[tool.setuptools_scm]
|
|
40
50
|
write_to = "src/bytecode/version.py"
|
|
41
51
|
write_to_template = """
|
|
@@ -74,7 +84,7 @@ __version__ = "{version}"
|
|
|
74
84
|
extra-standard-library = ["opcode"]
|
|
75
85
|
|
|
76
86
|
[tool.ruff.lint.mccabe]
|
|
77
|
-
max-complexity =
|
|
87
|
+
max-complexity = 43
|
|
78
88
|
|
|
79
89
|
[tool.mypy]
|
|
80
90
|
follow_imports = "normal"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
3
|
import types
|
|
4
4
|
from abc import abstractmethod
|
|
5
5
|
from typing import (
|
|
@@ -16,6 +16,7 @@ from typing import (
|
|
|
16
16
|
overload,
|
|
17
17
|
)
|
|
18
18
|
|
|
19
|
+
# alias to keep the 'bytecode' variable free
|
|
19
20
|
import bytecode as _bytecode
|
|
20
21
|
from bytecode.flags import CompilerFlags, infer_flags
|
|
21
22
|
from bytecode.instr import (
|
|
@@ -28,7 +29,6 @@ from bytecode.instr import (
|
|
|
28
29
|
TryBegin,
|
|
29
30
|
TryEnd,
|
|
30
31
|
)
|
|
31
|
-
from bytecode.utils import PY311
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
class BaseBytecode:
|
|
@@ -50,7 +50,7 @@ class BaseBytecode:
|
|
|
50
50
|
self.freevars: List[str] = []
|
|
51
51
|
self._flags: CompilerFlags = CompilerFlags(0)
|
|
52
52
|
|
|
53
|
-
def _copy_attr_from(self, bytecode:
|
|
53
|
+
def _copy_attr_from(self, bytecode: BaseBytecode) -> None:
|
|
54
54
|
self.argcount = bytecode.argcount
|
|
55
55
|
self.posonlyargcount = bytecode.posonlyargcount
|
|
56
56
|
self.kwonlyargcount = bytecode.kwonlyargcount
|
|
@@ -164,15 +164,33 @@ class _BaseBytecodeList(BaseBytecode, list, Generic[U]):
|
|
|
164
164
|
for i in reversed(lineno_pos):
|
|
165
165
|
del self[i]
|
|
166
166
|
|
|
167
|
-
def __iter__(self) -> Iterator[U]:
|
|
168
|
-
instructions = super().__iter__()
|
|
169
|
-
for instr in instructions:
|
|
170
|
-
self._check_instr(instr)
|
|
171
|
-
yield instr
|
|
172
|
-
|
|
173
167
|
def _check_instr(self, instr):
|
|
174
168
|
raise NotImplementedError()
|
|
175
169
|
|
|
170
|
+
def append(self, instr: U) -> None: # type: ignore[override]
|
|
171
|
+
self._check_instr(instr)
|
|
172
|
+
super().append(instr)
|
|
173
|
+
|
|
174
|
+
def insert(self, index: SupportsIndex, instr: U) -> None: # type: ignore[override]
|
|
175
|
+
self._check_instr(instr)
|
|
176
|
+
super().insert(index, instr)
|
|
177
|
+
|
|
178
|
+
def extend(self, instrs) -> None: # type: ignore[override]
|
|
179
|
+
instrs = list(instrs)
|
|
180
|
+
for instr in instrs:
|
|
181
|
+
self._check_instr(instr)
|
|
182
|
+
super().extend(instrs)
|
|
183
|
+
|
|
184
|
+
def __setitem__(self, index, value):
|
|
185
|
+
if isinstance(index, slice):
|
|
186
|
+
values = list(value)
|
|
187
|
+
for v in values:
|
|
188
|
+
self._check_instr(v)
|
|
189
|
+
super().__setitem__(index, values)
|
|
190
|
+
else:
|
|
191
|
+
self._check_instr(value)
|
|
192
|
+
super().__setitem__(index, value)
|
|
193
|
+
|
|
176
194
|
|
|
177
195
|
V = TypeVar("V")
|
|
178
196
|
|
|
@@ -242,15 +260,11 @@ class Bytecode(
|
|
|
242
260
|
) -> None:
|
|
243
261
|
BaseBytecode.__init__(self)
|
|
244
262
|
self.argnames: List[str] = []
|
|
245
|
-
for instr in instructions:
|
|
246
|
-
self._check_instr(instr)
|
|
247
263
|
self.extend(instructions)
|
|
248
264
|
|
|
249
265
|
def __iter__(self) -> Iterator[Union[Instr, Label, TryBegin, TryEnd, SetLineno]]:
|
|
250
|
-
instructions = super().__iter__()
|
|
251
266
|
seen_try_begin = False
|
|
252
|
-
for instr in
|
|
253
|
-
self._check_instr(instr)
|
|
267
|
+
for instr in super().__iter__():
|
|
254
268
|
if isinstance(instr, TryBegin):
|
|
255
269
|
if seen_try_begin:
|
|
256
270
|
raise RuntimeError("TryBegin pseudo instructions cannot be nested.")
|
|
@@ -277,7 +291,7 @@ class Bytecode(
|
|
|
277
291
|
code: types.CodeType,
|
|
278
292
|
prune_caches: bool = True,
|
|
279
293
|
conserve_exception_block_stackdepth: bool = False,
|
|
280
|
-
) ->
|
|
294
|
+
) -> Bytecode:
|
|
281
295
|
concrete = _bytecode.ConcreteBytecode.from_code(code)
|
|
282
296
|
return concrete.to_bytecode(
|
|
283
297
|
prune_caches=prune_caches,
|
|
@@ -298,7 +312,7 @@ class Bytecode(
|
|
|
298
312
|
) -> types.CodeType:
|
|
299
313
|
# Prevent reconverting the concrete bytecode to bytecode and cfg to do the
|
|
300
314
|
# calculation if we need to do it.
|
|
301
|
-
if stacksize is None or
|
|
315
|
+
if stacksize is None or compute_exception_stack_depths:
|
|
302
316
|
cfg = _bytecode.ControlFlowGraph.from_bytecode(self)
|
|
303
317
|
stacksize = cfg.compute_stacksize(
|
|
304
318
|
check_pre_and_post=check_pre_and_post,
|
|
@@ -319,7 +333,7 @@ class Bytecode(
|
|
|
319
333
|
self,
|
|
320
334
|
compute_jumps_passes: Optional[int] = None,
|
|
321
335
|
compute_exception_stack_depths: bool = True,
|
|
322
|
-
) ->
|
|
336
|
+
) -> _bytecode.ConcreteBytecode:
|
|
323
337
|
converter = _bytecode._ConvertBytecodeToConcrete(self)
|
|
324
338
|
return converter.to_concrete_bytecode(
|
|
325
339
|
compute_jumps_passes=compute_jumps_passes,
|