| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6b4c63d commit 32439d6
27 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -59,19 +59,24 @@ class struct_frozen(Structure): | |||
| 59 | 59 | items = [] | |
| 60 | 60 | # _frozen_importlib changes size whenever importlib._bootstrap | |
| 61 | 61 | # changes, so it gets a special case. We should make sure it's | |
| 62 | - # found, but don't worry about its size too much. | ||
| 63 | - _fzn_implib_seen = False | ||
| 62 | + # found, but don't worry about its size too much. The same | ||
| 63 | + # applies to _frozen_importlib_external. | ||
| 64 | + bootstrap_seen = [] | ||
| 65 | + bootstrap_expected = ( | ||
| 66 | + b'_frozen_importlib', | ||
| 67 | + b'_frozen_importlib_external', | ||
| 68 | + ) | ||
| 64 | 69 | for entry in ft: | |
| 65 | 70 | # This is dangerous. We *can* iterate over a pointer, but | |
| 66 | 71 | # the loop will not terminate (maybe with an access | |
| 67 | 72 | # violation;-) because the pointer instance has no size. | |
| 68 | 73 | if entry.name is None: | |
| 69 | 74 | break | |
| 70 | 75 | ||
| 71 | - if entry.name == b'_frozen_importlib': | ||
| 72 | - _fzn_implib_seen = True | ||
| 76 | + if entry.name in bootstrap_expected: | ||
| 77 | + bootstrap_seen.append(entry.name) | ||
| 73 | 78 | self.assertTrue(entry.size, | |
| 74 | - "_frozen_importlib was reported as having no size") | ||
| 79 | + "{} was reported as having no size".format(entry.name)) | ||
| 75 | 80 | continue | |
| 76 | 81 | items.append((entry.name, entry.size)) | |
| 77 | 82 | ||
@@ -81,8 +86,8 @@ class struct_frozen(Structure): | |||
| 81 | 86 | ] | |
| 82 | 87 | self.assertEqual(items, expected) | |
| 83 | 88 | ||
| 84 | - self.assertTrue(_fzn_implib_seen, | ||
| 85 | - "_frozen_importlib wasn't found in PyImport_FrozenModules") | ||
| 89 | + self.assertEqual(sorted(bootstrap_seen), bootstrap_expected, | ||
| 90 | + "frozen bootstrap modules did not match PyImport_FrozenModules") | ||
| 86 | 91 | ||
| 87 | 92 | from ctypes import _pointer_type_cache | |
| 88 | 93 | del _pointer_type_cache[struct_frozen] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,7 +16,8 @@ | |||
| 16 | 16 | # Platform doesn't support dynamic loading. | |
| 17 | 17 | load_dynamic = None | |
| 18 | 18 | ||
| 19 | - from importlib._bootstrap import SourcelessFileLoader, _ERR_MSG, _exec, _load | ||
| 19 | + from importlib._bootstrap import _ERR_MSG, _exec, _load | ||
| 20 | + from importlib._bootstrap_external import SourcelessFileLoader | ||
| 20 | 21 | ||
| 21 | 22 | from importlib import machinery | |
| 22 | 23 | from importlib import util | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,9 +30,25 @@ | |||
| 30 | 30 | pass | |
| 31 | 31 | sys.modules['importlib._bootstrap'] = _bootstrap | |
| 32 | 32 | ||
| 33 | + try: | ||
| 34 | + import _frozen_importlib_external as _bootstrap_external | ||
| 35 | + except ImportError: | ||
| 36 | + from . import _bootstrap_external | ||
| 37 | + _bootstrap_external._setup(_bootstrap) | ||
| 38 | + else: | ||
| 39 | + _bootstrap_external.__name__ = 'importlib._bootstrap_external' | ||
| 40 | + _bootstrap_external.__package__ = 'importlib' | ||
| 41 | + try: | ||
| 42 | + _bootstrap_external.__file__ = __file__.replace('__init__.py', '_bootstrap_external.py') | ||
| 43 | + except NameError: | ||
| 44 | + # __file__ is not guaranteed to be defined, e.g. if this code gets | ||
| 45 | + # frozen by a tool like cx_Freeze. | ||
| 46 | + pass | ||
| 47 | + sys.modules['importlib._bootstrap_external'] = _bootstrap_external | ||
| 48 | + | ||
| 33 | 49 | # To simplify imports in test code | |
| 34 | - _w_long = _bootstrap._w_long | ||
| 35 | - _r_long = _bootstrap._r_long | ||
| 50 | + _w_long = _bootstrap_external._w_long | ||
| 51 | + _r_long = _bootstrap_external._r_long | ||
| 36 | 52 | ||
| 37 | 53 | # Fully bootstrapped at this point, import whatever you like, circular | |
| 38 | 54 | # dependencies and startup overhead minimisation permitting :) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments