Issue 10210: os.get_exec_path() should not produce any warning (original) (raw)
Using -b command line option, os.get_exec_path() always produce a warning. Example:
$ ./python -b
import os: os.get_exec_path({'PATH': ''}) .../Lib/os.py:395: BytesWarning: Comparison between bytes and string path_listb = env[b'PATH'] ['']
You can see such warning on some buildbots. This function should make this warning quiet because it is expected: it is not possible to check that a dict contains 'PATH' and b'PATH' keys without emiting a BytesWarning (see issue #9636).
Attached patch fixes this bug. It imports the warnings module in get_exec_path() function because os is a core module and it should not import too much modules. But... I'm not sure that it's the right way to fix this issue.