[docs] [issue13402] Document absoluteness of sys.executable

Brad Larsen report at bugs.python.org
Mon Jul 11 22:59:08 EDT 2016

Brad Larsen added the comment:

@eryksun, you are right!  The output *is* an absolute path as far as `os.path.isabs` is concerned.

@ned.deily, you are right about my example --- I transcribed it wrong, and it should be `-c`.

The system in question is not a Mac OS system, but a Linux system with newer Python versions than what come with the system installed to /opt/local.  These are compiled from source, but without any modifications.

I'm commenting here because I'm seeing the `test_sys` test from the regression suite fail in a slightly modified version of Python that ships with a product.  In particular, in Lib/test/test_sys.py around line 640, we have this:

    @unittest.skipIf(sys.base_prefix != sys.prefix,
                     'Test is not venv-compatible')
    def test_executable(self):
        # sys.executable should be absolute
        self.assertEqual(os.path.abspath(sys.executable), sys.executable)

Yes, /opt/local/bin/../bin/python3.5 is an absolute path as far as `os.path.isabs` is concerned, but `os.path.abspath('/opt/local/bin/../bin/python3.5')` gives '/opt/local/bin/python3.5', and the test fails.  So maybe the documentation is fine but the test is wrong?


Python tracker <report at bugs.python.org>

More information about the docs mailing list