This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: importlib: PYTHONCASEOK should be ignored when using python3 -E
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Ido Michael, aeros, brett.cannon, corona10, eric.snow, lukasz.langa, ncoghlan, petdance, vstinner
Priority: normal Keywords: needs review

Created on 2019-11-05 01:55 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 18314 merged Ido Michael, 2020-02-02 14:44
PR 18553 merged vstinner, 2020-02-18 16:41
PR 18612 closed Ido Michael, 2020-02-23 02:07
PR 18627 merged Ido Michael, 2020-02-23 15:18
Messages (18)
msg355996 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-11-05 01:55
When using python3 -E or python3 -I, PYTHONCASEOK environment variable should be ignored by importlib. See an email sent in 2012:
https://mail.python.org/pipermail/python-dev/2012-December/123403.html

See importlib._bootstrap_external._relax_case attribute and its _make_relax_case() function.
msg360608 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-01-24 10:42
sys.flags.ignore_environment should be used.
msg361239 - (view) Author: Ido Michael (Ido Michael) * Date: 2020-02-02 14:45
Created this PR: GH-18314
msg361278 - (view) Author: Dong-hee Na (corona10) * (Python committer) Date: 2020-02-03 10:08
@Ido Michael
I left review comments for you :)
Thanks for the contribution.
msg362122 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-02-17 09:05
New changeset d83b6600b25487e4ebffd7949d0f478de9538875 by idomic in branch 'master':
bpo-38691 Added a switch to ignore PYTHONCASEOK when -E or -I flags passed (#18314)
https://github.com/python/cpython/commit/d83b6600b25487e4ebffd7949d0f478de9538875
msg362202 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-02-18 13:00
Tests fail on macOS:
https://buildbot.python.org/all/#/builders/275/builds/249

I reopen the issue. The issue should be fixed soon, or the change will be reverted to repair buildobts:
https://pythondev.readthedocs.io/ci.html#revert-on-fail

======================================================================
FAIL: test_case_insensitivity (test.test_importlib.extension.test_case_sensitivity.Frozen_ExtensionModuleCaseSensitivityTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/buildbot/buildarea/3.x.billenstein-macos/build/Lib/test/test_importlib/extension/test_case_sensitivity.py", line 36, in test_case_insensitivity
    self.assertTrue(hasattr(loader, 'load_module'))
AssertionError: False is not true

======================================================================
FAIL: test_case_insensitivity (test.test_importlib.extension.test_case_sensitivity.Source_ExtensionModuleCaseSensitivityTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/buildbot/buildarea/3.x.billenstein-macos/build/Lib/test/test_importlib/extension/test_case_sensitivity.py", line 36, in test_case_insensitivity
    self.assertTrue(hasattr(loader, 'load_module'))
AssertionError: False is not true

======================================================================
FAIL: test_insensitive (test.test_importlib.source.test_case_sensitivity.Frozen_CaseSensitivityTestPEP302)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/buildbot/buildarea/3.x.billenstein-macos/build/Lib/test/test_importlib/source/test_case_sensitivity.py", line 57, in test_insensitive
    self.assertIsNotNone(insensitive)
AssertionError: unexpectedly None

======================================================================
FAIL: test_insensitive (test.test_importlib.source.test_case_sensitivity.Frozen_CaseSensitivityTestPEP451)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/buildbot/buildarea/3.x.billenstein-macos/build/Lib/test/test_importlib/source/test_case_sensitivity.py", line 57, in test_insensitive
    self.assertIsNotNone(insensitive)
AssertionError: unexpectedly None

======================================================================
FAIL: test_insensitive (test.test_importlib.source.test_case_sensitivity.Source_CaseSensitivityTestPEP302)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/buildbot/buildarea/3.x.billenstein-macos/build/Lib/test/test_importlib/source/test_case_sensitivity.py", line 57, in test_insensitive
    self.assertIsNotNone(insensitive)
AssertionError: unexpectedly None

======================================================================
FAIL: test_insensitive (test.test_importlib.source.test_case_sensitivity.Source_CaseSensitivityTestPEP451)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/buildbot/buildarea/3.x.billenstein-macos/build/Lib/test/test_importlib/source/test_case_sensitivity.py", line 57, in test_insensitive
    self.assertIsNotNone(insensitive)
AssertionError: unexpectedly None
msg362226 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-02-18 16:42
I'm unable to debug the issue on macOS. I prepared PR 18553 to revert the change, just to give more time to fix the issue. It's to repair the CI, so we can notice other regressions.
msg362227 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-02-18 16:44
> Tests fail on macOS: https://buildbot.python.org/all/#/builders/275/builds/249

Tests are run with "./python.exe  ./Tools/scripts/run_tests.py -j 1 -u all -W --slowest --fail-env-changed --timeout=900 -j2 --junit-xml test-results.xml" which runs tests with "./python.exe -E": ignore PYTHON* environment variables. Maybe the test should just take that in account.
msg362240 - (view) Author: Ido Michael (Ido Michael) * Date: 2020-02-19 00:50
Yes I saw those in the morning, thanks for patching it up. I will debug this over the weekend and will update.
msg362258 - (view) Author: Kyle Stanley (aeros) * (Python committer) Date: 2020-02-19 07:06
From what I can tell, the regression seems like it could be fixed by adding "@unittest.skipIf(sys.flags.ignore_environment)" to the following tests in python/cpython/Lib/test/test_importlib/source/test_case_sensitivity.py that modify "PYTHONCASEOK":

CaseSensitivityTest.test_sensitive
CaseSensitivityTest.test_insensitive

Those tests seem ultimately pointless if environmental variables are being ignored (-E or -I), so I think in this case it's a misleading test failure, no?
msg362269 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-02-19 13:23
New changeset 4dee92b0ad9f4e3ea2fbbbb5253340801bb92dc7 by Victor Stinner in branch 'master':
Revert "bpo-38691 Added a switch to ignore PYTHONCASEOK when -E or -I flags passed (#18314)" (GH-18553)
https://github.com/python/cpython/commit/4dee92b0ad9f4e3ea2fbbbb5253340801bb92dc7
msg362270 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-02-19 13:24
> Yes I saw those in the morning, thanks for patching it up. I will debug this over the weekend and will update.

Ok, perfect. In the meanwhile, as announced, I reverted the change to be able to notify other regressions.

Once we get a fix, we can reapply the change with the fix.
msg362518 - (view) Author: Ido Michael (Ido Michael) * Date: 2020-02-23 15:19
Added a new clean PR with the code changes, will let you know once the tests are fixed: GH-18627
msg363103 - (view) Author: Ido Michael (Ido Michael) * Date: 2020-03-01 22:34
@vstinner ready for review.
msg363720 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-03-09 11:58
New changeset fc72ab6913f2b5337ae7fda711f2de846d38f479 by idomic in branch 'master':
bpo-38691: importlib ignores PYTHONCASEOK if -E is used (GH-18627)
https://github.com/python/cpython/commit/fc72ab6913f2b5337ae7fda711f2de846d38f479
msg364843 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2020-03-23 10:40
Re-opening as it causes refleaks all across the stable buildbots. I can reproduce on macOS Catalina as well. Run this to see for yourself:

- ./python.exe -E -Wd -m test -uall,-gui -l -L -R: test_importlib

Reverting GH-18627 fixes the issue.
msg364844 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2020-03-23 11:42
> Reverting GH-18627 fixes the issue.

Sorry, this is false. I just checked out to the last commit to importlib before GH-18627 and it did not refleak. But when I actually reverted just GH-18627, the issue persisted.

By bisecting, I found out that it's GH-19084 which causes the refleak and it only just so happens that this refleak appears in importlib tests.
msg365007 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-03-25 18:01
FYI importlib leak was fixed in bpo-40050 by:

commit 83d46e0622d2efdf5f3bf8bf8904d0dcb55fc322
Author: Victor Stinner <vstinner@python.org>
Date:   Tue Mar 24 18:03:34 2020 +0100

    bpo-40050: Fix importlib._bootstrap_external (GH-19135)
    
    Remove two unused imports: _thread and _weakref. Avoid creating a new
    winreg builtin module if it's already available in sys.modules.
    
    The winreg module is now stored as "winreg" rather than "_winreg".
History
Date User Action Args
2022-04-11 14:59:22adminsetgithub: 82872
2020-05-15 00:47:33vstinnerlinkissue16826 superseder
2020-03-25 18:01:14vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg365007

stage: commit review -> resolved
2020-03-23 11:42:24lukasz.langasetmessages: + msg364844
2020-03-23 10:40:39lukasz.langasetstage: resolved -> commit review
2020-03-23 10:40:03lukasz.langasetstatus: closed -> open

nosy: + lukasz.langa
messages: + msg364843

keywords: + needs review, - patch
resolution: fixed -> (no value)
2020-03-09 11:58:15vstinnersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-03-09 11:58:00vstinnersetmessages: + msg363720
2020-03-01 22:34:01Ido Michaelsetmessages: + msg363103
2020-02-23 15:19:44Ido Michaelsetmessages: + msg362518
2020-02-23 15:18:42Ido Michaelsetpull_requests: + pull_request17991
2020-02-23 02:07:21Ido Michaelsetpull_requests: + pull_request17977
2020-02-19 20:33:35petdancesetnosy: + petdance
2020-02-19 13:24:51vstinnersetmessages: + msg362270
2020-02-19 13:23:59vstinnersetmessages: + msg362269
2020-02-19 07:06:35aerossetnosy: + aeros
messages: + msg362258
2020-02-19 00:50:24Ido Michaelsetmessages: + msg362240
2020-02-18 16:44:47vstinnersetmessages: + msg362227
2020-02-18 16:42:34vstinnersetkeywords: - newcomer friendly

messages: + msg362226
title: [easy] importlib: PYTHONCASEOK should be ignored when using python3 -E -> importlib: PYTHONCASEOK should be ignored when using python3 -E
2020-02-18 16:41:23vstinnersetstage: resolved -> patch review
pull_requests: + pull_request17934
2020-02-18 13:51:45vstinnerlinkissue39669 superseder
2020-02-18 13:00:01vstinnersetstatus: closed -> open
resolution: fixed -> (no value)
messages: + msg362202
2020-02-17 09:06:53vstinnersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-02-17 09:05:15vstinnersetmessages: + msg362122
2020-02-03 10:08:42corona10setnosy: + corona10
messages: + msg361278
2020-02-02 14:45:47Ido Michaelsetnosy: + Ido Michael
messages: + msg361239
2020-02-02 14:44:12Ido Michaelsetkeywords: + patch
stage: patch review
pull_requests: + pull_request17690
2020-01-24 10:42:07vstinnersetkeywords: + newcomer friendly

messages: + msg360608
title: importlib: PYTHONCASEOK should be ignored when using python3 -E -> [easy] importlib: PYTHONCASEOK should be ignored when using python3 -E
2019-11-05 18:58:02brett.cannonsetnosy: + brett.cannon, ncoghlan, eric.snow
2019-11-05 01:55:56vstinnercreate