Skip to content

bpo-38691: Ignore pythoncaseok tests #18627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1835,6 +1835,9 @@ are always available. They are listed here in alphabetical order.
Negative values for *level* are no longer supported (which also changes
the default value to 0).

.. versionchanged:: 3.9
When the command line options :option:`-E` or :option:`-I` are being used,
the environment variable :envvar:`PYTHONCASEOK` is now ignored.

.. rubric:: Footnotes

Expand Down
3 changes: 3 additions & 0 deletions Doc/whatsnew/3.9.rst
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,9 @@ Changes in the Python API
since the *buffering* parameter has been removed.
(Contributed by Victor Stinner in :issue:`39357`.)

* The :mod:`importlib` module now ignores the :envvar:`PYTHONCASEOK`
environment variable when the :option:`-E` or :option:`-I` command line
options are being used.

CPython bytecode changes
------------------------
Expand Down
4 changes: 2 additions & 2 deletions Lib/importlib/_bootstrap_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def _make_relax_case():
key = b'PYTHONCASEOK'

def _relax_case():
"""True if filenames must be checked case-insensitively."""
return key in _os.environ
"""True if filenames must be checked case-insensitively and ignore environment flags are not set."""
return not sys.flags.ignore_environment and key in _os.environ
else:
def _relax_case():
"""True if filenames must be checked case-insensitively."""
Expand Down
4 changes: 3 additions & 1 deletion Lib/test/test_importlib/extension/test_case_sensitivity.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from importlib import _bootstrap_external
from test import support
import unittest

import sys
from .. import util

importlib = util.import_importlib('importlib')
Expand All @@ -21,13 +21,15 @@ def find_module(self):
self.machinery.EXTENSION_SUFFIXES))
return finder.find_module(bad_name)

@unittest.skipIf(sys.flags.ignore_environment, 'ignore_environment flag was set')
def test_case_sensitive(self):
with support.EnvironmentVarGuard() as env:
env.unset('PYTHONCASEOK')
self.caseok_env_changed(should_exist=False)
loader = self.find_module()
self.assertIsNone(loader)

@unittest.skipIf(sys.flags.ignore_environment, 'ignore_environment flag was set')
def test_case_insensitivity(self):
with support.EnvironmentVarGuard() as env:
env.set('PYTHONCASEOK', '1')
Expand Down
4 changes: 4 additions & 0 deletions Lib/test/test_importlib/source/test_case_sensitivity.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Test case-sensitivity (PEP 235)."""
import sys

from .. import util

importlib = util.import_importlib('importlib')
Expand Down Expand Up @@ -38,6 +40,7 @@ def sensitivity_test(self):
insensitive_finder = self.finder(insensitive_path)
return self.find(sensitive_finder), self.find(insensitive_finder)

@unittest.skipIf(sys.flags.ignore_environment, 'ignore_environment flag was set')
def test_sensitive(self):
with test_support.EnvironmentVarGuard() as env:
env.unset('PYTHONCASEOK')
Expand All @@ -47,6 +50,7 @@ def test_sensitive(self):
self.assertIn(self.name, sensitive.get_filename(self.name))
self.assertIsNone(insensitive)

@unittest.skipIf(sys.flags.ignore_environment, 'ignore_environment flag was set')
def test_insensitive(self):
with test_support.EnvironmentVarGuard() as env:
env.set('PYTHONCASEOK', '1')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The :mod:`importlib` module now ignores the :envvar:`PYTHONCASEOK`
environment variable when the :option:`-E` or :option:`-I` command line
options are being used.
5,260 changes: 2,634 additions & 2,626 deletions Python/importlib_external.h

Large diffs are not rendered by default.