cpython: ee9662d77ebb (original) (raw)

--- a/Doc/c-api/exceptions.rst +++ b/Doc/c-api/exceptions.rst @@ -686,8 +686,6 @@ the variables: +-----------------------------------------+---------------------------------+----------+ | :c:data:PyExc_ImportError | :exc:ImportError | | +-----------------------------------------+---------------------------------+----------+ -| :c:data:PyExc_ModuleNotFoundError | :exc:ModuleNotFoundError | | -+-----------------------------------------+---------------------------------+----------+ | :c:data:PyExc_IndexError | :exc:IndexError | | +-----------------------------------------+---------------------------------+----------+ | :c:data:PyExc_InterruptedError | :exc:InterruptedError | |

--- a/Doc/library/exceptions.rst +++ b/Doc/library/exceptions.rst @@ -169,8 +169,8 @@ The following exceptions are the excepti .. exception:: ImportError

-.. exception:: ModuleNotFoundError -

.. exception:: IndexError

--- a/Doc/whatsnew/3.4.rst +++ b/Doc/whatsnew/3.4.rst @@ -137,9 +137,6 @@ Some smaller changes made to the core Py

--- a/Include/pyerrors.h +++ b/Include/pyerrors.h @@ -152,7 +152,6 @@ PyAPI_DATA(PyObject *) PyExc_EOFError; PyAPI_DATA(PyObject *) PyExc_FloatingPointError; PyAPI_DATA(PyObject *) PyExc_OSError; PyAPI_DATA(PyObject *) PyExc_ImportError; -PyAPI_DATA(PyObject *) PyExc_ModuleNotFoundError; PyAPI_DATA(PyObject *) PyExc_IndexError; PyAPI_DATA(PyObject *) PyExc_KeyError; PyAPI_DATA(PyObject *) PyExc_KeyboardInterrupt;

--- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -1556,7 +1556,11 @@ def _find_and_load_unlocked(name, import raise ImportError(msg, name=name) loader = _find_module(name, path) if loader is None:

@@ -1642,12 +1646,15 @@ def _handle_fromlist(module, fromlist, i from_name = '{}.{}'.format(module.name, x) try: call_with_frames_removed(import, from_name)

--- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -316,7 +316,7 @@ def safeimport(path, forceload=0, cache= elif exc is SyntaxError: # A SyntaxError occurred before we could execute the module. raise ErrorDuringImport(value.filename, info)

--- a/Lib/test/exception_hierarchy.txt +++ b/Lib/test/exception_hierarchy.txt @@ -13,7 +13,6 @@ BaseException +-- BufferError +-- EOFError +-- ImportError

--- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -953,5 +953,8 @@ class ImportErrorTests(unittest.TestCase self.assertEqual(str(arg), str(exc)) +def test_main():

+ if name == 'main': unittest.main()

--- a/Lib/test/test_import.py +++ b/Lib/test/test_import.py @@ -68,15 +68,7 @@ class ImportTests(unittest.TestCase): def tearDown(self): unload(TESTFN)

-

def test_case_sensitivity(self): # Brief digression to test that import is case-sensitive: if we got @@ -495,7 +487,7 @@ func_filename = func.code.co_filenam header = f.read(12) code = marshal.load(f) constants = list(code.co_consts)

@@ -1021,5 +1013,16 @@ class ImportTracebackTests(unittest.Test importlib.SourceLoader.load_module = old_load_module +def test_main(verbose=None):

+ + if name == 'main':

--- a/Lib/test/test_importlib/import_/test_api.py +++ b/Lib/test/test_importlib/import_/test_api.py @@ -22,10 +22,6 @@ class APITest(unittest.TestCase): """Test API-specific details for import (e.g. raising the right exception when passing in an int for the module name)."""

- def test_name_requires_rparition(self): # Raise TypeError if a non-string is passed in for the module name. with self.assertRaises(TypeError):

--- a/Lib/test/test_importlib/import_/test_fromlist.py +++ b/Lib/test/test_importlib/import_/test_fromlist.py @@ -68,16 +68,16 @@ class HandlingFromlist(unittest.TestCase self.assertTrue(hasattr(module, 'module')) self.assertEqual(module.module.name, 'pkg.module')

--- a/Lib/test/test_pydoc.py +++ b/Lib/test/test_pydoc.py @@ -206,7 +206,7 @@ expected_html_data_docstrings = tuple(s. missing_pattern = "no Python documentation found for '%s'"

output pattern for module with bad imports

-badimport_pattern = "problem in %s - ModuleNotFoundError: No module named %r" +badimport_pattern = "problem in %s - ImportError: No module named %r" def run_pydoc(module_name, *args, **env): """

--- a/Lib/test/test_site.py +++ b/Lib/test/test_site.py @@ -131,7 +131,7 @@ class HelperFunctionsTests(unittest.Test re.escape(os.path.join(pth_dir, pth_fn))) # XXX: ditto previous XXX comment. self.assertRegex(err_out.getvalue(), 'Traceback')

@unittest.skipIf(sys.platform == "win32", "Windows does not raise an " "error for file paths containing null characters")

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -25,9 +25,6 @@ Core and Builtins

--- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -710,13 +710,6 @@ ComplexExtendsException(PyExc_Exception, "module."); /*

- -/*

*/ @@ -2402,7 +2395,6 @@ void PRE_INIT(SystemExit) PRE_INIT(KeyboardInterrupt) PRE_INIT(ImportError)

--- a/Python/ceval.c +++ b/Python/ceval.c @@ -4588,7 +4588,7 @@ import_from(PyObject *v, PyObject *name) x = PyObject_GetAttr(v, name); if (x == NULL && PyErr_ExceptionMatches(PyExc_AttributeError)) {

--- a/Python/importlib.h +++ b/Python/importlib.h @@ -3182,8 +3182,8 @@ const unsigned char _Py_M__importlib[] = 1,30,1,12,1,15,1,6,1,15,1,15,1,15,1,6, 2,27,1,19,1,114,63,1,0,0,117,20,0,0,0,78, 111,32,109,111,100,117,108,101,32,110,97,109,101,100,32,123,

};