diff options
Diffstat (limited to 'static_logic.py')
| -rw-r--r-- | static_logic.py | 13 |
1 files changed, 8 insertions, 5 deletions
| diff --git a/static_logic.py b/static_logic.py index c7ee001..ff820dd 100644 --- a/static_logic.py +++ b/static_logic.py | |||
| @@ -78,13 +78,16 @@ def get_progressive_item_id(name: str): | |||
| 78 | def load_static_data_from_file(): | 78 | def load_static_data_from_file(): |
| 79 | global PAINTING_ENTRANCES, PAINTING_EXITS | 79 | global PAINTING_ENTRANCES, PAINTING_EXITS |
| 80 | 80 | ||
| 81 | from . import datatypes | ||
| 82 | from Utils import safe_builtins | ||
| 83 | |||
| 81 | class RenameUnpickler(pickle.Unpickler): | 84 | class RenameUnpickler(pickle.Unpickler): |
| 82 | def find_class(self, module, name): | 85 | def find_class(self, module, name): |
| 83 | renamed_module = module | 86 | if module in ("worlds.lingo.datatypes", "datatypes"): |
| 84 | if module == "datatypes": | 87 | return getattr(datatypes, name) |
| 85 | renamed_module = "worlds.lingo.datatypes" | 88 | elif module == "builtins" and name in safe_builtins: |
| 86 | 89 | return getattr(safe_builtins, name) | |
| 87 | return super(RenameUnpickler, self).find_class(renamed_module, name) | 90 | raise pickle.UnpicklingError(f"global '{module}.{name}' is forbidden") |
| 88 | 91 | ||
| 89 | file = pkgutil.get_data(__name__, os.path.join("data", "generated.dat")) | 92 | file = pkgutil.get_data(__name__, os.path.join("data", "generated.dat")) |
| 90 | pickdata = RenameUnpickler(BytesIO(file)).load() | 93 | pickdata = RenameUnpickler(BytesIO(file)).load() |
