mirror of
https://github.com/syssec-utd/pylingual.git
synced 2026-05-10 18:39:03 -07:00
fix slice masking
This commit is contained in:
@@ -195,6 +195,8 @@ class Masker:
|
||||
continue # don't mask None
|
||||
elif type(const) in (list, tuple, frozenset):
|
||||
consts[idx] = type(const)(replace_list(list(const)))
|
||||
elif type(const) is slice:
|
||||
consts[idx] = f"{self.mask(const.start)} : {self.mask(const.stop)} : {self.mask(const.step)}"
|
||||
else:
|
||||
consts[idx] = self.mask(const)
|
||||
return consts
|
||||
@@ -214,6 +216,8 @@ class Masker:
|
||||
# demote quotes one layer
|
||||
arg_repr = repr(type(inst.argval)(consts)).replace("'", "").replace('"', "'")
|
||||
view = f"{inst.opname} , {arg_repr}"
|
||||
elif type(inst.argval) is slice:
|
||||
view = f"{inst.opname} , {self.mask(inst.argval.start)} : {self.mask(inst.argval.stop)} : {self.mask(inst.argval.step)}"
|
||||
else:
|
||||
view = f"{inst.opname} , {self.mask(inst.bytecode.resolve_namespace(inst.argval))}"
|
||||
|
||||
|
||||
@@ -56,6 +56,9 @@ def create_global_masker(bytecode: EditableBytecode) -> Masker:
|
||||
continue
|
||||
if type(const) in (list, tuple, frozenset, set):
|
||||
consts.extend(const)
|
||||
elif type(const) is slice:
|
||||
# decompose slice constants for 3.14+
|
||||
consts.extend([const.start, const.stop, const.step])
|
||||
else:
|
||||
global_tab.update({bc.resolve_namespace(const): f"<mask_{global_idx}>"})
|
||||
global_idx += 1
|
||||
|
||||
Reference in New Issue
Block a user