Message266057
importlib ignores the PYTHONCASEOK environment variable on Windows. _relax_case checks for b'PYTHONCASEOK' in os.environ, which is never true because os.environ is Unicode. On Windows, _make_relax_case should return a function that instead checks for 'PYTHONCASEOK'.
The following test demonstrates that case-insensitive imports otherwise appear to work correctly in 3.5:
>>> import sys, importlib, glob
>>> glob.glob('*.py')
['Test.py']
>>> importlib._bootstrap_external._relax_case()
False
>>> import test
>>> test.__file__
'C:\\Program Files\\Python35\\lib\\test\\__init__.py'
patched:
>>> src = "_relax_case = lambda: 'PYTHONCASEOK' in _os.environ"
>>> exec(src, vars(importlib._bootstrap_external))
>>> importlib._bootstrap_external._relax_case()
True
>>> del sys.modules['test']
>>> import test
this is a test
>>> test.__file__
'C:\\Temp\\test.py'
It would be better if __file__ were the actual filename "Test.py" instead of "test.py". |
|
Date |
User |
Action |
Args |
2016-05-22 06:45:32 | eryksun | set | recipients:
+ eryksun, brett.cannon, paul.moore, tim.golden, zach.ware, steve.dower |
2016-05-22 06:45:32 | eryksun | set | messageid: <1463899532.05.0.0164205622545.issue27083@psf.upfronthosting.co.za> |
2016-05-22 06:45:31 | eryksun | link | issue27083 messages |
2016-05-22 06:45:31 | eryksun | create | |
|