mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #16309: Make PYTHONPATH= behavior the same as if PYTHONPATH not set at all.
Thanks to Armin Rigo and Alexey Kachayev.
This commit is contained in:
parent
683b46aa8d
commit
69032c81aa
4 changed files with 22 additions and 3 deletions
|
@ -216,6 +216,23 @@ class CmdLineTest(unittest.TestCase):
|
|||
self.assertIn(path1.encode('ascii'), out)
|
||||
self.assertIn(path2.encode('ascii'), out)
|
||||
|
||||
def test_empty_PYTHONPATH_issue16309(self):
|
||||
"""On Posix, it is documented that setting PATH to the
|
||||
empty string is equivalent to not setting PATH at all,
|
||||
which is an exception to the rule that in a string like
|
||||
"/bin::/usr/bin" the empty string in the middle gets
|
||||
interpreted as '.'"""
|
||||
code = """if 1:
|
||||
import sys
|
||||
path = ":".join(sys.path)
|
||||
path = path.encode("ascii", "backslashreplace")
|
||||
sys.stdout.buffer.write(path)"""
|
||||
rc1, out1, err1 = assert_python_ok('-c', code, PYTHONPATH="")
|
||||
rc2, out2, err2 = assert_python_ok('-c', code)
|
||||
# regarding to Posix specification, outputs should be equal
|
||||
# for empty and unset PYTHONPATH
|
||||
self.assertEquals(out1, out2)
|
||||
|
||||
def test_displayhook_unencodable(self):
|
||||
for encoding in ('ascii', 'latin-1', 'utf-8'):
|
||||
env = os.environ.copy()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue