From bb462399c7b64487d68d0a1e05c2d09e5d67b627 Mon Sep 17 00:00:00 2001 From: CensoredUsername Date: Wed, 17 Apr 2024 02:25:14 +0200 Subject: [PATCH] Handle #216: issues during re-pickling of data for the translations feature. --- decompiler/magic.py | 14 +++++++------- decompiler/renpycompat.py | 8 ++++++++ un.rpyc/corrupy | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/decompiler/magic.py b/decompiler/magic.py index 728ff0d..809cbb4 100644 --- a/decompiler/magic.py +++ b/decompiler/magic.py @@ -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 diff --git a/decompiler/renpycompat.py b/decompiler/renpycompat.py index e6ef388..bdb9253 100644 --- a/decompiler/renpycompat.py +++ b/decompiler/renpycompat.py @@ -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) @@ -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) diff --git a/un.rpyc/corrupy b/un.rpyc/corrupy index 82ecacb..f6322c9 160000 --- a/un.rpyc/corrupy +++ b/un.rpyc/corrupy @@ -1 +1 @@ -Subproject commit 82ecacb1a81cdd726748a8fc2aa4b72f6d3a33a6 +Subproject commit f6322c95e2d3762249e241e65b65c64ca00ade77