Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:
The patch for the Python implementation of zipimport (see issue25711) is much simpler (see the attached sample patch). But it requires adding a way of modifying co_filename. Currently code objects are immutable. This issue looks as a part of the larger problem. Zipimport is not the only source of precompiled bytecode which needs updating co_filename. For example the tree of py and pyc files can be moved to other place. Also, since co_filename contains system depended path, it doesn't make sense when load pyc files on other system (for example if they were created on Linux and ran on Windows). On other side, the import machinery tries to load pyc and py files, therefore it should know the path of corresponding py file when load a pyc file. Maybe it be better to not save co_filename in a pyc file (note that all code object in a file have the same co_filename, but it is saved for every code object), but set co_filename after unmarshalling the module bytecode by the import machinery in all loaders. ---------- Added file: https://bugs.python.org/file47775/pyzipimport-code-filename.diff _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue18307> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com