https://github.com/python/cpython/commit/422f8e9e02e68d45aee3846751a003a70fca13b6
commit: 422f8e9e02e68d45aee3846751a003a70fca13b6
branch: main
author: sobolevn <[email protected]>
committer: sobolevn <[email protected]>
date: 2025-02-17T10:55:30+03:00
summary:
gh-129805: Fix `bytes` annotation in `Tools/jit` (#129806)
files:
M Tools/jit/_stencils.py
M Tools/jit/_targets.py
diff --git a/Tools/jit/_stencils.py b/Tools/jit/_stencils.py
index ee761a73fa808a..8b6957f8bdbdfc 100644
--- a/Tools/jit/_stencils.py
+++ b/Tools/jit/_stencils.py
@@ -141,7 +141,11 @@ class Hole:
def __post_init__(self) -> None:
self.func = _PATCH_FUNCS[self.kind]
- def fold(self, other: typing.Self, body: bytes) -> typing.Self | None:
+ def fold(
+ self,
+ other: typing.Self,
+ body: bytes | bytearray,
+ ) -> typing.Self | None:
"""Combine two holes into a single hole, if possible."""
instruction_a = int.from_bytes(
body[self.offset : self.offset + 4], byteorder=sys.byteorder
diff --git a/Tools/jit/_targets.py b/Tools/jit/_targets.py
index d23ced19842347..7eb433e2a5b207 100644
--- a/Tools/jit/_targets.py
+++ b/Tools/jit/_targets.py
@@ -97,7 +97,7 @@ def _handle_section(self, section: _S, group:
_stencils.StencilGroup) -> None:
raise NotImplementedError(type(self))
def _handle_relocation(
- self, base: int, relocation: _R, raw: bytes
+ self, base: int, relocation: _R, raw: bytes | bytearray
) -> _stencils.Hole:
raise NotImplementedError(type(self))
@@ -257,7 +257,10 @@ def _unwrap_dllimport(self, name: str) ->
tuple[_stencils.HoleValue, str | None]
return _stencils.symbol_to_value(name)
def _handle_relocation(
- self, base: int, relocation: _schema.COFFRelocation, raw: bytes
+ self,
+ base: int,
+ relocation: _schema.COFFRelocation,
+ raw: bytes | bytearray,
) -> _stencils.Hole:
match relocation:
case {
@@ -348,7 +351,10 @@ def _handle_section(
}, section_type
def _handle_relocation(
- self, base: int, relocation: _schema.ELFRelocation, raw: bytes
+ self,
+ base: int,
+ relocation: _schema.ELFRelocation,
+ raw: bytes | bytearray,
) -> _stencils.Hole:
symbol: str | None
match relocation:
@@ -424,7 +430,10 @@ def _handle_section(
stencil.holes.append(hole)
def _handle_relocation(
- self, base: int, relocation: _schema.MachORelocation, raw: bytes
+ self,
+ base: int,
+ relocation: _schema.MachORelocation,
+ raw: bytes | bytearray,
) -> _stencils.Hole:
symbol: str | None
match relocation:
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]