diff --git a/.github/workflows/python-app.yaml b/.github/workflows/python-app.yaml index 39d8e26..3d1d137 100644 --- a/.github/workflows/python-app.yaml +++ b/.github/workflows/python-app.yaml @@ -13,15 +13,18 @@ jobs: tests-py3: name: Runs tests runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.9", "3.12"] steps: - uses: actions/checkout@v4 with: submodules: recursive - - name: Set up Python 3 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: - python-version: "3.9" + python-version: ${{ matrix.python-version }} - name: Test by decompiling a script and building un.rpyc run: | # test the command line tool diff --git a/decompiler/magic.py b/decompiler/magic.py index 809cbb4..f7655d6 100644 --- a/decompiler/magic.py +++ b/decompiler/magic.py @@ -29,6 +29,12 @@ import pickle import struct +try: + # only available (and needed) from 3.4 onwards. + from importlib.machinery import ModuleSpec +except: + pass + if PY3: from io import BytesIO as StringIO else: @@ -402,19 +408,36 @@ class FakePackageLoader(object): this ensures that any attempt to get a submodule from module *root* results in a FakePackage, creating the illusion that *root* is an actual package tree. + + This class is both a `finder` and a `loader` """ def __init__(self, root): self.root = root + # the old way of loading modules. find_module returns a loader for the + # given module. In this case, that is this object itself again. + def find_module(self, fullname, path=None): if fullname == self.root or fullname.startswith(self.root + "."): return self else: return None + # the new way of loading modules. It returns a ModuleSpec, that has + # the loader attribute set to this class. + + def find_spec(self, fullname, path, target=None): + if fullname == self.root or fullname.startswith(self.root + "."): + return ModuleSpec(fullname, self) + else: + return None + + # loader methods. This loads the module. + def load_module(self, fullname): return FakePackage(fullname) + # Fake unpickler implementation class FakeUnpicklingError(pickle.UnpicklingError): diff --git a/un.rpyc/corrupy b/un.rpyc/corrupy index f6322c9..a5ee0c9 160000 --- a/un.rpyc/corrupy +++ b/un.rpyc/corrupy @@ -1 +1 @@ -Subproject commit f6322c95e2d3762249e241e65b65c64ca00ade77 +Subproject commit a5ee0c9fa5282b1bc905ae4928da525b5d369954