diff -r c6c0faaf65d7 Lib/_dummy_thread.py --- a/Lib/_dummy_thread.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/_dummy_thread.py Wed Jun 12 23:39:53 2013 -0400 @@ -7,7 +7,7 @@ try: import _thread - except ImportError: + except ModuleNotFoundError: import _dummy_thread as _thread """ diff -r c6c0faaf65d7 Lib/_osx_support.py --- a/Lib/_osx_support.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/_osx_support.py Wed Jun 12 23:39:53 2013 -0400 @@ -62,7 +62,7 @@ try: import tempfile fp = tempfile.NamedTemporaryFile() - except ImportError: + except ModuleNotFoundError: fp = open("/tmp/_osx_support.%s"%( os.getpid(),), "w+b") diff -r c6c0faaf65d7 Lib/_pyio.py --- a/Lib/_pyio.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/_pyio.py Wed Jun 12 23:39:53 2013 -0400 @@ -9,7 +9,7 @@ # Import _thread instead of threading to reduce startup cost try: from _thread import allocate_lock as Lock -except ImportError: +except ModuleNotFoundError: from _dummy_thread import allocate_lock as Lock import io @@ -1486,7 +1486,7 @@ if encoding is None: try: import locale - except ImportError: + except ModuleNotFoundError: # Importing locale may fail if Python is being built encoding = "ascii" else: diff -r c6c0faaf65d7 Lib/_strptime.py --- a/Lib/_strptime.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/_strptime.py Wed Jun 12 23:39:53 2013 -0400 @@ -21,7 +21,7 @@ timezone as datetime_timezone) try: from _thread import allocate_lock as _thread_allocate_lock -except ImportError: +except ModuleNotFoundError: from _dummy_thread import allocate_lock as _thread_allocate_lock __all__ = [] diff -r c6c0faaf65d7 Lib/bisect.py --- a/Lib/bisect.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/bisect.py Wed Jun 12 23:39:53 2013 -0400 @@ -88,5 +88,5 @@ # Overwrite above definitions with a fast C implementation try: from _bisect import * -except ImportError: +except ModuleNotFoundError: pass diff -r c6c0faaf65d7 Lib/bz2.py --- a/Lib/bz2.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/bz2.py Wed Jun 12 23:39:53 2013 -0400 @@ -14,7 +14,7 @@ try: from threading import RLock -except ImportError: +except ModuleNotFoundError: from dummy_threading import RLock from _bz2 import BZ2Compressor, BZ2Decompressor diff -r c6c0faaf65d7 Lib/cmd.py --- a/Lib/cmd.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/cmd.py Wed Jun 12 23:39:53 2013 -0400 @@ -109,7 +109,7 @@ self.old_completer = readline.get_completer() readline.set_completer(self.complete) readline.parse_and_bind(self.completekey+": complete") - except ImportError: + except ModuleNotFoundError: pass try: if intro is not None: @@ -143,7 +143,7 @@ try: import readline readline.set_completer(self.old_completer) - except ImportError: + except ModuleNotFoundError: pass diff -r c6c0faaf65d7 Lib/code.py --- a/Lib/code.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/code.py Wed Jun 12 23:39:53 2013 -0400 @@ -293,7 +293,7 @@ else: try: import readline - except ImportError: + except ModuleNotFoundError: pass console.interact(banner) diff -r c6c0faaf65d7 Lib/collections/__init__.py --- a/Lib/collections/__init__.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/collections/__init__.py Wed Jun 12 23:39:53 2013 -0400 @@ -395,7 +395,7 @@ try: # Load C helper function if available from _collections import _count_elements -except ImportError: +except ModuleNotFoundError: pass class Counter(dict): diff -r c6c0faaf65d7 Lib/copy.py --- a/Lib/copy.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/copy.py Wed Jun 12 23:39:53 2013 -0400 @@ -59,7 +59,7 @@ try: from org.python.core import PyStringMap -except ImportError: +except ModuleNotFoundError: PyStringMap = None __all__ = ["Error", "copy", "deepcopy"] diff -r c6c0faaf65d7 Lib/datetime.py --- a/Lib/datetime.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/datetime.py Wed Jun 12 23:39:53 2013 -0400 @@ -2116,7 +2116,7 @@ try: from _datetime import * -except ImportError: +except ModuleNotFoundError: pass else: # Clean up unused names diff -r c6c0faaf65d7 Lib/decimal.py --- a/Lib/decimal.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/decimal.py Wed Jun 12 23:39:53 2013 -0400 @@ -149,7 +149,7 @@ try: from collections import namedtuple as _namedtuple DecimalTuple = _namedtuple('DecimalTuple', 'sign digits exponent') -except ImportError: +except ModuleNotFoundError: DecimalTuple = lambda *args: args # Rounding @@ -430,7 +430,7 @@ try: import threading -except ImportError: +except ModuleNotFoundError: # Python was compiled without threads; create a mock object instead class MockThreading(object): def local(self, sys=sys): @@ -6147,7 +6147,7 @@ # don't care too much if locale isn't present. try: import locale as _locale -except ImportError: +except ModuleNotFoundError: pass def _parse_format_specifier(format_spec, _localeconv=None): @@ -6391,7 +6391,7 @@ try: import _decimal -except ImportError: +except ModuleNotFoundError: pass else: s1 = set(dir()) diff -r c6c0faaf65d7 Lib/distutils/archive_util.py --- a/Lib/distutils/archive_util.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/distutils/archive_util.py Wed Jun 12 23:39:53 2013 -0400 @@ -9,7 +9,7 @@ try: import zipfile -except ImportError: +except ModuleNotFoundError: zipfile = None diff -r c6c0faaf65d7 Lib/distutils/ccompiler.py --- a/Lib/distutils/ccompiler.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/distutils/ccompiler.py Wed Jun 12 23:39:53 2013 -0400 @@ -3,7 +3,7 @@ Contains CCompiler, an abstract base class that defines the interface for the Distutils compiler abstraction model.""" -import sys, os, re +import importlib, sys, os, re from distutils.errors import * from distutils.spawn import spawn from distutils.file_util import move_file @@ -1013,10 +1013,9 @@ try: module_name = "distutils." + module_name - __import__ (module_name) - module = sys.modules[module_name] + module = importlib.import_module(module_name) klass = vars(module)[class_name] - except ImportError: + except ModuleNotFoundError: raise DistutilsModuleError( "can't compile C/C++ code: unable to load module '%s'" % \ module_name) diff -r c6c0faaf65d7 Lib/distutils/dist.py --- a/Lib/distutils/dist.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/distutils/dist.py Wed Jun 12 23:39:53 2013 -0400 @@ -4,11 +4,11 @@ being built/installed/distributed. """ -import sys, os, re +import importlib, sys, os, re try: import warnings -except ImportError: +except ModuleNotFoundError: warnings = None from distutils.errors import * @@ -788,9 +788,8 @@ klass_name = command try: - __import__ (module_name) - module = sys.modules[module_name] - except ImportError: + module = importlib.import_module(module_name) + except ModuleNotFoundError: continue try: diff -r c6c0faaf65d7 Lib/distutils/msvccompiler.py --- a/Lib/distutils/msvccompiler.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/distutils/msvccompiler.py Wed Jun 12 23:39:53 2013 -0400 @@ -28,7 +28,7 @@ RegEnumValue = winreg.EnumValue RegError = winreg.error -except ImportError: +except ModuleNotFoundError: try: import win32api import win32con @@ -39,7 +39,7 @@ RegEnumKey = win32api.RegEnumKey RegEnumValue = win32api.RegEnumValue RegError = win32api.error - except ImportError: + except ModuleNotFoundError: log.info("Warning: Can't read registry to find the " "necessary compiler setting\n" "Make sure that Python modules winreg, " diff -r c6c0faaf65d7 Lib/distutils/util.py --- a/Lib/distutils/util.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/distutils/util.py Wed Jun 12 23:39:53 2013 -0400 @@ -388,7 +388,7 @@ try: from tempfile import mkstemp (script_fd, script_name) = mkstemp(".py") - except ImportError: + except ModuleNotFoundError: from tempfile import mktemp (script_fd, script_name) = None, mktemp(".py") log.info("writing byte-compilation script '%s'", script_name) diff -r c6c0faaf65d7 Lib/encodings/__init__.py --- a/Lib/encodings/__init__.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/encodings/__init__.py Wed Jun 12 23:39:53 2013 -0400 @@ -29,11 +29,11 @@ """#" import codecs +import importlib from . import aliases _cache = {} _unknown = '--unknown--' -_import_tail = ['*'] _aliases = aliases.aliases class CodecRegistryError(LookupError, SystemError): @@ -94,9 +94,8 @@ try: # Import is absolute to prevent the possibly malicious import of a # module with side-effects that is not in the 'encodings' package. - mod = __import__('encodings.' + modname, fromlist=_import_tail, - level=0) - except ImportError: + mod = importlib.import_module('encodings.' + modname) + except ModuleNotFoundError: pass else: break diff -r c6c0faaf65d7 Lib/ftplib.py --- a/Lib/ftplib.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/ftplib.py Wed Jun 12 23:39:53 2013 -0400 @@ -667,7 +667,7 @@ try: import ssl -except ImportError: +except ModuleNotFoundError: _SSLSocket = None else: _SSLSocket = ssl.SSLSocket diff -r c6c0faaf65d7 Lib/functools.py --- a/Lib/functools.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/functools.py Wed Jun 12 23:39:53 2013 -0400 @@ -15,7 +15,7 @@ try: from _functools import reduce -except ImportError: +except ModuleNotFoundError: pass from abc import get_cache_token from collections import namedtuple @@ -143,7 +143,7 @@ try: from _functools import cmp_to_key -except ImportError: +except ModuleNotFoundError: pass @@ -166,7 +166,7 @@ try: from _functools import partial -except ImportError: +except ModuleNotFoundError: pass diff -r c6c0faaf65d7 Lib/getopt.py --- a/Lib/getopt.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/getopt.py Wed Jun 12 23:39:53 2013 -0400 @@ -36,7 +36,7 @@ import os try: from gettext import gettext as _ -except ImportError: +except ModuleNotFoundError: # Bootstrapping Python: gettext's dependencies not built yet def _(s): return s diff -r c6c0faaf65d7 Lib/getpass.py --- a/Lib/getpass.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/getpass.py Wed Jun 12 23:39:53 2013 -0400 @@ -161,10 +161,10 @@ # it's possible there is an incompatible termios from the # McMillan Installer, make sure we have a UNIX-compatible termios termios.tcgetattr, termios.tcsetattr -except (ImportError, AttributeError): +except (ModuleNotFoundError, AttributeError): try: import msvcrt - except ImportError: + except ModuleNotFoundError: getpass = fallback_getpass else: getpass = win_getpass diff -r c6c0faaf65d7 Lib/hashlib.py --- a/Lib/hashlib.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/hashlib.py Wed Jun 12 23:39:53 2013 -0400 @@ -98,7 +98,7 @@ return _sha3.sha3_384 elif bs == '512': return _sha3.sha3_512 - except ImportError: + except ModuleNotFoundError: pass # no extension module, this hash is unsupported. raise ValueError('unsupported hash type ' + name) @@ -143,7 +143,7 @@ __get_hash = __get_openssl_constructor algorithms_available = algorithms_available.union( _hashlib.openssl_md_meth_names) -except ImportError: +except ModuleNotFoundError: new = __py_new __get_hash = __get_builtin_constructor diff -r c6c0faaf65d7 Lib/heapq.py --- a/Lib/heapq.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/heapq.py Wed Jun 12 23:39:53 2013 -0400 @@ -343,7 +343,7 @@ # If available, use C implementation try: from _heapq import * -except ImportError: +except ModuleNotFoundError: pass def merge(*iterables): diff -r c6c0faaf65d7 Lib/http/client.py --- a/Lib/http/client.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/http/client.py Wed Jun 12 23:39:53 2013 -0400 @@ -1156,7 +1156,7 @@ try: import ssl -except ImportError: +except ModuleNotFoundError: pass else: class HTTPSConnection(HTTPConnection): diff -r c6c0faaf65d7 Lib/http/cookiejar.py --- a/Lib/http/cookiejar.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/http/cookiejar.py Wed Jun 12 23:39:53 2013 -0400 @@ -35,7 +35,7 @@ import urllib.parse, urllib.request try: import threading as _threading -except ImportError: +except ModuleNotFoundError: import dummy_threading as _threading import http.client # only for the default HTTP port from calendar import timegm diff -r c6c0faaf65d7 Lib/http/server.py --- a/Lib/http/server.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/http/server.py Wed Jun 12 23:39:53 2013 -0400 @@ -904,7 +904,7 @@ return nobody try: import pwd - except ImportError: + except ModuleNotFoundError: return -1 try: nobody = pwd.getpwnam('nobody')[2] diff -r c6c0faaf65d7 Lib/imaplib.py --- a/Lib/imaplib.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/imaplib.py Wed Jun 12 23:39:53 2013 -0400 @@ -29,7 +29,7 @@ try: import ssl HAVE_SSL = True -except ImportError: +except ModuleNotFoundError: HAVE_SSL = False __all__ = ["IMAP4", "IMAP4_stream", "Internaldate2tuple", diff -r c6c0faaf65d7 Lib/imp.py --- a/Lib/imp.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/imp.py Wed Jun 12 23:39:53 2013 -0400 @@ -12,7 +12,7 @@ _fix_co_filename) try: from _imp import load_dynamic -except ImportError: +except ModuleNotFoundError: # Platform doesn't support dynamic loading. load_dynamic = None diff -r c6c0faaf65d7 Lib/importlib/__init__.py --- a/Lib/importlib/__init__.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/importlib/__init__.py Wed Jun 12 23:39:53 2013 -0400 @@ -14,7 +14,7 @@ try: import _frozen_importlib as _bootstrap -except ImportError: +except ModuleNotFoundError: from . import _bootstrap _bootstrap._setup(sys, _imp) else: diff -r c6c0faaf65d7 Lib/importlib/abc.py --- a/Lib/importlib/abc.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/importlib/abc.py Wed Jun 12 23:39:53 2013 -0400 @@ -3,7 +3,7 @@ from . import machinery try: import _frozen_importlib -except ImportError as exc: +except ModuleNotFoundError as exc: if exc.name != '_frozen_importlib': raise _frozen_importlib = None diff -r c6c0faaf65d7 Lib/inspect.py --- a/Lib/inspect.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/inspect.py Wed Jun 12 23:39:53 2013 -0400 @@ -51,7 +51,7 @@ # back to hardcording so the dependency is optional try: from dis import COMPILER_FLAG_NAMES as _flag_names -except ImportError: +except ModuleNotFoundError: CO_OPTIMIZED, CO_NEWLOCALS = 0x1, 0x2 CO_VARARGS, CO_VARKEYWORDS = 0x4, 0x8 CO_NESTED, CO_GENERATOR, CO_NOFREE = 0x10, 0x20, 0x40 diff -r c6c0faaf65d7 Lib/json/decoder.py --- a/Lib/json/decoder.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/json/decoder.py Wed Jun 12 23:39:53 2013 -0400 @@ -5,7 +5,7 @@ from json import scanner try: from _json import scanstring as c_scanstring -except ImportError: +except ModuleNotFoundError: c_scanstring = None __all__ = ['JSONDecoder'] diff -r c6c0faaf65d7 Lib/json/encoder.py --- a/Lib/json/encoder.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/json/encoder.py Wed Jun 12 23:39:53 2013 -0400 @@ -4,11 +4,11 @@ try: from _json import encode_basestring_ascii as c_encode_basestring_ascii -except ImportError: +except ModuleNotFoundError: c_encode_basestring_ascii = None try: from _json import make_encoder as c_make_encoder -except ImportError: +except ModuleNotFoundError: c_make_encoder = None ESCAPE = re.compile(r'[\x00-\x1f\\"\b\f\n\r\t]') diff -r c6c0faaf65d7 Lib/json/scanner.py --- a/Lib/json/scanner.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/json/scanner.py Wed Jun 12 23:39:53 2013 -0400 @@ -3,7 +3,7 @@ import re try: from _json import make_scanner as c_make_scanner -except ImportError: +except ModuleNotFoundError: c_make_scanner = None __all__ = ['make_scanner'] diff -r c6c0faaf65d7 Lib/lib2to3/refactor.py --- a/Lib/lib2to3/refactor.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/lib2to3/refactor.py Wed Jun 12 23:39:53 2013 -0400 @@ -706,7 +706,7 @@ items, write, doctests_only) try: import multiprocessing - except ImportError: + except ModuleNotFoundError: raise MultiprocessingUnsupported if self.queue is not None: raise RuntimeError("already doing multiple processes") diff -r c6c0faaf65d7 Lib/locale.py --- a/Lib/locale.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/locale.py Wed Jun 12 23:39:53 2013 -0400 @@ -47,7 +47,7 @@ from _locale import * -except ImportError: +except ModuleNotFoundError: # Locale emulation diff -r c6c0faaf65d7 Lib/logging/__init__.py --- a/Lib/logging/__init__.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/logging/__init__.py Wed Jun 12 23:39:53 2013 -0400 @@ -37,7 +37,7 @@ try: import threading -except ImportError: #pragma: no cover +except ModuleNotFoundError: #pragma: no cover threading = None __author__ = "Vinay Sajip " diff -r c6c0faaf65d7 Lib/logging/config.py --- a/Lib/logging/config.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/logging/config.py Wed Jun 12 23:39:53 2013 -0400 @@ -30,7 +30,7 @@ try: import _thread as thread import threading -except ImportError: #pragma: no cover +except ModuleNotFoundError: #pragma: no cover thread = None from socketserver import ThreadingTCPServer, StreamRequestHandler diff -r c6c0faaf65d7 Lib/logging/handlers.py --- a/Lib/logging/handlers.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/logging/handlers.py Wed Jun 12 23:39:53 2013 -0400 @@ -29,7 +29,7 @@ import queue try: import threading -except ImportError: #pragma: no cover +except ModuleNotFoundError: #pragma: no cover threading = None # @@ -995,7 +995,7 @@ logging.ERROR : win32evtlog.EVENTLOG_ERROR_TYPE, logging.CRITICAL: win32evtlog.EVENTLOG_ERROR_TYPE, } - except ImportError: + except ModuleNotFoundError: print("The Python Win32 extensions for NT (service, event "\ "logging) appear not to be available.") self._welu = None diff -r c6c0faaf65d7 Lib/macpath.py --- a/Lib/macpath.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/macpath.py Wed Jun 12 23:39:53 2013 -0400 @@ -187,7 +187,7 @@ path = abspath(path) try: import Carbon.File - except ImportError: + except ModuleNotFoundError: return path if not path: return path diff -r c6c0faaf65d7 Lib/mailbox.py --- a/Lib/mailbox.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/mailbox.py Wed Jun 12 23:39:53 2013 -0400 @@ -23,7 +23,7 @@ import contextlib try: import fcntl -except ImportError: +except ModuleNotFoundError: fcntl = None __all__ = [ 'Mailbox', 'Maildir', 'mbox', 'MH', 'Babyl', 'MMDF', diff -r c6c0faaf65d7 Lib/mimetypes.py --- a/Lib/mimetypes.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/mimetypes.py Wed Jun 12 23:39:53 2013 -0400 @@ -29,7 +29,7 @@ import urllib.parse try: import winreg as _winreg -except ImportError: +except ModuleNotFoundError: _winreg = None __all__ = [ diff -r c6c0faaf65d7 Lib/multiprocessing/connection.py --- a/Lib/multiprocessing/connection.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/multiprocessing/connection.py Wed Jun 12 23:39:53 2013 -0400 @@ -27,7 +27,7 @@ try: import _winapi from _winapi import WAIT_OBJECT_0, WAIT_TIMEOUT, INFINITE -except ImportError: +except ModuleNotFoundError: if sys.platform == 'win32': raise _winapi = None diff -r c6c0faaf65d7 Lib/multiprocessing/forking.py --- a/Lib/multiprocessing/forking.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/multiprocessing/forking.py Wed Jun 12 23:39:53 2013 -0400 @@ -73,7 +73,7 @@ try: from functools import partial -except ImportError: +except ModuleNotFoundError: pass else: def _reduce_partial(p): diff -r c6c0faaf65d7 Lib/nntplib.py --- a/Lib/nntplib.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/nntplib.py Wed Jun 12 23:39:53 2013 -0400 @@ -71,7 +71,7 @@ try: import ssl -except ImportError: +except ModuleNotFoundError: _have_ssl = False else: _have_ssl = True diff -r c6c0faaf65d7 Lib/ntpath.py --- a/Lib/ntpath.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/ntpath.py Wed Jun 12 23:39:53 2013 -0400 @@ -566,7 +566,7 @@ try: from nt import _getfullpathname -except ImportError: # not running on Windows - mock up something sensible +except ModuleNotFoundError: # not running on Windows - mock up something sensible def abspath(path): """Return the absolute version of a path.""" if not isabs(path): @@ -659,6 +659,6 @@ # This is overkill on Windows - just pass the path to GetFileAttributes # and check the attribute from there. from nt import _isdir as isdir -except ImportError: +except ModuleNotFoundError: # Use genericpath.isdir as imported above. pass diff -r c6c0faaf65d7 Lib/operator.py --- a/Lib/operator.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/operator.py Wed Jun 12 23:39:53 2013 -0400 @@ -360,7 +360,7 @@ try: from _operator import * -except ImportError: +except ModuleNotFoundError: pass else: from _operator import __doc__ diff -r c6c0faaf65d7 Lib/optparse.py --- a/Lib/optparse.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/optparse.py Wed Jun 12 23:39:53 2013 -0400 @@ -87,7 +87,7 @@ try: from gettext import gettext, ngettext -except ImportError: +except ModuleNotFoundError: def gettext(message): return message diff -r c6c0faaf65d7 Lib/os.py --- a/Lib/os.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/os.py Wed Jun 12 23:39:53 2013 -0400 @@ -52,13 +52,13 @@ try: from posix import _exit __all__.append('_exit') - except ImportError: + except ModuleNotFoundError: pass import posixpath as path try: from posix import _have_functions - except ImportError: + except ModuleNotFoundError: pass elif 'nt' in _names: @@ -68,7 +68,7 @@ try: from nt import _exit __all__.append('_exit') - except ImportError: + except ModuleNotFoundError: pass import ntpath as path @@ -78,7 +78,7 @@ try: from nt import _have_functions - except ImportError: + except ModuleNotFoundError: pass elif 'ce' in _names: @@ -88,7 +88,7 @@ try: from ce import _exit __all__.append('_exit') - except ImportError: + except ModuleNotFoundError: pass # We can use the standard Windows path. import ntpath as path @@ -99,11 +99,11 @@ try: from ce import _have_functions - except ImportError: + except ModuleNotFoundError: pass else: - raise ImportError('no os specific module found') + raise ModuleNotFoundError('no os specific module found') sys.modules['os.path'] = path from os.path import (curdir, pardir, sep, pathsep, defpath, extsep, altsep, diff -r c6c0faaf65d7 Lib/pdb.py --- a/Lib/pdb.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/pdb.py Wed Jun 12 23:39:53 2013 -0400 @@ -158,7 +158,7 @@ import readline # remove some common file name delimiters readline.set_completer_delims(' \t\n`@#$%^&*()=+[{]}\\|;:\'",?') - except ImportError: + except ModuleNotFoundError: pass self.allow_kbdint = False self.nosigint = nosigint diff -r c6c0faaf65d7 Lib/pickle.py --- a/Lib/pickle.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/pickle.py Wed Jun 12 23:39:53 2013 -0400 @@ -90,7 +90,7 @@ # Jython has PyStringMap; it's a dict subclass with string keys try: from org.python.core import PyStringMap -except ImportError: +except ModuleNotFoundError: PyStringMap = None # Pickle opcodes. See pickletools.py for extensive docs. The listing @@ -1296,7 +1296,7 @@ # Use the faster _pickle if possible try: from _pickle import * -except ImportError: +except ModuleNotFoundError: Pickler, Unpickler = _Pickler, _Unpickler # Doctest diff -r c6c0faaf65d7 Lib/platform.py --- a/Lib/platform.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/platform.py Wed Jun 12 23:39:53 2013 -0400 @@ -460,7 +460,7 @@ try: # Use win32api if available from win32api import RegQueryValueEx - except ImportError: + except ModuleNotFoundError: # On Python 2.0 and later, emulate using winreg import winreg RegQueryValueEx = winreg.QueryValueEx @@ -503,7 +503,7 @@ RegCloseKey, GetVersionEx from win32con import HKEY_LOCAL_MACHINE, VER_PLATFORM_WIN32_NT, \ VER_PLATFORM_WIN32_WINDOWS, VER_NT_WORKSTATION - except ImportError: + except ModuleNotFoundError: # Emulate the win32api module using Python APIs try: sys.getwindowsversion @@ -661,7 +661,7 @@ # Check whether the version info module is available try: import _gestalt - except ImportError: + except ModuleNotFoundError: return None # Get the infos sysv, sysa = _mac_ver_lookup(('sysv','sysa')) @@ -697,7 +697,7 @@ try: import plistlib - except ImportError: + except ModuleNotFoundError: return None pl = plistlib.readPlist(fn) @@ -762,7 +762,7 @@ # Import the needed APIs try: import java.lang - except ImportError: + except ModuleNotFoundError: return release,vendor,vminfo,osinfo vendor = _java_getprop('java.vendor', vendor) @@ -874,7 +874,7 @@ """ try: import socket - except ImportError: + except ModuleNotFoundError: # No sockets... return default try: @@ -1138,7 +1138,7 @@ # Get processor information try: import vms_lib - except ImportError: + except ModuleNotFoundError: pass else: csid, cpu_number = vms_lib.getsyi('SYI$_CPU',0) diff -r c6c0faaf65d7 Lib/poplib.py --- a/Lib/poplib.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/poplib.py Wed Jun 12 23:39:53 2013 -0400 @@ -20,7 +20,7 @@ try: import ssl HAVE_SSL = True -except ImportError: +except ModuleNotFoundError: HAVE_SSL = False __all__ = ["POP3","error_proto"] diff -r c6c0faaf65d7 Lib/pstats.py --- a/Lib/pstats.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/pstats.py Wed Jun 12 23:39:53 2013 -0400 @@ -528,7 +528,7 @@ import cmd try: import readline - except ImportError: + except ModuleNotFoundError: pass class ProfileBrowser(cmd.Cmd): diff -r c6c0faaf65d7 Lib/pty.py --- a/Lib/pty.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/pty.py Wed Jun 12 23:39:53 2013 -0400 @@ -67,7 +67,7 @@ result = os.open(tty_name, os.O_RDWR) try: from fcntl import ioctl, I_PUSH - except ImportError: + except ModuleNotFoundError: return result try: ioctl(result, I_PUSH, "ptem") diff -r c6c0faaf65d7 Lib/pydoc.py --- a/Lib/pydoc.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/pydoc.py Wed Jun 12 23:39:53 2013 -0400 @@ -1893,7 +1893,7 @@ def showtopic(self, topic, more_xrefs=''): try: import pydoc_data.topics - except ImportError: + except ModuleNotFoundError: self.output.write(''' Sorry, topic and keyword documentation is not available because the module "pydoc_data.topics" could not be found. @@ -1933,7 +1933,7 @@ """ try: import pydoc_data.topics - except ImportError: + except ModuleNotFoundError: return(''' Sorry, topic and keyword documentation is not available because the module "pydoc_data.topics" could not be found. diff -r c6c0faaf65d7 Lib/queue.py --- a/Lib/queue.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/queue.py Wed Jun 12 23:39:53 2013 -0400 @@ -2,13 +2,13 @@ try: import threading -except ImportError: +except ModuleNotFoundError: import dummy_threading as threading from collections import deque from heapq import heappush, heappop try: from time import monotonic as time -except ImportError: +except ModuleNotFoundError: from time import time __all__ = ['Empty', 'Full', 'Queue', 'PriorityQueue', 'LifoQueue'] diff -r c6c0faaf65d7 Lib/quopri.py --- a/Lib/quopri.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/quopri.py Wed Jun 12 23:39:53 2013 -0400 @@ -13,7 +13,7 @@ try: from binascii import a2b_qp, b2a_qp -except ImportError: +except ModuleNotFoundError: a2b_qp = None b2a_qp = None diff -r c6c0faaf65d7 Lib/reprlib.py --- a/Lib/reprlib.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/reprlib.py Wed Jun 12 23:39:53 2013 -0400 @@ -6,7 +6,7 @@ from itertools import islice try: from _thread import get_ident -except ImportError: +except ModuleNotFoundError: from _dummy_thread import get_ident def recursive_repr(fillvalue='...'): diff -r c6c0faaf65d7 Lib/rlcompleter.py --- a/Lib/rlcompleter.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/rlcompleter.py Wed Jun 12 23:39:53 2013 -0400 @@ -154,7 +154,7 @@ try: import readline -except ImportError: +except ModuleNotFoundError: pass else: readline.set_completer(Completer().complete) diff -r c6c0faaf65d7 Lib/sched.py --- a/Lib/sched.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/sched.py Wed Jun 12 23:39:53 2013 -0400 @@ -33,11 +33,11 @@ from collections import namedtuple try: import threading -except ImportError: +except ModuleNotFoundError: import dummy_threading as threading try: from time import monotonic as _time -except ImportError: +except ModuleNotFoundError: from time import time as _time __all__ = ["scheduler"] diff -r c6c0faaf65d7 Lib/shutil.py --- a/Lib/shutil.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/shutil.py Wed Jun 12 23:39:53 2013 -0400 @@ -17,17 +17,17 @@ import bz2 del bz2 _BZ2_SUPPORTED = True -except ImportError: +except ModuleNotFoundError: _BZ2_SUPPORTED = False try: from pwd import getpwnam -except ImportError: +except ModuleNotFoundError: getpwnam = None try: from grp import getgrnam -except ImportError: +except ModuleNotFoundError: getgrnam = None __all__ = ["copyfileobj", "copyfile", "copymode", "copystat", "copy", "copy2", @@ -668,7 +668,7 @@ # command. try: import zipfile - except ImportError: + except ModuleNotFoundError: zipfile = None if zipfile is None: @@ -858,7 +858,7 @@ """ try: import zipfile - except ImportError: + except ModuleNotFoundError: raise ReadError('zlib not supported, cannot unpack this archive.') if not zipfile.is_zipfile(filename): diff -r c6c0faaf65d7 Lib/site.py --- a/Lib/site.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/site.py Wed Jun 12 23:39:53 2013 -0400 @@ -469,7 +469,7 @@ try: import readline import rlcompleter - except ImportError: + except ModuleNotFoundError: return # Reading the initialization (config) file may not be enough to set a @@ -570,7 +570,7 @@ """Run custom site specific code, if available.""" try: import sitecustomize - except ImportError: + except ModuleNotFoundError: pass except Exception as err: if os.environ.get("PYTHONVERBOSE"): @@ -586,7 +586,7 @@ """Run custom user specific code, if available.""" try: import usercustomize - except ImportError: + except ModuleNotFoundError: pass except Exception as err: if os.environ.get("PYTHONVERBOSE"): diff -r c6c0faaf65d7 Lib/smtpd.py --- a/Lib/smtpd.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/smtpd.py Wed Jun 12 23:39:53 2013 -0400 @@ -846,7 +846,7 @@ if options.setuid: try: import pwd - except ImportError: + except ModuleNotFoundError: print('Cannot import module "pwd"; try running with -n option.', file=sys.stderr) sys.exit(1) nobody = pwd.getpwnam('nobody')[2] diff -r c6c0faaf65d7 Lib/smtplib.py --- a/Lib/smtplib.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/smtplib.py Wed Jun 12 23:39:53 2013 -0400 @@ -171,7 +171,7 @@ try: import ssl -except ImportError: +except ModuleNotFoundError: _have_ssl = False else: _have_ssl = True diff -r c6c0faaf65d7 Lib/socket.py --- a/Lib/socket.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/socket.py Wed Jun 12 23:39:53 2013 -0400 @@ -51,7 +51,7 @@ try: import errno -except ImportError: +except ModuleNotFoundError: errno = None EBADF = getattr(errno, 'EBADF', 9) EAGAIN = getattr(errno, 'EAGAIN', 11) diff -r c6c0faaf65d7 Lib/socketserver.py --- a/Lib/socketserver.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/socketserver.py Wed Jun 12 23:39:53 2013 -0400 @@ -136,7 +136,7 @@ import errno try: import threading -except ImportError: +except ModuleNotFoundError: import dummy_threading as threading __all__ = ["TCPServer","UDPServer","ForkingUDPServer","ForkingTCPServer", diff -r c6c0faaf65d7 Lib/sqlite3/test/dbapi.py --- a/Lib/sqlite3/test/dbapi.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/sqlite3/test/dbapi.py Wed Jun 12 23:39:53 2013 -0400 @@ -25,7 +25,7 @@ import sqlite3 as sqlite try: import threading -except ImportError: +except ModuleNotFoundError: threading = None from test.support import TESTFN, unlink diff -r c6c0faaf65d7 Lib/sqlite3/test/types.py --- a/Lib/sqlite3/test/types.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/sqlite3/test/types.py Wed Jun 12 23:39:53 2013 -0400 @@ -26,7 +26,7 @@ import sqlite3 as sqlite try: import zlib -except ImportError: +except ModuleNotFoundError: zlib = None diff -r c6c0faaf65d7 Lib/sre_compile.py --- a/Lib/sre_compile.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/sre_compile.py Wed Jun 12 23:39:53 2013 -0400 @@ -295,7 +295,7 @@ def _optimize_unicode(charset, fixup): try: import array - except ImportError: + except ModuleNotFoundError: return charset charmap = [0]*65536 negate = 0 diff -r c6c0faaf65d7 Lib/ssl.py --- a/Lib/ssl.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/ssl.py Wed Jun 12 23:39:53 2013 -0400 @@ -127,14 +127,14 @@ try: from _ssl import PROTOCOL_SSLv2 _SSLv2_IF_EXISTS = PROTOCOL_SSLv2 -except ImportError: +except ModuleNotFoundError: _SSLv2_IF_EXISTS = None else: _PROTOCOL_NAMES[PROTOCOL_SSLv2] = "SSLv2" try: from _ssl import PROTOCOL_TLSv1_1, PROTOCOL_TLSv1_2 -except ImportError: +except ModuleNotFoundError: pass else: _PROTOCOL_NAMES[PROTOCOL_TLSv1_1] = "TLSv1.1" diff -r c6c0faaf65d7 Lib/subprocess.py --- a/Lib/subprocess.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/subprocess.py Wed Jun 12 23:39:53 2013 -0400 @@ -353,7 +353,7 @@ import errno try: from time import monotonic as _time -except ImportError: +except ModuleNotFoundError: from time import time as _time # Exception classes used by this module. diff -r c6c0faaf65d7 Lib/tarfile.py --- a/Lib/tarfile.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/tarfile.py Wed Jun 12 23:39:53 2013 -0400 @@ -50,7 +50,7 @@ try: import grp, pwd -except ImportError: +except ModuleNotFoundError: grp = pwd = None # os.symlink on Windows prior to 6.0 raises NotImplementedError @@ -381,7 +381,7 @@ if comptype == "gz": try: import zlib - except ImportError: + except ModuleNotFoundError: raise CompressionError("zlib module is not available") self.zlib = zlib self.crc = zlib.crc32(b"") @@ -394,7 +394,7 @@ elif comptype == "bz2": try: import bz2 - except ImportError: + except ModuleNotFoundError: raise CompressionError("bz2 module is not available") if mode == "r": self.dbuf = b"" @@ -406,7 +406,7 @@ elif comptype == "xz": try: import lzma - except ImportError: + except ModuleNotFoundError: raise CompressionError("lzma module is not available") if mode == "r": self.dbuf = b"" @@ -1654,7 +1654,7 @@ try: import bz2 - except ImportError: + except ModuleNotFoundError: raise CompressionError("bz2 module is not available") fileobj = bz2.BZ2File(fileobj or name, mode, @@ -1678,7 +1678,7 @@ try: import lzma - except ImportError: + except ModuleNotFoundError: raise CompressionError("lzma module is not available") fileobj = lzma.LZMAFile(fileobj or name, mode, preset=preset) diff -r c6c0faaf65d7 Lib/tempfile.py --- a/Lib/tempfile.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/tempfile.py Wed Jun 12 23:39:53 2013 -0400 @@ -36,7 +36,7 @@ try: import fcntl as _fcntl -except ImportError: +except ModuleNotFoundError: def _set_cloexec(fd): pass else: @@ -53,7 +53,7 @@ try: import _thread -except ImportError: +except ModuleNotFoundError: import _dummy_thread as _thread _allocate_lock = _thread.allocate_lock diff -r c6c0faaf65d7 Lib/threading.py --- a/Lib/threading.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/threading.py Wed Jun 12 23:39:53 2013 -0400 @@ -6,14 +6,14 @@ from time import sleep as _sleep try: from time import monotonic as _time -except ImportError: +except ModuleNotFoundError: from time import time as _time from traceback import format_exc as _format_exc from _weakrefset import WeakSet from itertools import islice as _islice try: from _collections import deque as _deque -except ImportError: +except ModuleNotFoundError: from collections import deque as _deque # Note regarding PEP 8 compliant names @@ -922,7 +922,7 @@ try: from _thread import _local as local -except ImportError: +except ModuleNotFoundError: from _threading_local import local diff -r c6c0faaf65d7 Lib/trace.py --- a/Lib/trace.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/trace.py Wed Jun 12 23:39:53 2013 -0400 @@ -61,12 +61,12 @@ from warnings import warn as _warn try: from time import monotonic as _time -except ImportError: +except ModuleNotFoundError: from time import time as _time try: import threading -except ImportError: +except ModuleNotFoundError: _settrace = sys.settrace def _unsettrace(): diff -r c6c0faaf65d7 Lib/urllib/request.py --- a/Lib/urllib/request.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/urllib/request.py Wed Jun 12 23:39:53 2013 -0400 @@ -110,7 +110,7 @@ # check for SSL try: import ssl -except ImportError: +except ModuleNotFoundError: _have_ssl = False else: _have_ssl = True @@ -2512,7 +2512,7 @@ proxies = {} try: import winreg - except ImportError: + except ModuleNotFoundError: # Std module, so should be around - but you never know! return proxies try: @@ -2560,7 +2560,7 @@ def proxy_bypass_registry(host): try: import winreg - except ImportError: + except ModuleNotFoundError: # Std modules, so should be around - but you never know! return 0 try: diff -r c6c0faaf65d7 Lib/venv/__init__.py --- a/Lib/venv/__init__.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/venv/__init__.py Wed Jun 12 23:39:53 2013 -0400 @@ -35,7 +35,7 @@ import sysconfig try: import threading -except ImportError: +except ModuleNotFoundError: threading = None logger = logging.getLogger(__name__) diff -r c6c0faaf65d7 Lib/warnings.py --- a/Lib/warnings.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/warnings.py Wed Jun 12 23:39:53 2013 -0400 @@ -3,6 +3,7 @@ # Note: function level imports should *not* be used # in this module as it may cause import lock deadlock. # See bug 683658. +import importlib import linecache import sys @@ -144,8 +145,8 @@ module = category[:i] klass = category[i+1:] try: - m = __import__(module, None, None, [klass]) - except ImportError: + m = importlib.import_module(module) + except ModuleNotFoundError: raise _OptionError("invalid module name: %r" % (module,)) try: cat = getattr(m, klass) @@ -362,7 +363,7 @@ defaultaction = _defaultaction onceregistry = _onceregistry _warnings_defaults = True -except ImportError: +except ModuleNotFoundError: filters = [] defaultaction = "default" onceregistry = {} diff -r c6c0faaf65d7 Lib/xml/etree/ElementTree.py --- a/Lib/xml/etree/ElementTree.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/xml/etree/ElementTree.py Wed Jun 12 23:39:53 2013 -0400 @@ -1439,13 +1439,13 @@ def __init__(self, html=0, target=None, encoding=None): try: from xml.parsers import expat - except ImportError: + except ModuleNotFoundError: try: import pyexpat as expat - except ImportError: - raise ImportError( - "No module named expat; use SimpleXMLTreeBuilder instead" - ) + except ModuleNotFoundError: + raise ModuleNotFoundError( + "No module named expat; use SimpleXMLTreeBuilder instead", + name='expat') parser = expat.ParserCreate(encoding, "}") if target is None: target = TreeBuilder() diff -r c6c0faaf65d7 Lib/xml/sax/expatreader.py --- a/Lib/xml/sax/expatreader.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/xml/sax/expatreader.py Wed Jun 12 23:39:53 2013 -0400 @@ -20,7 +20,7 @@ try: from xml.parsers import expat -except ImportError: +except ModuleNotFoundError: raise SAXReaderNotAvailable("expat not supported", None) else: if not hasattr(expat, "ParserCreate"): @@ -30,18 +30,7 @@ AttributesImpl = xmlreader.AttributesImpl AttributesNSImpl = xmlreader.AttributesNSImpl -# If we're using a sufficiently recent version of Python, we can use -# weak references to avoid cycles between the parser and content -# handler, otherwise we'll just have to pretend. -try: - import _weakref -except ImportError: - def _mkproxy(o): - return o -else: - import weakref - _mkproxy = weakref.proxy - del weakref, _weakref +import weakref # --- ExpatLocator @@ -52,7 +41,7 @@ a circular reference between the parser and the content handler. """ def __init__(self, parser): - self._ref = _mkproxy(parser) + self._ref = weakref.proxy(parser) def getColumnNumber(self): parser = self._ref diff -r c6c0faaf65d7 Lib/xmlrpc/client.py --- a/Lib/xmlrpc/client.py Wed Jun 12 23:38:50 2013 -0400 +++ b/Lib/xmlrpc/client.py Wed Jun 12 23:39:53 2013 -0400 @@ -139,7 +139,7 @@ from io import BytesIO try: import gzip -except ImportError: +except ModuleNotFoundError: gzip = None #python can be built without zlib/gzip support # --------------------------------------------------------------------

AltStyle によって変換されたページ (->オリジナル) /