Marc-Andre Lemburg <m...@egenix.com> added the comment:
FWIW, I've not found the importer for frozen modules to be lacking features. When using frozen modules, you don't expect to see source code, so the whole part about finding source code is not really relevant for that use case. The only lacking part I found regarding frozen modules is support for these in pkgutil.py. But that's easy to add: --- /home/lemburg/egenix/projects/PyRun/Python-3.8.0/Lib/pkgutil.py 2019-10-14 1> +++ ./Lib/pkgutil.py 2019-11-17 11:36:38.404752218 +0100 @@ -315,20 +315,27 @@ return self.etc[2]==imp.PKG_DIRECTORY def get_code(self, fullname=None): + # eGenix PyRun needs pkgutil to also work for frozen modules, + # since pkgutil is used by the runpy module, which is needed + # to implement the -m command line switch. + if self.code is not None: + return self.code fullname = self._fix_name(fullname) - if self.code is None: - mod_type = self.etc[2] - if mod_type==imp.PY_SOURCE: - source = self.get_source(fullname) - self.code = compile(source, self.filename, 'exec') - elif mod_type==imp.PY_COMPILED: - self._reopen() - try: - self.code = read_code(self.file) - finally: - self.file.close() - elif mod_type==imp.PKG_DIRECTORY: - self.code = self._get_delegate().get_code() + mod_type = self.etc[2] + if mod_type == imp.PY_FROZEN: + self.code = imp.get_frozen_object(fullname) + return self.code + elif mod_type==imp.PY_SOURCE: + source = self.get_source(fullname) + self.code = compile(source, self.filename, 'exec') + elif mod_type==imp.PY_COMPILED: + self._reopen() + try: + self.code = read_code(self.file) + finally: + self.file.close() + elif mod_type==imp.PKG_DIRECTORY: + self.code = self._get_delegate().get_code() return self.code def get_source(self, fullname=None): ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue45020> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com