Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ca9650e
update for 3.14
MatthieuDartiailh Jun 23, 2025
9bcecf7
enable 3.14 in CIs
MatthieuDartiailh Jun 23, 2025
d7a0304
flags: remove reliance on removed opcode
MatthieuDartiailh Jun 23, 2025
9112c91
drop support for Python 3.8
MatthieuDartiailh Jun 23, 2025
3ec8e3b
properly use BinaryOp enum for BINARY_OP opcode
MatthieuDartiailh Jun 23, 2025
742b317
cis: fix python version for framework tests
MatthieuDartiailh Jun 23, 2025
b837f21
fix linting issue
MatthieuDartiailh Jun 23, 2025
7b51464
tests: fix typing error
MatthieuDartiailh Jun 23, 2025
6b4a2d4
instr: properly handle instruction dealing with formatting and fix Sp…
MatthieuDartiailh Jun 29, 2025
006fb53
tests: fix for 3.14
MatthieuDartiailh Jun 29, 2025
40fc121
allow slight increase in function complexity and fix version bound on…
MatthieuDartiailh Jun 29, 2025
6de8222
fix typing and minor test issues
MatthieuDartiailh Jun 29, 2025
82fdafe
fix typo in test
MatthieuDartiailh Jun 29, 2025
795e410
ci: fix to run framework test on 3.14
MatthieuDartiailh Jul 3, 2025
108a4a1
tests for validation of the argument of the following instructions: B…
makslevental Jul 25, 2025
bc8e6c0
use opcode groups
makslevental Aug 10, 2025
f6fcfc3
pyproject: add depdency groups for development requirements
MatthieuDartiailh Aug 10, 2025
48d0c95
ci: switch to trusted publishing
MatthieuDartiailh Aug 10, 2025
d6cafe5
update XXX comment to FIXME
MatthieuDartiailh Aug 20, 2025
bcb284d
ci: upgrade to checkout v5
MatthieuDartiailh Aug 20, 2025
6c29624
instr: make usage of BinaryOp enum be backward compatible
MatthieuDartiailh Aug 20, 2025
6586e60
tests: add test for CONVERT_VALUE/FORMAT_VALUE
MatthieuDartiailh Aug 20, 2025
c78f391
instr: allow to coerce int to FormatValue for backward compatibility
MatthieuDartiailh Aug 21, 2025
2a9ffaa
rename CommonConstants to CommonConstant
MatthieuDartiailh Aug 21, 2025
8a7a4f7
update changelog
MatthieuDartiailh Aug 21, 2025
75013eb
fix binary op arg coercion
MatthieuDartiailh Aug 21, 2025
dc7da4d
tests: fix instr arg validation logic
MatthieuDartiailh Aug 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/cis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
name: Lint code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v5
with:
Expand All @@ -42,8 +42,6 @@ jobs:
fail-fast: false
matrix:
include:
- python-version: "3.8"
toxenv: py38
- python-version: "3.9"
toxenv: py39
- python-version: "3.10"
Expand All @@ -54,8 +52,10 @@ jobs:
toxenv: py312
- python-version: "3.13"
toxenv: py313
- python-version: "3.14-dev"
toxenv: py314
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
name: Docs building
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/frameworks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
fetch-depth: 0

Expand Down
17 changes: 8 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
Expand Down Expand Up @@ -72,6 +72,11 @@ jobs:
if: github.event_name == 'push'
needs: [build_wheel, build_sdist]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/kiwisolver
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v5.0.0
Expand All @@ -81,11 +86,6 @@ jobs:
merge-multiple: true

- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.pypi_password }}
# To test:
# repository_url: https://test.pypi.org/legacy/

