]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-129805: Fix `bytes` annotation in `Tools/jit` (#129806)
authorsobolevn <mail@sobolevn.me>
Mon, 17 Feb 2025 07:55:30 +0000 (10:55 +0300)
committerGitHub <noreply@github.com>
Mon, 17 Feb 2025 07:55:30 +0000 (10:55 +0300)
Tools/jit/_stencils.py
Tools/jit/_targets.py

index ee761a73fa808a7756e7c1b41e024f34a5471d47..8b6957f8bdbdfc00dd9a9c163e40f955e390949d 100644 (file)
@@ -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
index d23ced198423474b72568d551c91dfd39b9d614b..7eb433e2a5b2077422f7baf686aabab17173ae7b 100644 (file)
@@ -97,7 +97,7 @@ class _Target(typing.Generic[_S, _R]):
         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 @@ class _COFF(
         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 @@ class _ELF(
             }, 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 @@ class _MachO(
             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: