Skip to content

Commit a971785

Browse files
committed
fix slice unmarshalling
1 parent 4b47d7f commit a971785

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

xdis/unmarshal.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ def __init__(self, fp, magic_int, bytes_for_s, code_objects={}) -> None:
153153

154154
self.bytes_for_s = bytes_for_s
155155
version = magic_int2tuple(self.magic_int)
156-
if version >= (3, 4):
156+
if version >= (3, 14):
157+
self.marshal_version = 5
158+
elif (3, 14) > version >= (3, 4):
157159
if self.magic_int in (3250, 3260, 3270):
158160
self.marshal_version = 3
159161
else:
@@ -455,9 +457,9 @@ def t_python2_string_reference(self, save_ref, bytes_for_s: bool = False):
455457
refnum = unpack("<i", self.fp.read(4))[0]
456458
return self.internStrings[refnum]
457459

458-
# for the new TYPE_SLICE in marshal.c
460+
# for the new TYPE_SLICE in marshal version 5
459461
def t_slice(self, save_ref, bytes_for_s: bool = False):
460-
retval, idx = self.r_ref_reserve(tuple(), save_ref)
462+
retval, idx = self.r_ref_reserve(slice(None, None, None), save_ref)
461463

462464
if idx and idx < 0:
463465
return
@@ -477,7 +479,7 @@ def t_slice(self, save_ref, bytes_for_s: bool = False):
477479
if not step:
478480
return
479481

480-
retval += (start, stop, step)
482+
retval = slice(start, stop, step)
481483
return self.r_ref_insert(retval, idx)
482484

483485
def t_code(self, save_ref, bytes_for_s: bool = False):
@@ -581,6 +583,8 @@ def t_code(self, save_ref, bytes_for_s: bool = False):
581583
co_freevars = tuple()
582584
co_cellvars = tuple()
583585

586+
breakpoint()
587+
584588
if self.version_tuple >= (3, 11) and not self.is_pypy:
585589
# parse localsplusnames list: https://github.com/python/cpython/blob/3.11/Objects/codeobject.c#L208C12
586590
co_localsplusnames = self.r_object(bytes_for_s=bytes_for_s)

0 commit comments

Comments
 (0)