New submission from Éric Araujo <mer...@netwok.org>: I recently changed packaging.util.byte_compile, the function used by the build_py and install_lib commands, so that it can create .pyc and/or .pyo files independently of the calling’s Python -O or -B flags (dad02a080bbc), but I think I introduced a bug. To check that bug and fully test byte_compile before I further simplify the function and backport the whole fix to distutils, I wanted to add tests that load a .pyc or .pyo file and make sure that the right optimization level is used (nothing for --compile, level one for --optimize=1, level 2 for --optimize=2).
In the attached patch, I run a Python with -O, -OO or no flag in a subprocess to import a module that prints different things depending on the optimization level. The .pyc or .pyo file is already created by packaging, but I have no check that makes sure that they are not recreated (which I don’t want) and I don’t know if the optimizations in compile.c are applied during byte-compilation or after import (which would make my tests not exercise what I want). (I tried to use imp.load_module at first but it’s not very friendly. Other ideas that I had after the patch was done: Use subprocess + imp so that I can import pyc or pyo as I wish; use open + dis module.) So, could you import experts review the functions added in packaging.tests.support and tell me if they exercise what I want? ---------- assignee: eric.araujo components: Distutils, Distutils2 files: p7g-tests-bytecompiled-files.diff keywords: patch messages: 148258 nosy: alexis, brett.cannon, eric.araujo, ncoghlan, tarek priority: normal severity: normal stage: commit review status: open title: Add tests for files byte-compiled by distutils[2] versions: 3rd party, Python 2.7, Python 3.2, Python 3.3 Added file: http://bugs.python.org/file23768/p7g-tests-bytecompiled-files.diff _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue13473> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com