New submission from Decorater: So, I have a class (it subclasses the zipimporter for my import hook) that allows me to not worry about issues when the hook is appended to the beginning of the path hooks.
The code to the class as follows: class OriginalZipImport(zipimport.zipimporter): """ Original zipimporter class. Modified for requirements of this import hook. """ # Sadly I have to manually specify the file extensions the original # zipimporter supports to bypass an AttributeError. # according to https://docs.python.org/3.6/library/zipimport.html # zipimport only allows importing ``.py`` and ``.pyc`` files from zips. extensions = ['.py', '.pyc'] def __init__(self, archivepath): super(OriginalZipImport, self.inst).__init__(self, archivepath) def find_loader(self, fullname, path=None): """ Original find_loader. """ self.inst.find_loader(fullname, path=path) def find_module(self, fullname, path=None): """ Original find_module. """ self.inst.find_module(self, fullname, path=path) def load_module(self, fullname): """ Original load_module. """ self.inst.load_module(self, fullname) However instead of working like the way I would expect it gives this traceback: Traceback (most recent call last): File "E:\Users\Elsword\Desktop\DecoraterBot\Async\\zipmaker\make_zip.py", line 11, in <module> from pathlib import Path File "<frozen importlib._bootstrap>", line 961, in _find_and_load File "<frozen importlib._bootstrap>", line 946, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 885, in _find_spec File "<frozen importlib._bootstrap_external>", line 1157, in find_spec File "<frozen importlib._bootstrap_external>", line 1129, in _get_spec File "<frozen importlib._bootstrap_external>", line 1273, in find_spec File "<frozen importlib._bootstrap_external>", line 1229, in _get_spec File "E:\Users\Elsword\Desktop\DecoraterBot\Async\zipmaker\py2pycx\_pycx_backend.py", line 180, in find_loader self.inst.find_loader(fullname, path=path) AttributeError: 'str' object has no attribute 'inst' Note: it does use a slightly modified make_zip.py that is different than the one that is on the python source trees. It is specifically for testing the hook to see if it works or not. The hook is supposed to work however it is confusing why it is doing this as I did not set self to be an string so it should allow me to do all of this just fine. ---------- components: Interpreter Core messages: 285316 nosy: Decorater priority: normal severity: normal status: open title: self in classes missinterpreted as a string. versions: Python 3.6, Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29252> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com