New submission from Eryk Sun: 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". ---------- components: Library (Lib), Windows keywords: easy messages: 266057 nosy: brett.cannon, eryksun, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal stage: needs patch status: open title: PYTHONCASEOK is ignored on Windows type: behavior versions: Python 3.5, Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27083> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com