Skip to content

Commit

Permalink
Core: fix invalid __package__ of zipped worlds (ArchipelagoMW#3686)
Browse files Browse the repository at this point in the history
* fix invalid package fix

* add comment describing fix
  • Loading branch information
Silvris authored Aug 10, 2024
1 parent 9dba39b commit 8e06ab4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion worlds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ def load(self) -> bool:
else: # TODO: remove with 3.8 support
mod = importer.load_module(os.path.basename(self.path).rsplit(".", 1)[0])

mod.__package__ = f"worlds.{mod.__package__}"
if mod.__package__ is not None:
mod.__package__ = f"worlds.{mod.__package__}"
else:
# load_module does not populate package, we'll have to assume mod.__name__ is correct here
# probably safe to remove with 3.8 support
mod.__package__ = f"worlds.{mod.__name__}"
mod.__name__ = f"worlds.{mod.__name__}"
sys.modules[mod.__name__] = mod
with warnings.catch_warnings():
Expand Down

0 comments on commit 8e06ab4

Please sign in to comment.