github-release:
name: >-
Expand All @@ -107,9 +107,8 @@ jobs:
path: dist
merge-multiple: true
- name: Sign the dists with Sigstore
uses: sigstore/gh-action-sigstore-python@v2.1.0
uses: sigstore/gh-action-sigstore-python@v3.0.1
with:
password: ${{ secrets.pypi_password }}
inputs: >-
./dist/*.tar.gz
./dist/*.whl
Expand Down
22 changes: 22 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
ChangeLog
=========

unreleased: Version 0.17.0
--------------------------

New features:

- Add support for Python 3.14 PR #166

Support for Python 3.14, comes with a number of changes reflecting changes in
CPython bytecode itself:

- introduced an enum for BINARY_OP argument which now supports subscribe.
When disassembling the enum is always used, when creating bytecode from
scratch integer values are coerced into the right enum member.
- support BUILD_TEMPLATE, BUILD_INTERPOLATION, LOAD_SMALL_INT, LOAD_FAST_BORROW
and LOAD_FAST_BORROW_LOAD_FAST_BORROW
- LOAD_COMMON_CONSTANT, LOAD_SPECIAL whose argument is described using dedicated
enums CommonConstant, SpecialMethod
- CONVERT_VALUE (FORMAT_VALUE in Python < 3.13) now use the FormatValue enum.
When disassembling the enum is always used, when creating bytecode from
scratch integer values are coerced into the right enum member.


2025-04-14: Version 0.16.2
--------------------------

Expand Down
18 changes: 15 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "bytecode"
description = "Python module to generate and modify bytecode"
readme = "README.rst"
requires-python = ">=3.8"
requires-python = ">=3.9"
license = { file = "COPYING" }
authors = [{ name = "Victor Stinner", email = "victor.stinner@gmail.com" }]
maintainers = [{ name = "Matthieu C. Dartiailh", email = "m.dartiailh@gmail.com" }]
Expand All @@ -13,12 +13,12 @@
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = ["typing_extensions;python_version<'3.10'"]
Expand All @@ -36,6 +36,18 @@
requires = ["setuptools>=61.2", "wheel", "setuptools_scm[toml]>=3.4.3"]
build-backend = "setuptools.build_meta"

[dependency-groups]
dev = [
"mypy>=1.16.1",
"pytest>=8",
"pytest-cov>=6",
"ruff>=0.12.0",
]
test = [
"pytest>=8",
"pytest-cov",
]

[tool.setuptools_scm]
write_to = "src/bytecode/version.py"
write_to_template = """
Expand Down Expand Up @@ -74,7 +86,7 @@ __version__ = "{version}"
extra-standard-library = ["opcode"]

[tool.ruff.lint.mccabe]
max-complexity = 42
max-complexity = 43

[tool.mypy]
follow_imports = "normal"
Expand Down
37 changes: 33 additions & 4 deletions src/bytecode/concrete.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,25 @@
from bytecode.flags import CompilerFlags
from bytecode.instr import (
_UNSET,
BINARY_OPS,
BITFLAG2_OPCODES,
BITFLAG_OPCODES,
COMMON_CONSTANT_OPS,
DUAL_ARG_OPCODES,
DUAL_ARG_OPCODES_SINGLE_OPS,
FORMAT_VALUE_OPS,
INTRINSIC,
INTRINSIC_1OP,
INTRINSIC_2OP,
PLACEHOLDER_LABEL,
SPECIAL_OPS,
UNSET,
BaseInstr,
BinaryOp,
CellVar,
CommonConstant,
Compare,
FormatValue,
FreeVar,
Instr,
InstrArg,
Expand All @@ -46,6 +53,7 @@
Intrinsic2Op,
Label,
SetLineno,
SpecialMethod,
TryBegin,
TryEnd,
_check_arg_int,
Expand Down Expand Up @@ -1056,7 +1064,10 @@ def to_bytecode(
arg = locals_lookup[c_arg]
elif opcode in _opcode.hasname:
if opcode in BITFLAG_OPCODES:
arg = (bool(c_arg & 1), self.names[c_arg >> 1])
arg = (
bool(c_arg & 1),
self.names[c_arg >> 1],
)
elif opcode in BITFLAG2_OPCODES:
arg = (bool(c_arg & 1), bool(c_arg & 2), self.names[c_arg >> 2])
else:
Expand All @@ -1082,6 +1093,20 @@ def to_bytecode(
arg = Intrinsic1Op(c_arg)
elif opcode in INTRINSIC_2OP:
arg = Intrinsic2Op(c_arg)
elif opcode in BINARY_OPS:
arg = BinaryOp(c_arg)
elif opcode in COMMON_CONSTANT_OPS:
arg = CommonConstant(c_arg)
elif opcode in SPECIAL_OPS:
arg = SpecialMethod(c_arg)
elif opcode in FORMAT_VALUE_OPS:
if opcode in BITFLAG_OPCODES:
arg = (
bool(c_arg & 1),
FormatValue(c_arg >> 1),
)
else:
arg = FormatValue(c_arg)
else:
arg = c_arg

Expand Down Expand Up @@ -1143,7 +1168,7 @@ def to_bytecode(


class _ConvertBytecodeToConcrete:
# XXX document attributes
# FIXME document attributes

#: Default number of passes of compute_jumps() before giving up. Refer to
#: assemble_jump_offsets() in compile.c for background.
Expand Down Expand Up @@ -1316,9 +1341,13 @@ def concrete_instructions(self) -> None:
isinstance(arg, tuple)
and len(arg) == 2
and isinstance(arg[0], bool)
and isinstance(arg[1], str)
), arg
index = self.add(self.names, arg[1])
if isinstance(arg[1], str):
index = self.add(self.names, arg[1])
elif isinstance(arg, FormatValue):
index = int(arg)
else:
assert False, arg # noqa
c_arg = int(arg[0]) + (index << 1)
elif opcode in BITFLAG2_OPCODES:
assert (
Expand Down
4 changes: 2 additions & 2 deletions src/bytecode/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import bytecode as _bytecode

from .instr import DUAL_ARG_OPCODES, CellVar, FreeVar
from .utils import PY311, PY312, PY313
from .utils import PY311, PY312, PY313, PY314


class CompilerFlags(IntFlag):
Expand Down Expand Up @@ -48,7 +48,7 @@ class CompilerFlags(IntFlag):
_opcode.opmap["GET_AWAITABLE"],
_opcode.opmap["GET_AITER"],
_opcode.opmap["GET_ANEXT"],
_opcode.opmap["BEFORE_ASYNC_WITH"],
*((_opcode.opmap["BEFORE_ASYNC_WITH"],) if not PY314 else ()), # Removed in 3.14+
*((_opcode.opmap["SETUP_ASYNC_WITH"],) if not PY311 else ()), # Removed in 3.11+
_opcode.opmap["END_ASYNC_FOR"],
*((_opcode.opmap["ASYNC_GEN_WRAP"],) if PY311 and not PY312 else ()), # New in 3.11
Expand Down
Loading