Skip to content

Commit

Permalink
Handle CensoredUsername#216: issues during re-pickling of data for th…
Browse files Browse the repository at this point in the history
…e translations feature.
  • Loading branch information
CensoredUsername committed Apr 17, 2024
1 parent 7ab374a commit bb46239
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
14 changes: 7 additions & 7 deletions decompiler/magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,22 +538,22 @@ class SafePickler(pickle.Pickler if PY2 else pickle._Pickler):
the classes themselves, and we need to override the method used for normally saving classes.
"""

def save_global(self, obj, name=None, pack=struct.pack):
def save_global(self, obj, name=None, pack=None):
if isinstance(obj, FakeClassType):
if PY2:
self.write(pickle.GLOBAL + obj.__module__ + '\n' + obj.__name__ + '\n')
self.write(pickle.GLOBAL
+ obj.__module__ + '\n' + obj.__name__ + '\n')
elif self.proto >= 4:
self.save(obj.__module__)
self.save(obj.__name__)
self.write(STACK_GLOBAL)
self.write(pickle.STACK_GLOBAL)
else:
self.write(pickle.GLOBAL +
(obj.__module__ + '\n' + obj.__name__ + '\n').decode("utf-8")
)
self.write(pickle.GLOBAL
+ (obj.__module__ + '\n' + obj.__name__ + '\n').decode("utf-8"))
self.memoize(obj)
return

pickle.Pickler.save_global(self, obj, name, pack)
super().save_global(obj, name)

# the main API

Expand Down
8 changes: 8 additions & 0 deletions decompiler/renpycompat.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
class oldset(set):
__module__ = "__builtin__"

def __reduce__(self):
cls, args, state = super().__reduce__()
return (set, args, state)


oldset.__name__ = "set"
SPECIAL_CLASSES.append(oldset)
Expand All @@ -50,6 +54,10 @@ class oldset(set):
class oldfrozenset(frozenset):
__module__ = "__builtin__"

def __reduce__(self):
cls, args, state = super().__reduce__()
return (frozenset, args, state)


oldfrozenset.__name__ = "frozenset"
SPECIAL_CLASSES.append(oldfrozenset)
Expand Down
2 changes: 1 addition & 1 deletion un.rpyc/corrupy
Submodule corrupy updated 2 files
+5 −5 codegen.py
+8 −7 picklemagic.py

0 comments on commit bb46239

Please sign in to comment.