| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 603dcf2 commit c9a1bfe
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -146,11 +146,11 @@ | |||
| 146 | 146 | ||
| 147 | 147 | try: | |
| 148 | 148 | import threading | |
| 149 | - except ImportError: | ||
| 149 | + except ModuleNotFoundError: | ||
| 150 | 150 | threading = None | |
| 151 | 151 | try: | |
| 152 | 152 | import multiprocessing.process | |
| 153 | - except ImportError: | ||
| 153 | + except ModuleNotFoundError: | ||
| 154 | 154 | multiprocessing = None | |
| 155 | 155 | ||
| 156 | 156 | ||
@@ -180,7 +180,7 @@ | |||
| 180 | 180 | if sys.platform == 'darwin': | |
| 181 | 181 | try: | |
| 182 | 182 | import resource | |
| 183 | - except ImportError: | ||
| 183 | + except ModuleNotFoundError: | ||
| 184 | 184 | pass | |
| 185 | 185 | else: | |
| 186 | 186 | soft, hard = resource.getrlimit(resource.RLIMIT_STACK) | |
@@ -571,7 +571,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, | |||
| 571 | 571 | if findleaks: | |
| 572 | 572 | try: | |
| 573 | 573 | import gc | |
| 574 | - except ImportError: | ||
| 574 | + except ModuleNotFoundError: | ||
| 575 | 575 | print('No GC available, disabling findleaks.') | |
| 576 | 576 | findleaks = False | |
| 577 | 577 | else: | |
@@ -692,7 +692,7 @@ def test_forever(tests=list(selected)): | |||
| 692 | 692 | if use_mp: | |
| 693 | 693 | try: | |
| 694 | 694 | from threading import Thread | |
| 695 | - except ImportError: | ||
| 695 | + except ModuleNotFoundError: | ||
| 696 | 696 | print("Multiprocess option requires thread support") | |
| 697 | 697 | sys.exit(2) | |
| 698 | 698 | from queue import Queue | |
@@ -1396,7 +1396,7 @@ def dash_R(the_module, test, indirect_test, huntrleaks): | |||
| 1396 | 1396 | pic = sys.path_importer_cache.copy() | |
| 1397 | 1397 | try: | |
| 1398 | 1398 | import zipimport | |
| 1399 | - except ImportError: | ||
| 1399 | + except ModuleNotFoundError: | ||
| 1400 | 1400 | zdc = None # Run unmodified on platforms without zipimport support | |
| 1401 | 1401 | else: | |
| 1402 | 1402 | zdc = zipimport._zip_directory_cache.copy() | |
@@ -1473,7 +1473,7 @@ def dash_R_cleanup(fs, ps, pic, zdc, abcs): | |||
| 1473 | 1473 | sys.path_importer_cache.update(pic) | |
| 1474 | 1474 | try: | |
| 1475 | 1475 | import zipimport | |
| 1476 | - except ImportError: | ||
| 1476 | + except ModuleNotFoundError: | ||
| 1477 | 1477 | pass # Run unmodified on platforms without zipimport support | |
| 1478 | 1478 | else: | |
| 1479 | 1479 | zipimport._zip_directory_cache.clear() | |
@@ -1510,7 +1510,7 @@ def dash_R_cleanup(fs, ps, pic, zdc, abcs): | |||
| 1510 | 1510 | doctest.master = None | |
| 1511 | 1511 | try: | |
| 1512 | 1512 | import ctypes | |
| 1513 | - except ImportError: | ||
| 1513 | + except ModuleNotFoundError: | ||
| 1514 | 1514 | # Don't worry about resetting the cache if ctypes is not supported | |
| 1515 | 1515 | pass | |
| 1516 | 1516 | else: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,27 +29,27 @@ | |||
| 29 | 29 | ||
| 30 | 30 | try: | |
| 31 | 31 | import _thread, threading | |
| 32 | - except ImportError: | ||
| 32 | + except ModuleNotFoundError: | ||
| 33 | 33 | _thread = None | |
| 34 | 34 | threading = None | |
| 35 | 35 | try: | |
| 36 | 36 | import multiprocessing.process | |
| 37 | - except ImportError: | ||
| 37 | + except ModuleNotFoundError: | ||
| 38 | 38 | multiprocessing = None | |
| 39 | 39 | ||
| 40 | 40 | try: | |
| 41 | 41 | import zlib | |
| 42 | - except ImportError: | ||
| 42 | + except ModuleNotFoundError: | ||
| 43 | 43 | zlib = None | |
| 44 | 44 | ||
| 45 | 45 | try: | |
| 46 | 46 | import bz2 | |
| 47 | - except ImportError: | ||
| 47 | + except ModuleNotFoundError: | ||
| 48 | 48 | bz2 = None | |
| 49 | 49 | ||
| 50 | 50 | try: | |
| 51 | 51 | import lzma | |
| 52 | - except ImportError: | ||
| 52 | + except ModuleNotFoundError: | ||
| 53 | 53 | lzma = None | |
| 54 | 54 | ||
| 55 | 55 | __all__ = [ | |
@@ -116,7 +116,7 @@ def import_module(name, deprecated=False, *, required_on=()): | |||
| 116 | 116 | with _ignore_deprecated_imports(deprecated): | |
| 117 | 117 | try: | |
| 118 | 118 | return importlib.import_module(name) | |
| 119 | - except ImportError as msg: | ||
| 119 | + except ModuleNotFoundError as msg: | ||
| 120 | 120 | if sys.platform.startswith(tuple(required_on)): | |
| 121 | 121 | raise | |
| 122 | 122 | raise unittest.SkipTest(str(msg)) | |
@@ -188,7 +188,7 @@ def import_fresh_module(name, fresh=(), blocked=(), deprecated=False): | |||
| 188 | 188 | if not _save_and_block_module(blocked_name, orig_modules): | |
| 189 | 189 | names_to_remove.append(blocked_name) | |
| 190 | 190 | fresh_module = importlib.import_module(name) | |
| 191 | - except ImportError: | ||
| 191 | + except ModuleNotFoundError: | ||
| 192 | 192 | fresh_module = None | |
| 193 | 193 | finally: | |
| 194 | 194 | for orig_name, module in orig_modules.items(): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -75,7 +75,7 @@ def test_all(self): | |||
| 75 | 75 | try: | |
| 76 | 76 | import rlcompleter | |
| 77 | 77 | import locale | |
| 78 | - except ImportError: | ||
| 78 | + except ModuleNotFoundError: | ||
| 79 | 79 | pass | |
| 80 | 80 | else: | |
| 81 | 81 | locale.setlocale(locale.LC_CTYPE, 'C') | |
@@ -113,8 +113,5 @@ def test_all(self): | |||
| 113 | 113 | print('Following modules failed to be imported:', failed_imports) | |
| 114 | 114 | ||
| 115 | 115 | ||
| 116 | - def test_main(): | ||
| 117 | - support.run_unittest(AllTest) | ||
| 118 | - | ||
| 119 | 116 | if __name__ == "__main__": | |
| 120 | - test_main() | ||
| 117 | + unittest.main() | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -116,7 +116,7 @@ def export_add(self, x, y): | |||
| 116 | 116 | import traceback | |
| 117 | 117 | try: | |
| 118 | 118 | import fcntl | |
| 119 | - except ImportError: | ||
| 119 | + except ModuleNotFoundError: | ||
| 120 | 120 | fcntl = None | |
| 121 | 121 | ||
| 122 | 122 | def resolve_dotted_attribute(obj, attr, allow_dotted_names=True): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,18 +18,18 @@ | |||
| 18 | 18 | try: | |
| 19 | 19 | import zlib # We may need its compression method | |
| 20 | 20 | crc32 = zlib.crc32 | |
| 21 | - except ImportError: | ||
| 21 | + except ModuleNotFoundError: | ||
| 22 | 22 | zlib = None | |
| 23 | 23 | crc32 = binascii.crc32 | |
| 24 | 24 | ||
| 25 | 25 | try: | |
| 26 | 26 | import bz2 # We may need its compression method | |
| 27 | - except ImportError: | ||
| 27 | + except ModuleNotFoundError: | ||
| 28 | 28 | bz2 = None | |
| 29 | 29 | ||
| 30 | 30 | try: | |
| 31 | 31 | import lzma # We may need its compression method | |
| 32 | - except ImportError: | ||
| 32 | + except ModuleNotFoundError: | ||
| 33 | 33 | lzma = None | |
| 34 | 34 | ||
| 35 | 35 | __all__ = ["BadZipFile", "BadZipfile", "error", | |
| Back | FazBrowse Home | New Git URL |
0 commit comments