summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authoridomic <michael.ido@gmail.com>2020-03-09 11:57:53 (GMT)
committerGitHub <noreply@github.com>2020-03-09 11:57:53 (GMT)
commitfc72ab6913f2b5337ae7fda711f2de846d38f479 (patch)
tree2978bd3e0b166854e13690f9acc376d442f0df64 /Lib
parente53a3932cb01683b0fa8a7448ca25a2e658c39e6 (diff)
downloadcpython-fc72ab6913f2b5337ae7fda711f2de846d38f479.zip
cpython-fc72ab6913f2b5337ae7fda711f2de846d38f479.tar.gz
cpython-fc72ab6913f2b5337ae7fda711f2de846d38f479.tar.bz2
bpo-38691: importlib ignores PYTHONCASEOK if -E is used (GH-18627)
The importlib module now ignores the PYTHONCASEOK environment variable when the -E or -I command line options are being used.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/importlib/_bootstrap_external.py4
-rw-r--r--Lib/test/test_importlib/extension/test_case_sensitivity.py4
-rw-r--r--Lib/test/test_importlib/source/test_case_sensitivity.py4
3 files changed, 9 insertions, 3 deletions
diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py
index 2434cf0..7353bf9 100644
--- a/Lib/importlib/_bootstrap_external.py
+++ b/Lib/importlib/_bootstrap_external.py
@@ -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."""
diff --git a/Lib/test/test_importlib/extension/test_case_sensitivity.py b/Lib/test/test_importlib/extension/test_case_sensitivity.py
index 0dd9c86..3a85784 100644
--- a/Lib/test/test_importlib/extension/test_case_sensitivity.py
+++ b/Lib/test/test_importlib/extension/test_case_sensitivity.py
@@ -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')
@@ -21,6 +21,7 @@ class ExtensionModuleCaseSensitivityTest(util.CASEOKTestBase):
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')
@@ -28,6 +29,7 @@ class ExtensionModuleCaseSensitivityTest(util.CASEOKTestBase):
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')
diff --git a/Lib/test/test_importlib/source/test_case_sensitivity.py b/Lib/test/test_importlib/source/test_case_sensitivity.py
index 12ce0cb..ad1cfdb 100644
--- a/Lib/test/test_importlib/source/test_case_sensitivity.py
+++ b/Lib/test/test_importlib/source/test_case_sensitivity.py
@@ -1,4 +1,6 @@
"""Test case-sensitivity (PEP 235)."""
+import sys
+
from .. import util
importlib = util.import_importlib('importlib')
@@ -38,6 +40,7 @@ class CaseSensitivityTest(util.CASEOKTestBase):
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')
@@ -47,6 +50,7 @@ class CaseSensitivityTest(util.CASEOKTestBase):
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')