Author eryksun
Recipients brett.cannon, eryksun, paul.moore, steve.dower, tim.golden, zach.ware
Date 2016-05-22.06:45:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1463899532.05.0.0164205622545.issue27083@psf.upfronthosting.co.za>
In-reply-to
Content
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".
History
Date User Action Args
2016-05-22 06:45:32eryksunsetrecipients: + eryksun, brett.cannon, paul.moore, tim.golden, zach.ware, steve.dower
2016-05-22 06:45:32eryksunsetmessageid: <1463899532.05.0.0164205622545.issue27083@psf.upfronthosting.co.za>
2016-05-22 06:45:31eryksunlinkissue27083 messages
2016-05-22 06:45:31eryksuncreate