[issue37473] importlib: Remove libregrtest hack: "We import importlib *ASAP* in order to test #15386"

2019-07-14 Thread STINNER Victor


STINNER Victor  added the comment:

I merged your PR. If someone considers than test_there_can_be_only_one() is not 
enough, please add a new test.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37473] importlib: Remove libregrtest hack: "We import importlib *ASAP* in order to test #15386"

2019-07-14 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 8b7db5a1114e2113a756bdf8877fbe366055c69a by Victor Stinner in 
branch 'master':
bpo-37473: Don't import importlib ASAP in tests (GH-14661)
https://github.com/python/cpython/commit/8b7db5a1114e2113a756bdf8877fbe366055c69a


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37473] importlib: Remove libregrtest hack: "We import importlib *ASAP* in order to test #15386"

2019-07-09 Thread STINNER Victor


Change by STINNER Victor :


--
keywords: +patch
pull_requests: +14468
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/14661

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37473] importlib: Remove libregrtest hack: "We import importlib *ASAP* in order to test #15386"

2019-07-01 Thread STINNER Victor


New submission from STINNER Victor :

Lib/test/regrtest.py starts with:

# We import importlib *ASAP* in order to test #15386
import importlib

If there is a bug to test, would it be possible to write a dedicated test, 
rather than putting the test... in the code of the test runner?

Code added by bpo-15386:

commit be7e49fd820318509cd8b4dbde479c552f74ef62
Author: Nick Coghlan 
Date:   Fri Jul 20 23:40:09 2012 +1000

Close #15386: There was a loophole that meant importlib.machinery and imp 
would sometimes reference an uninitialised copy of importlib._bootstrap

(...)

diff --git a/Lib/runpy.py b/Lib/runpy.py
index d612727c6f..39c0e9f7dd 100644
--- a/Lib/runpy.py
+++ b/Lib/runpy.py
@@ -12,8 +12,8 @@ importers when locating support scripts as well as when 
importing modules.
 
 import os
 import sys
+import importlib.machinery # importlib first so we can test #15386 via -m
 import imp
-import importlib.machinery
 from pkgutil import read_code, get_loader, get_importer
 
 __all__ = [
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index 28655f0e65..3c8359aca1 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -165,6 +165,9 @@ example, to run all the tests except for the gui tests, 
give the
 option '-uall,-gui'.
 """
 
+# We import importlib *ASAP* in order to test #15386
+import importlib
+
 import builtins
 import faulthandler
 import getopt
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py
index 89ec8dcedc..51b52c7e0b 100644
--- a/Lib/test/test_import.py
+++ b/Lib/test/test_import.py
@@ -1,8 +1,9 @@
+# We import importlib *ASAP* in order to test #15386
+import importlib
 import builtins
 import imp
 from importlib.test.import_ import test_suite as importlib_import_test_suite
 from importlib.test.import_ import util as importlib_util
-import importlib
 import marshal
 import os
 import platform

--
components: Tests
messages: 347032
nosy: brett.cannon, ncoghlan, vstinner
priority: normal
severity: normal
status: open
title: importlib: Remove libregrtest hack: "We import importlib *ASAP* in order 
to test #15386"
versions: Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com