mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
Lingo: Fix world load on frozen 3.8 (#3220)
* Lingo: Fix world load on frozen 3.8 * Fixed absolute imports in unit test * Made unpickling safer
This commit is contained in:
committed by
GitHub
parent
fc4e6adff5
commit
487a067d10
@@ -78,13 +78,16 @@ def get_progressive_item_id(name: str):
|
||||
def load_static_data_from_file():
|
||||
global PAINTING_ENTRANCES, PAINTING_EXITS
|
||||
|
||||
from . import datatypes
|
||||
from Utils import safe_builtins
|
||||
|
||||
class RenameUnpickler(pickle.Unpickler):
|
||||
def find_class(self, module, name):
|
||||
renamed_module = module
|
||||
if module == "datatypes":
|
||||
renamed_module = "worlds.lingo.datatypes"
|
||||
|
||||
return super(RenameUnpickler, self).find_class(renamed_module, name)
|
||||
if module in ("worlds.lingo.datatypes", "datatypes"):
|
||||
return getattr(datatypes, name)
|
||||
elif module == "builtins" and name in safe_builtins:
|
||||
return getattr(safe_builtins, name)
|
||||
raise pickle.UnpicklingError(f"global '{module}.{name}' is forbidden")
|
||||
|
||||
file = pkgutil.get_data(__name__, os.path.join("data", "generated.dat"))
|
||||
pickdata = RenameUnpickler(BytesIO(file)).load()
|
||||
|
||||
Reference in New Issue
Block a user