This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: os.get_exec_path() should not produce any warning
Type: Stage:
Components: Library (Lib), Unicode Versions: Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: eric.araujo, vstinner
Priority: normal Keywords: patch

Created on 2010-10-27 00:58 by vstinner, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
get_exec_path_byteswarning.patch vstinner, 2010-10-27 00:58
Messages (2)
msg119666 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-10-27 00:58
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.
msg119833 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-10-29 00:39
Fixed by r85902.
History
Date User Action Args
2022-04-11 14:57:07adminsetgithub: 54419
2010-10-29 00:39:24vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg119833
2010-10-27 11:59:38eric.araujosetnosy: + eric.araujo
2010-10-27 00:58:04vstinnercreate