Skip to content

Commit 422f8e9

Browse files
authored
gh-129805: Fix bytes annotation in Tools/jit (#129806)
1 parent cfe4103 commit 422f8e9

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

Tools/jit/_stencils.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,11 @@ class Hole:
141141
def __post_init__(self) -> None:
142142
self.func = _PATCH_FUNCS[self.kind]
143143

144-
def fold(self, other: typing.Self, body: bytes) -> typing.Self | None:
144+
def fold(
145+
self,
146+
other: typing.Self,
147+
body: bytes | bytearray,
148+
) -> typing.Self | None:
145149
"""Combine two holes into a single hole, if possible."""
146150
instruction_a = int.from_bytes(
147151
body[self.offset : self.offset + 4], byteorder=sys.byteorder

Tools/jit/_targets.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def _handle_section(self, section: _S, group: _stencils.StencilGroup) -> None:
9797
raise NotImplementedError(type(self))
9898

9999
def _handle_relocation(
100-
self, base: int, relocation: _R, raw: bytes
100+
self, base: int, relocation: _R, raw: bytes | bytearray
101101
) -> _stencils.Hole:
102102
raise NotImplementedError(type(self))
103103

@@ -257,7 +257,10 @@ def _unwrap_dllimport(self, name: str) -> tuple[_stencils.HoleValue, str | None]
257257
return _stencils.symbol_to_value(name)
258258

259259
def _handle_relocation(
260-
self, base: int, relocation: _schema.COFFRelocation, raw: bytes
260+
self,
261+
base: int,
262+
relocation: _schema.COFFRelocation,
263+
raw: bytes | bytearray,
261264
) -> _stencils.Hole:
262265
match relocation:
263266
case {
@@ -348,7 +351,10 @@ def _handle_section(
348351
}, section_type
349352

350353
def _handle_relocation(
351-
self, base: int, relocation: _schema.ELFRelocation, raw: bytes
354+
self,
355+
base: int,
356+
relocation: _schema.ELFRelocation,
357+
raw: bytes | bytearray,
352358
) -> _stencils.Hole:
353359
symbol: str | None
354360
match relocation:
@@ -424,7 +430,10 @@ def _handle_section(
424430
stencil.holes.append(hole)
425431

426432
def _handle_relocation(
427-
self, base: int, relocation: _schema.MachORelocation, raw: bytes
433+
self,
434+
base: int,
435+
relocation: _schema.MachORelocation,
436+
raw: bytes | bytearray,
428437
) -> _stencils.Hole:
429438
symbol: str | None
430439
match relocation:

0 commit comments

Comments
 (0)