Nuitka-winsvc 1.8.6__cp312-cp312-win_amd64.whl → 1.9.3__cp312-cp312-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. {Nuitka_winsvc-1.8.6.dist-info → Nuitka_winsvc-1.9.3.dist-info}/METADATA +1 -1
  2. {Nuitka_winsvc-1.8.6.dist-info → Nuitka_winsvc-1.9.3.dist-info}/RECORD +212 -203
  3. {Nuitka_winsvc-1.8.6.dist-info → Nuitka_winsvc-1.9.3.dist-info}/WHEEL +1 -1
  4. nuitka/BytecodeCaching.py +4 -1
  5. nuitka/HardImportRegistry.py +348 -0
  6. nuitka/MainControl.py +45 -25
  7. nuitka/OptionParsing.py +31 -20
  8. nuitka/Options.py +47 -16
  9. nuitka/Progress.py +32 -2
  10. nuitka/PythonFlavors.py +1 -1
  11. nuitka/PythonVersions.py +61 -0
  12. nuitka/Tracing.py +25 -12
  13. nuitka/TreeXML.py +5 -5
  14. nuitka/Variables.py +15 -24
  15. nuitka/Version.py +16 -6
  16. nuitka/__main__.py +15 -0
  17. nuitka/__past__.py +15 -17
  18. nuitka/build/Backend.scons +44 -35
  19. nuitka/build/CCompilerVersion.scons +10 -9
  20. nuitka/build/Onefile.scons +11 -26
  21. nuitka/build/SconsCaching.py +2 -0
  22. nuitka/build/SconsCompilerSettings.py +72 -22
  23. nuitka/build/SconsHacks.py +1 -0
  24. nuitka/build/SconsInterface.py +5 -0
  25. nuitka/build/SconsSpawn.py +16 -3
  26. nuitka/build/SconsUtils.py +11 -12
  27. nuitka/build/include/nuitka/checksum_tools.h +0 -4
  28. nuitka/build/include/nuitka/compiled_asyncgen.h +1 -1
  29. nuitka/build/include/nuitka/compiled_coroutine.h +1 -1
  30. nuitka/build/include/nuitka/compiled_frame.h +7 -4
  31. nuitka/build/include/nuitka/compiled_function.h +13 -3
  32. nuitka/build/include/nuitka/compiled_generator.h +1 -1
  33. nuitka/build/include/nuitka/constants.h +2 -0
  34. nuitka/build/include/nuitka/environment_variables.h +45 -0
  35. nuitka/build/include/nuitka/exceptions.h +32 -4
  36. nuitka/build/include/nuitka/filesystem_paths.h +6 -1
  37. nuitka/build/include/nuitka/freelists.h +11 -1
  38. nuitka/build/include/nuitka/helper/dictionaries.h +1 -1
  39. nuitka/build/include/nuitka/helper/import_hard.h +3 -0
  40. nuitka/build/include/nuitka/helpers.h +2 -0
  41. nuitka/build/include/nuitka/importing.h +3 -0
  42. nuitka/build/include/nuitka/prelude.h +17 -6
  43. nuitka/build/include/nuitka/unfreezing.h +1 -1
  44. nuitka/build/inline_copy/bin/scons.py +14 -0
  45. nuitka/build/inline_copy/tqdm/tqdm/__init__.py +2 -2
  46. nuitka/build/inline_copy/tqdm/tqdm/utils.py +14 -8
  47. nuitka/build/inline_copy/zlib/LICENSE +22 -0
  48. nuitka/build/inline_copy/zlib/crc32.c +1049 -0
  49. nuitka/build/inline_copy/zlib/crc32.h +9446 -0
  50. nuitka/build/inline_copy/zlib/zconf.h +551 -0
  51. nuitka/build/inline_copy/zlib/zlib.h +1938 -0
  52. nuitka/build/inline_copy/zlib/zutil.h +275 -0
  53. nuitka/build/static_src/CompiledAsyncgenType.c +41 -41
  54. nuitka/build/static_src/CompiledCodeHelpers.c +14 -7
  55. nuitka/build/static_src/CompiledCoroutineType.c +60 -51
  56. nuitka/build/static_src/CompiledFrameType.c +12 -12
  57. nuitka/build/static_src/CompiledFunctionType.c +149 -28
  58. nuitka/build/static_src/CompiledGeneratorType.c +64 -65
  59. nuitka/build/static_src/CompiledGeneratorTypeUncompiledIntegration.c +1 -1
  60. nuitka/build/static_src/CompiledMethodType.c +5 -3
  61. nuitka/build/static_src/HelperEnvironmentVariables.c +120 -0
  62. nuitka/build/static_src/HelpersAttributes.c +1 -1
  63. nuitka/build/static_src/HelpersBuiltin.c +1 -1
  64. nuitka/build/static_src/HelpersChecksumTools.c +19 -4
  65. nuitka/build/static_src/HelpersComparisonEq.c +4 -4
  66. nuitka/build/static_src/HelpersComparisonNe.c +4 -4
  67. nuitka/build/static_src/HelpersConstantsBlob.c +40 -23
  68. nuitka/build/static_src/HelpersDictionaries.c +3 -1
  69. nuitka/build/static_src/HelpersDictionariesGenerated.c +9 -9
  70. nuitka/build/static_src/HelpersFilesystemPaths.c +12 -2
  71. nuitka/build/static_src/HelpersImport.c +29 -1
  72. nuitka/build/static_src/HelpersImportHard.c +19 -0
  73. nuitka/build/static_src/HelpersOperationInplaceAddUtils.c +5 -4
  74. nuitka/build/static_src/HelpersPythonPgo.c +5 -5
  75. nuitka/build/static_src/HelpersSafeStrings.c +2 -1
  76. nuitka/build/static_src/HelpersStrings.c +12 -10
  77. nuitka/build/static_src/HelpersTypes.c +1 -1
  78. nuitka/build/static_src/InspectPatcher.c +3 -2
  79. nuitka/build/static_src/MainProgram.c +182 -214
  80. nuitka/build/static_src/MetaPathBasedLoader.c +36 -23
  81. nuitka/build/static_src/MetaPathBasedLoaderImportlibMetadataDistribution.c +4 -2
  82. nuitka/build/static_src/MetaPathBasedLoaderResourceReaderFiles.c +38 -2
  83. nuitka/build/static_src/OnefileBootstrap.c +124 -93
  84. nuitka/code_generation/CodeGeneration.py +4 -2
  85. nuitka/code_generation/CodeObjectCodes.py +5 -1
  86. nuitka/code_generation/ConstantCodes.py +4 -0
  87. nuitka/code_generation/Contexts.py +111 -3
  88. nuitka/code_generation/DictCodes.py +5 -5
  89. nuitka/code_generation/FunctionCodes.py +4 -2
  90. nuitka/code_generation/GlobalConstants.py +10 -0
  91. nuitka/code_generation/ImportCodes.py +69 -33
  92. nuitka/code_generation/ModuleCodes.py +4 -1
  93. nuitka/code_generation/Namify.py +6 -5
  94. nuitka/code_generation/YieldCodes.py +3 -3
  95. nuitka/code_generation/templates/CodeTemplatesModules.py +61 -95
  96. nuitka/code_generation/templates_c/HelperDictionaryCopy.c.j2 +3 -3
  97. nuitka/code_generation/templates_c/HelperOperationComparisonUnicode.c.j2 +2 -2
  98. nuitka/distutils/DistutilCommands.py +3 -0
  99. nuitka/finalizations/FinalizeMarkups.py +1 -1
  100. nuitka/freezer/DependsExe.py +2 -1
  101. nuitka/freezer/DllDependenciesPosix.py +11 -1
  102. nuitka/freezer/IncludedEntryPoints.py +54 -16
  103. nuitka/freezer/Onefile.py +7 -3
  104. nuitka/freezer/Standalone.py +39 -17
  105. nuitka/importing/Importing.py +195 -62
  106. nuitka/importing/PreloadedPackages.py +2 -1
  107. nuitka/importing/Recursion.py +98 -27
  108. nuitka/importing/StandardLibrary.py +7 -4
  109. nuitka/nodes/BuiltinOpenNodes.py +28 -1
  110. nuitka/nodes/BuiltinRangeNodes.py +2 -2
  111. nuitka/nodes/BuiltinSumNodes.py +1 -1
  112. nuitka/nodes/ChildrenHavingMixins.py +326 -2
  113. nuitka/nodes/HardImportNodesGenerated.py +141 -38
  114. nuitka/nodes/ImportHardNodes.py +0 -8
  115. nuitka/nodes/ImportNodes.py +267 -361
  116. nuitka/nodes/IterationHandles.py +36 -17
  117. nuitka/nodes/LocalsScopes.py +3 -1
  118. nuitka/nodes/NodeBases.py +8 -14
  119. nuitka/nodes/OperatorNodes.py +9 -9
  120. nuitka/nodes/OutlineNodes.py +3 -3
  121. nuitka/nodes/PackageMetadataNodes.py +19 -9
  122. nuitka/nodes/SliceNodes.py +1 -1
  123. nuitka/nodes/VariableAssignNodes.py +25 -15
  124. nuitka/nodes/VariableRefNodes.py +7 -7
  125. nuitka/nodes/YieldNodes.py +2 -2
  126. nuitka/nodes/shapes/BuiltinTypeShapes.py +81 -6
  127. nuitka/nodes/shapes/ShapeMixins.py +21 -0
  128. nuitka/nodes/shapes/StandardShapes.py +9 -3
  129. nuitka/optimizations/OptimizeBuiltinCalls.py +1 -1
  130. nuitka/optimizations/TraceCollections.py +75 -0
  131. nuitka/pgo/PGO.py +14 -6
  132. nuitka/plugins/PluginBase.py +83 -11
  133. nuitka/plugins/Plugins.py +78 -35
  134. nuitka/plugins/standard/AntiBloatPlugin.py +46 -1
  135. nuitka/plugins/standard/ConsiderPyLintAnnotationsPlugin.py +1 -1
  136. nuitka/plugins/standard/DelvewheelPlugin.py +2 -1
  137. nuitka/plugins/standard/DillPlugin.py +3 -99
  138. nuitka/plugins/standard/DllFilesPlugin.py +45 -0
  139. nuitka/plugins/standard/GiPlugin.py +23 -10
  140. nuitka/plugins/standard/GlfwPlugin.py +1 -0
  141. nuitka/plugins/standard/ImplicitImports.py +267 -15
  142. nuitka/plugins/standard/KivyPlugin.py +1 -0
  143. nuitka/plugins/standard/MatplotlibPlugin.py +43 -25
  144. nuitka/plugins/standard/OptionsNannyPlugin.py +5 -6
  145. nuitka/plugins/standard/PkgResourcesPlugin.py +1 -1
  146. nuitka/plugins/standard/PmwPlugin.py +1 -1
  147. nuitka/plugins/standard/PySidePyQtPlugin.py +37 -20
  148. nuitka/plugins/standard/TkinterPlugin.py +44 -30
  149. nuitka/plugins/standard/TransformersPlugin.py +3 -1
  150. nuitka/plugins/standard/standard.nuitka-package.config.yml +522 -86
  151. nuitka/plugins/standard/stdlib3.nuitka-package.config.yml +8 -1
  152. nuitka/reports/CompilationReportReader.py +53 -0
  153. nuitka/reports/LicenseReport.rst.j2 +4 -4
  154. nuitka/reports/Reports.py +129 -47
  155. nuitka/specs/HardImportSpecs.py +6 -0
  156. nuitka/tools/data_composer/DataComposer.py +29 -17
  157. nuitka/tools/onefile_compressor/OnefileCompressor.py +173 -110
  158. nuitka/tools/podman/__main__.py +17 -2
  159. nuitka/tools/scanning/DisplayPackageDLLs.py +11 -2
  160. nuitka/tools/scanning/DisplayPackageData.py +1 -1
  161. nuitka/tools/specialize/CTypeDescriptions.py +36 -27
  162. nuitka/tools/specialize/SpecializeC.py +1 -1
  163. nuitka/tools/specialize/SpecializePython.py +16 -0
  164. nuitka/tools/testing/Common.py +3 -4
  165. nuitka/tools/testing/OutputComparison.py +23 -0
  166. nuitka/tools/testing/SearchModes.py +2 -2
  167. nuitka/tools/testing/compare_with_cpython/__main__.py +13 -4
  168. nuitka/tools/testing/measure_construct_performance/__main__.py +2 -5
  169. nuitka/tools/watch/__main__.py +194 -56
  170. nuitka/tree/Building.py +8 -2
  171. nuitka/tree/ComplexCallHelperFunctions.py +45 -15
  172. nuitka/tree/ReformulationAssignmentStatements.py +18 -12
  173. nuitka/tree/ReformulationCallExpressions.py +1 -1
  174. nuitka/tree/ReformulationClasses.py +11 -5
  175. nuitka/tree/ReformulationClasses3.py +30 -12
  176. nuitka/tree/ReformulationComparisonExpressions.py +4 -2
  177. nuitka/tree/ReformulationContractionExpressions.py +19 -11
  178. nuitka/tree/ReformulationDictionaryCreation.py +9 -3
  179. nuitka/tree/ReformulationExecStatements.py +6 -6
  180. nuitka/tree/ReformulationForLoopStatements.py +5 -5
  181. nuitka/tree/ReformulationFunctionStatements.py +6 -2
  182. nuitka/tree/ReformulationImportStatements.py +7 -2
  183. nuitka/tree/ReformulationLambdaExpressions.py +1 -1
  184. nuitka/tree/ReformulationMatchStatements.py +3 -1
  185. nuitka/tree/ReformulationNamespacePackages.py +7 -3
  186. nuitka/tree/ReformulationPrintStatements.py +1 -1
  187. nuitka/tree/ReformulationSequenceCreation.py +18 -6
  188. nuitka/tree/ReformulationWithStatements.py +8 -8
  189. nuitka/tree/ReformulationYieldExpressions.py +2 -2
  190. nuitka/tree/SourceHandling.py +27 -5
  191. nuitka/tree/VariableClosure.py +11 -1
  192. nuitka/utils/AppDirs.py +2 -2
  193. nuitka/utils/CStrings.py +39 -3
  194. nuitka/utils/CommandLineOptions.py +42 -1
  195. nuitka/utils/Distributions.py +305 -38
  196. nuitka/utils/Download.py +27 -8
  197. nuitka/utils/FileOperations.py +103 -20
  198. nuitka/utils/Hashing.py +2 -3
  199. nuitka/utils/Importing.py +60 -3
  200. nuitka/utils/InstalledPythons.py +31 -36
  201. nuitka/utils/Jinja2.py +11 -5
  202. nuitka/utils/ModuleNames.py +11 -3
  203. nuitka/utils/ReExecute.py +7 -0
  204. nuitka/utils/SharedLibraries.py +38 -14
  205. nuitka/utils/SlotMetaClasses.py +55 -0
  206. nuitka/utils/Utils.py +10 -0
  207. nuitka/utils/Yaml.py +9 -1
  208. nuitka/build/inline_copy/tqdm/tqdm/_tqdm_gui.py +0 -9
  209. nuitka/build/inline_copy/tqdm/tqdm/gui.py +0 -191
  210. {Nuitka_winsvc-1.8.6.data → Nuitka_winsvc-1.9.3.data}/scripts/nuitka-run.bat +0 -0
  211. {Nuitka_winsvc-1.8.6.data → Nuitka_winsvc-1.9.3.data}/scripts/nuitka.bat +0 -0
  212. {Nuitka_winsvc-1.8.6.dist-info → Nuitka_winsvc-1.9.3.dist-info}/LICENSE.txt +0 -0
  213. {Nuitka_winsvc-1.8.6.dist-info → Nuitka_winsvc-1.9.3.dist-info}/entry_points.txt +0 -0
  214. {Nuitka_winsvc-1.8.6.dist-info → Nuitka_winsvc-1.9.3.dist-info}/top_level.txt +0 -0
@@ -26,12 +26,28 @@ deeper that what it normally could. The import expression node can lead to
26
26
  modules being added. After optimization it will be asked about used modules.
27
27
  """
28
28
 
29
- import os
30
29
  import sys
31
30
 
32
31
  from nuitka.__past__ import long, unicode, xrange
33
32
  from nuitka.code_generation.Reports import onMissingTrust
33
+ from nuitka.HardImportRegistry import (
34
+ addModuleSingleAttributeNodeFactory,
35
+ hard_modules_aliases,
36
+ hard_modules_limited,
37
+ hard_modules_non_stdlib,
38
+ hard_modules_stdlib,
39
+ hard_modules_trust,
40
+ isHardModule,
41
+ isHardModuleWithoutSideEffect,
42
+ trust_constant,
43
+ trust_importable,
44
+ trust_may_exist,
45
+ trust_node,
46
+ trust_node_factory,
47
+ trust_undefined,
48
+ )
34
49
  from nuitka.importing.Importing import (
50
+ isNonRaisingBuiltinModule,
35
51
  isPackageDir,
36
52
  locateModule,
37
53
  makeModuleUsageAttempt,
@@ -40,29 +56,24 @@ from nuitka.importing.ImportResolving import resolveModuleName
40
56
  from nuitka.importing.Recursion import decideRecursion
41
57
  from nuitka.importing.StandardLibrary import isStandardLibraryPath
42
58
  from nuitka.Options import (
59
+ isExperimental,
43
60
  isStandaloneMode,
44
61
  shallMakeModule,
45
62
  shallWarnUnusualCode,
46
63
  )
47
- from nuitka.PythonVersions import (
48
- getFutureModuleKeys,
49
- getImportlibSubPackages,
50
- python_version,
51
- )
64
+ from nuitka.PythonVersions import python_version
52
65
  from nuitka.specs.BuiltinParameterSpecs import (
53
66
  BuiltinParameterSpec,
54
67
  extractBuiltinArgs,
55
68
  )
56
69
  from nuitka.Tracing import unusual_logger
57
70
  from nuitka.utils.ModuleNames import ModuleName
58
- from nuitka.utils.Utils import isWin32Windows
59
71
 
60
72
  from .ChildrenHavingMixins import (
61
73
  ChildHavingModuleMixin,
62
74
  ChildrenExpressionBuiltinImportMixin,
63
75
  ChildrenExpressionImportlibImportModuleCallMixin,
64
76
  )
65
- from .ConstantRefNodes import ExpressionConstantSysVersionInfoRef
66
77
  from .ExpressionBases import ExpressionBase
67
78
  from .ImportHardNodes import (
68
79
  ExpressionImportHardBase,
@@ -79,270 +90,6 @@ from .NodeMakingHelpers import (
79
90
  from .shapes.BuiltinTypeShapes import tshape_module, tshape_module_builtin
80
91
  from .StatementBasesGenerated import StatementImportStarBase
81
92
 
82
- # These module are supported in code generation to be imported the hard way.
83
- hard_modules = frozenset(
84
- (
85
- "os",
86
- "ntpath",
87
- "posixpath",
88
- # TODO: Add mac path package too
89
- "sys",
90
- "types",
91
- "typing",
92
- "__future__",
93
- "importlib",
94
- "importlib.resources",
95
- "importlib.metadata",
96
- "_frozen_importlib",
97
- "_frozen_importlib_external",
98
- "pkgutil",
99
- "functools",
100
- "sysconfig",
101
- "unittest",
102
- "unittest.mock",
103
- # "cStringIO",
104
- "io",
105
- "_io",
106
- "ctypes",
107
- "ctypes.wintypes",
108
- "ctypes.macholib",
109
- # TODO: Once generation of nodes for functions exists.
110
- # "platform",
111
- )
112
- )
113
-
114
- hard_modules_aliases = {
115
- "os.path": os.path.__name__,
116
- }
117
-
118
- # Lets put here, hard modules that are kind of backports only.
119
- hard_modules_stdlib = hard_modules
120
- hard_modules_non_stdlib = frozenset(
121
- (
122
- "site",
123
- "pkg_resources",
124
- "importlib_metadata",
125
- "importlib_resources",
126
- )
127
- )
128
-
129
- hard_modules = hard_modules | hard_modules_non_stdlib
130
-
131
- hard_modules_version = {
132
- "cStringIO": (None, 0x300, None),
133
- "typing": (0x350, None, None),
134
- "_frozen_importlib": (0x300, None, None),
135
- "_frozen_importlib_external": (0x350, None, None),
136
- "importlib.resources": (0x370, None, None),
137
- "importlib.metadata": (0x380, None, None),
138
- "ctypes.wintypes": (None, None, "win32"),
139
- }
140
-
141
- hard_modules_limited = ("importlib.metadata", "ctypes.wintypes", "importlib_metadata")
142
-
143
-
144
- def isHardModule(module_name):
145
- if module_name not in hard_modules:
146
- return False
147
-
148
- min_version, max_version, os_limit = hard_modules_version.get(
149
- module_name, (None, None, None)
150
- )
151
-
152
- if min_version is not None and python_version < min_version:
153
- return False
154
-
155
- if max_version is not None and python_version >= max_version:
156
- return False
157
-
158
- if os_limit is not None:
159
- if os_limit == "win32":
160
- return isWin32Windows()
161
-
162
- return True
163
-
164
-
165
- trust_undefined = 0
166
- trust_constant = 1
167
- trust_exist = 2
168
- trust_future = trust_exist
169
- trust_importable = 3
170
- trust_node = 4
171
- trust_may_exist = 5
172
- trust_not_exist = 6
173
- trust_node_factory = {}
174
-
175
- module_importlib_trust = dict(
176
- (key, trust_importable) for key in getImportlibSubPackages()
177
- )
178
-
179
- if "metadata" not in module_importlib_trust:
180
- module_importlib_trust["metadata"] = trust_undefined
181
- if "resources" not in module_importlib_trust:
182
- module_importlib_trust["resources"] = trust_undefined
183
-
184
- module_sys_trust = {
185
- "version": trust_constant,
186
- "hexversion": trust_constant,
187
- "platform": trust_constant,
188
- "maxsize": trust_constant,
189
- "byteorder": trust_constant,
190
- "builtin_module_names": trust_constant,
191
- "stdout": trust_exist,
192
- "stderr": trust_exist,
193
- }
194
-
195
- if python_version < 0x270:
196
- module_sys_trust["version_info"] = trust_constant
197
- else:
198
- module_sys_trust["version_info"] = trust_node
199
- trust_node_factory[("sys", "version_info")] = ExpressionConstantSysVersionInfoRef
200
-
201
- if python_version < 0x300:
202
- module_sys_trust["exc_type"] = trust_may_exist
203
- module_sys_trust["exc_value"] = trust_may_exist
204
- module_sys_trust["exc_traceback"] = trust_may_exist
205
-
206
- module_sys_trust["maxint"] = trust_constant
207
- module_sys_trust["subversion"] = trust_constant
208
- else:
209
- module_sys_trust["exc_type"] = trust_not_exist
210
- module_sys_trust["exc_value"] = trust_not_exist
211
- module_sys_trust["exc_traceback"] = trust_not_exist
212
-
213
- module_typing_trust = {
214
- "TYPE_CHECKING": trust_constant,
215
- }
216
-
217
- module_os_trust = {
218
- "name": trust_constant,
219
- "listdir": trust_node,
220
- "curdir": trust_constant,
221
- "pardir": trust_constant,
222
- "sep": trust_constant,
223
- "extsep": trust_constant,
224
- "altsep": trust_constant,
225
- "pathsep": trust_constant,
226
- "linesep": trust_constant,
227
- }
228
-
229
- module_os_path_trust = {
230
- "exists": trust_node,
231
- "isfile": trust_node,
232
- "isdir": trust_node,
233
- "basename": trust_node,
234
- }
235
-
236
-
237
- module_ctypes_trust = {
238
- "CDLL": trust_node,
239
- }
240
-
241
- # module_platform_trust = {"python_implementation": trust_function}
242
-
243
- hard_modules_trust = {
244
- "os": module_os_trust,
245
- "ntpath": module_os_path_trust if os.path.__name__ == "ntpath" else {},
246
- "posixpath": module_os_path_trust if os.path.__name__ == "posixpath" else {},
247
- "sys": module_sys_trust,
248
- # "platform": module_platform_trust,
249
- "types": {},
250
- "typing": module_typing_trust,
251
- "__future__": dict((key, trust_future) for key in getFutureModuleKeys()),
252
- "importlib": module_importlib_trust,
253
- "importlib.metadata": {
254
- "version": trust_node,
255
- "distribution": trust_node,
256
- "metadata": trust_node,
257
- "entry_points": trust_node,
258
- "PackageNotFoundError": trust_exist,
259
- },
260
- "importlib_metadata": {
261
- "version": trust_node,
262
- "distribution": trust_node,
263
- "metadata": trust_node,
264
- "entry_points": trust_node,
265
- "PackageNotFoundError": trust_exist,
266
- },
267
- "_frozen_importlib": {},
268
- "_frozen_importlib_external": {},
269
- "pkgutil": {"get_data": trust_node},
270
- "functools": {"partial": trust_exist},
271
- "sysconfig": {},
272
- # TODO: We should have trust_module too.
273
- "unittest": {"mock": trust_exist},
274
- "unittest.mock": {},
275
- "io": {"BytesIO": trust_exist, "StringIO": trust_exist},
276
- "_io": {"BytesIO": trust_exist, "StringIO": trust_exist},
277
- # "cStringIO": {"StringIO": trust_exist},
278
- "pkg_resources": {
279
- "require": trust_node,
280
- "get_distribution": trust_node,
281
- "iter_entry_points": trust_node,
282
- "resource_string": trust_node,
283
- "resource_stream": trust_node,
284
- },
285
- "importlib.resources": {
286
- "read_binary": trust_node,
287
- "read_text": trust_node,
288
- "files": trust_node,
289
- },
290
- "importlib_resources": {
291
- "read_binary": trust_node,
292
- "read_text": trust_node,
293
- "files": trust_node,
294
- },
295
- "ctypes": module_ctypes_trust,
296
- "site": {},
297
- "ctypes.wintypes": {},
298
- "ctypes.macholib": {},
299
- }
300
-
301
-
302
- def _addHardImportNodeClasses():
303
- from .HardImportNodesGenerated import hard_import_node_classes
304
-
305
- for hard_import_node_class, spec in hard_import_node_classes.items():
306
- module_name, function_name = spec.name.rsplit(".", 1)
307
-
308
- if module_name in hard_modules_aliases:
309
- module_name = hard_modules_aliases.get(module_name)
310
-
311
- trust_node_factory[(module_name, function_name)] = hard_import_node_class
312
-
313
- # hard_modules_trust[module_name][function_name] = trust_node
314
-
315
-
316
- _addHardImportNodeClasses()
317
-
318
- # Remove this one again, not available on Windows, but the node generation does
319
- # not know that.
320
- if isWin32Windows():
321
- module_os_trust["uname"] = trust_not_exist
322
-
323
-
324
- def _checkHardModules():
325
- for module_name in hard_modules:
326
- assert module_name in hard_modules_trust, module_name
327
-
328
- for module_name, trust in hard_modules_trust.items():
329
- assert module_name in hard_modules, module_name
330
-
331
- for attribute_name, trust_value in trust.items():
332
- if trust_value is trust_node:
333
- assert (
334
- module_name,
335
- attribute_name,
336
- ) in trust_node_factory or os.path.basename(sys.argv[0]).startswith(
337
- "generate-"
338
- ), (
339
- module_name,
340
- attribute_name,
341
- )
342
-
343
-
344
- _checkHardModules()
345
-
346
93
 
347
94
  def makeExpressionImportModuleNameHard(
348
95
  module_name, import_name, module_guaranteed, source_ref
@@ -363,25 +110,13 @@ def makeExpressionImportModuleNameHard(
363
110
  )
364
111
 
365
112
 
366
- # These modules can cause issues if imported during compile time.
367
- hard_modules_trust_with_side_effects = set(["site"])
368
- if not isWin32Windows():
369
- # Crashing on anything but Windows.
370
- hard_modules_trust_with_side_effects.add("ctypes.wintypes")
371
-
372
-
373
- def isHardModuleWithoutSideEffect(module_name):
374
- return (
375
- module_name in hard_modules
376
- and module_name not in hard_modules_trust_with_side_effects
377
- )
378
-
379
-
380
113
  class ExpressionImportAllowanceMixin(object):
381
114
  # Mixins are not allowed to specify slots, pylint: disable=assigning-non-slot
382
115
  __slots__ = ()
383
116
 
384
- def __init__(self):
117
+ def __init__(self, using_module_name):
118
+ self.using_module_name = using_module_name
119
+
385
120
  if self.finding == "not-found":
386
121
  self.allowed = False
387
122
  elif self.finding == "built-in":
@@ -390,7 +125,7 @@ class ExpressionImportAllowanceMixin(object):
390
125
  self.allowed = True
391
126
  else:
392
127
  self.allowed, _reason = decideRecursion(
393
- using_module_name=None,
128
+ using_module_name=self.using_module_name,
394
129
  module_filename=self.module_filename,
395
130
  module_name=self.module_name,
396
131
  module_kind=self.module_kind,
@@ -413,17 +148,18 @@ class ExpressionImportModuleFixed(ExpressionBase):
413
148
 
414
149
  __slots__ = (
415
150
  "module_name",
151
+ "value_name",
416
152
  "found_module_name",
417
153
  "found_module_filename",
418
154
  "module_kind",
419
155
  "finding",
420
- "allowance",
421
156
  )
422
157
 
423
- def __init__(self, module_name, source_ref):
158
+ def __init__(self, module_name, value_name, source_ref):
424
159
  ExpressionBase.__init__(self, source_ref)
425
160
 
426
161
  self.module_name = ModuleName(module_name)
162
+ self.value_name = ModuleName(value_name)
427
163
 
428
164
  self.finding = None
429
165
 
@@ -470,11 +206,14 @@ class ExpressionImportModuleFixed(ExpressionBase):
470
206
  del self.parent
471
207
 
472
208
  def getDetails(self):
473
- return {"module_name": self.module_name}
209
+ return {"module_name": self.module_name, "value_name": self.value_name}
474
210
 
475
211
  def getModuleName(self):
476
212
  return self.module_name
477
213
 
214
+ def getValueName(self):
215
+ return self.value_name
216
+
478
217
  @staticmethod
479
218
  def mayHaveSideEffects():
480
219
  # TODO: For included modules, we might be able to tell, not not done now.
@@ -486,6 +225,8 @@ class ExpressionImportModuleFixed(ExpressionBase):
486
225
  return True
487
226
 
488
227
  def getTypeShape(self):
228
+ # TODO: This ought to be dead code, built-in modules have their own nodes now
229
+ # and may only be hard imports, but not this.
489
230
  if self.module_name in sys.builtin_module_names:
490
231
  return tshape_module_builtin
491
232
  else:
@@ -522,6 +263,98 @@ class ExpressionImportModuleFixed(ExpressionBase):
522
263
  )
523
264
 
524
265
 
266
+ class ExpressionImportModuleBuiltin(ExpressionBase):
267
+ """Hard coded import names, that we know to exist."
268
+
269
+ These created as result of builtin imports and "importlib.import_module" calls
270
+ that were compile time resolved, and for known module names.
271
+ """
272
+
273
+ kind = "EXPRESSION_IMPORT_MODULE_BUILTIN"
274
+
275
+ __slots__ = (
276
+ "module_name",
277
+ "value_name",
278
+ "module_kind",
279
+ "builtin_module",
280
+ )
281
+
282
+ def __init__(self, module_name, value_name, source_ref):
283
+ ExpressionBase.__init__(self, source_ref)
284
+
285
+ self.module_name = ModuleName(module_name)
286
+ self.value_name = ModuleName(value_name)
287
+
288
+ self.builtin_module = __import__(module_name.asString())
289
+
290
+ # If not found, we import the package at least
291
+ _module_name, _module_filename, _module_kind, _finding = locateModule(
292
+ module_name=self.module_name,
293
+ parent_package=None,
294
+ level=0,
295
+ )
296
+
297
+ assert _module_name == self.module_name, _module_name
298
+ assert _finding == "built-in", _finding
299
+ assert _module_kind is None, _module_kind
300
+
301
+ @staticmethod
302
+ def getTypeShape():
303
+ return tshape_module_builtin
304
+
305
+ def mayRaiseExceptionImportName(self, exception_type, import_name):
306
+ return not hasattr(self.builtin_module, import_name)
307
+
308
+ def finalize(self):
309
+ del self.parent
310
+
311
+ def getDetails(self):
312
+ return {"module_name": self.module_name, "value_name": self.value_name}
313
+
314
+ def getModuleName(self):
315
+ return self.module_name
316
+
317
+ def getValueName(self):
318
+ return self.value_name
319
+
320
+ @staticmethod
321
+ def mayHaveSideEffects():
322
+ return True
323
+
324
+ def mayRaiseException(self, exception_type):
325
+ return isNonRaisingBuiltinModule(self.module_name) is not False
326
+
327
+ def getModuleUsageAttempt(self):
328
+ return makeModuleUsageAttempt(
329
+ module_name=self.module_name,
330
+ filename=None,
331
+ finding="built-in",
332
+ module_kind=None,
333
+ level=0,
334
+ source_ref=self.source_ref,
335
+ reason="import",
336
+ )
337
+
338
+ def computeExpressionRaw(self, trace_collection):
339
+ if self.mayRaiseException(BaseException):
340
+ trace_collection.onExceptionRaiseExit(BaseException)
341
+
342
+ # Trace the module usage attempt.
343
+ trace_collection.onModuleUsageAttempt(self.getModuleUsageAttempt())
344
+
345
+ # Nothing to do about it.
346
+ return self, None, None
347
+
348
+ def computeExpressionImportName(self, import_node, import_name, trace_collection):
349
+ # TODO: For include modules, something might be possible here, consider self.allowance
350
+ # when that is implemented.
351
+ return self.computeExpressionAttribute(
352
+ lookup_node=import_node,
353
+ attribute_name=import_name,
354
+ trace_collection=trace_collection,
355
+ )
356
+
357
+
525
358
  class ExpressionImportModuleHard(
526
359
  ExpressionImportAllowanceMixin, ExpressionImportHardBase
527
360
  ):
@@ -533,17 +366,26 @@ class ExpressionImportModuleHard(
533
366
 
534
367
  kind = "EXPRESSION_IMPORT_MODULE_HARD"
535
368
 
536
- __slots__ = ("module", "allowed", "guaranteed", "value_name", "is_package")
369
+ __slots__ = (
370
+ "using_module_name",
371
+ "module",
372
+ "allowed",
373
+ "guaranteed",
374
+ "value_name",
375
+ "is_package",
376
+ )
537
377
 
538
- def __init__(self, module_name, value_name, source_ref):
378
+ def __init__(self, using_module_name, module_name, value_name, source_ref):
539
379
  ExpressionImportHardBase.__init__(
540
380
  self, module_name=module_name, source_ref=source_ref
541
381
  )
542
382
 
543
- ExpressionImportAllowanceMixin.__init__(self)
544
-
545
383
  self.value_name = value_name
546
384
 
385
+ ExpressionImportAllowanceMixin.__init__(
386
+ self, using_module_name=using_module_name
387
+ )
388
+
547
389
  if self.finding != "not-found" and isHardModuleWithoutSideEffect(
548
390
  self.module_name
549
391
  ):
@@ -571,7 +413,11 @@ class ExpressionImportModuleHard(
571
413
  del self.parent
572
414
 
573
415
  def getDetails(self):
574
- return {"module_name": self.module_name, "value_name": self.value_name}
416
+ return {
417
+ "using_module_name": self.using_module_name,
418
+ "module_name": self.module_name,
419
+ "value_name": self.value_name,
420
+ }
575
421
 
576
422
  def getModuleName(self):
577
423
  return self.module_name
@@ -656,6 +502,7 @@ class ExpressionImportModuleHard(
656
502
 
657
503
  if isHardModule(full_name):
658
504
  new_node = ExpressionImportModuleHard(
505
+ using_module_name=self.using_module_name,
659
506
  module_name=full_name,
660
507
  value_name=full_name,
661
508
  source_ref=lookup_node.source_ref,
@@ -699,13 +546,17 @@ class ExpressionImportModuleHard(
699
546
  )
700
547
  else:
701
548
  if trust is trust_undefined:
702
- # TODO: Should add this, such that these imports are
703
- # properly resolved: pylint: disable=condition-evals-to-constant
704
-
705
- if self.is_package and False:
549
+ # Need to attempt module imports if this is for an import
550
+ # lookup of code like "from value_name import attribute_name".
551
+ if self.is_package:
706
552
  full_name = self.value_name.getChildNamed(attribute_name)
707
553
 
708
- _sub_module_name, _sub_module_filename, finding = locateModule(
554
+ (
555
+ _sub_module_name,
556
+ _sub_module_filename,
557
+ _sub_module_kind,
558
+ finding,
559
+ ) = locateModule(
709
560
  module_name=full_name,
710
561
  parent_package=None,
711
562
  level=0,
@@ -713,7 +564,9 @@ class ExpressionImportModuleHard(
713
564
 
714
565
  if finding != "not-found":
715
566
  result = makeExpressionImportModuleFixed(
567
+ using_module_name=self.getParentModule().getFullName(),
716
568
  module_name=full_name,
569
+ value_name=full_name,
717
570
  source_ref=lookup_node.getSourceReference(),
718
571
  )
719
572
 
@@ -747,6 +600,9 @@ class ExpressionImportModuleHard(
747
600
  % (self.value_name, attribute_name),
748
601
  )
749
602
  elif trust is trust_node:
603
+ # TODO: Unify with other branches.
604
+ trace_collection.onExceptionRaiseExit(ImportError)
605
+
750
606
  result = trust_node_factory[self.value_name, attribute_name](
751
607
  source_ref=lookup_node.source_ref
752
608
  )
@@ -919,7 +775,10 @@ class ExpressionImportlibImportModuleCall(
919
775
  trace_collection.onExceptionRaiseExit(BaseException)
920
776
 
921
777
  result = makeExpressionImportModuleFixed(
922
- module_name=resolved_module_name, source_ref=self.source_ref
778
+ using_module_name=self.getParentModule().getFullName(),
779
+ module_name=resolved_module_name,
780
+ value_name=resolved_module_name,
781
+ source_ref=self.source_ref,
923
782
  )
924
783
 
925
784
  return (
@@ -943,8 +802,9 @@ class ExpressionImportlibImportModuleCall(
943
802
  return self, None, None
944
803
 
945
804
 
946
- module_importlib_trust["import_module"] = trust_node
947
- trust_node_factory[("importlib", "import_module")] = ExpressionImportlibImportModuleRef
805
+ addModuleSingleAttributeNodeFactory(
806
+ "importlib", "import_module", ExpressionImportlibImportModuleRef
807
+ )
948
808
 
949
809
 
950
810
  class ExpressionBuiltinImport(ChildrenExpressionBuiltinImportMixin, ExpressionBase):
@@ -952,8 +812,6 @@ class ExpressionBuiltinImport(ChildrenExpressionBuiltinImportMixin, ExpressionBa
952
812
  "follow_attempted",
953
813
  "finding",
954
814
  "used_modules",
955
- "type_shape",
956
- "builtin_module",
957
815
  )
958
816
 
959
817
  kind = "EXPRESSION_BUILTIN_IMPORT"
@@ -984,10 +842,6 @@ class ExpressionBuiltinImport(ChildrenExpressionBuiltinImportMixin, ExpressionBa
984
842
  # imports are considered too.
985
843
  self.used_modules = []
986
844
 
987
- self.type_shape = tshape_module
988
-
989
- self.builtin_module = None
990
-
991
845
  self.finding = None
992
846
 
993
847
  def _attemptFollow(self, module_name):
@@ -995,10 +849,6 @@ class ExpressionBuiltinImport(ChildrenExpressionBuiltinImportMixin, ExpressionBa
995
849
 
996
850
  parent_module = self.getParentModule()
997
851
 
998
- parent_package = parent_module.getFullName()
999
- if not parent_module.isCompiledPythonPackage():
1000
- parent_package = parent_package.getPackageName()
1001
-
1002
852
  level = self.subnode_level
1003
853
 
1004
854
  if level is None:
@@ -1008,6 +858,13 @@ class ExpressionBuiltinImport(ChildrenExpressionBuiltinImportMixin, ExpressionBa
1008
858
  else:
1009
859
  level = level.getCompileTimeConstant()
1010
860
 
861
+ if level != 0:
862
+ parent_package = parent_module.getFullName()
863
+ if not parent_module.isCompiledPythonPackage():
864
+ parent_package = parent_package.getPackageName()
865
+ else:
866
+ parent_package = None
867
+
1011
868
  # TODO: Catch this as a static error maybe.
1012
869
  if type(level) not in (int, long):
1013
870
  return None
@@ -1024,15 +881,16 @@ class ExpressionBuiltinImport(ChildrenExpressionBuiltinImportMixin, ExpressionBa
1024
881
  )
1025
882
  )
1026
883
 
1027
- module_name, module_filename, module_kind, self.finding = locateModule(
1028
- module_name=resolveModuleName(module_name),
884
+ module_name = ModuleName(module_name)
885
+ module_name_found, module_filename, module_kind, self.finding = locateModule(
886
+ module_name=ModuleName(module_name),
1029
887
  parent_package=parent_package,
1030
888
  level=level,
1031
889
  )
1032
890
 
1033
891
  self.used_modules = [
1034
892
  makeModuleUsageAttempt(
1035
- module_name=module_name,
893
+ module_name=module_name_found,
1036
894
  filename=module_filename,
1037
895
  module_kind=module_kind,
1038
896
  finding=self.finding,
@@ -1043,6 +901,8 @@ class ExpressionBuiltinImport(ChildrenExpressionBuiltinImportMixin, ExpressionBa
1043
901
  ]
1044
902
 
1045
903
  if self.finding != "not-found":
904
+ module_name = module_name_found
905
+
1046
906
  import_list = self.subnode_fromlist
1047
907
 
1048
908
  if import_list is not None:
@@ -1086,8 +946,6 @@ class ExpressionBuiltinImport(ChildrenExpressionBuiltinImportMixin, ExpressionBa
1086
946
 
1087
947
  return module_filename
1088
948
  else:
1089
- module_name = resolveModuleName(module_name)
1090
-
1091
949
  while True:
1092
950
  module_name = module_name.getPackageName()
1093
951
 
@@ -1122,9 +980,19 @@ class ExpressionBuiltinImport(ChildrenExpressionBuiltinImportMixin, ExpressionBa
1122
980
 
1123
981
  return None
1124
982
 
983
+ def _getImportedValueName(self, imported_module_name):
984
+ from_list_truth = (
985
+ self.subnode_fromlist is not None and self.subnode_fromlist.getTruthValue()
986
+ )
987
+
988
+ if from_list_truth is True:
989
+ return imported_module_name
990
+ else:
991
+ return imported_module_name.getTopLevelPackageName()
992
+
1125
993
  def computeExpression(self, trace_collection):
1126
- # Attempt to recurse if not already done, many cases to consider
1127
- # pylint: disable=too-many-branches
994
+ # Attempt to recurse if not already done, many cases to consider and its
995
+ # return driven, pylint: disable=too-many-branches,too-many-return-statements
1128
996
  if self.follow_attempted:
1129
997
  if self.finding == "not-found":
1130
998
  # Importing and not finding, may raise an exception obviously.
@@ -1163,29 +1031,28 @@ class ExpressionBuiltinImport(ChildrenExpressionBuiltinImportMixin, ExpressionBa
1163
1031
  if self.finding == "absolute" and isHardModule(imported_module_name):
1164
1032
  if (
1165
1033
  imported_module_name in hard_modules_non_stdlib
1034
+ or module_filename is None
1166
1035
  or isStandardLibraryPath(module_filename)
1167
1036
  ):
1168
- from_list_truth = (
1169
- self.subnode_fromlist is not None
1170
- and self.subnode_fromlist.getTruthValue()
1171
- )
1172
-
1173
- if from_list_truth is True:
1174
- value_name = imported_module_name
1175
- else:
1176
- value_name = imported_module_name.getTopLevelPackageName()
1177
-
1178
1037
  result = ExpressionImportModuleHard(
1038
+ using_module_name=self.getParentModule().getFullName(),
1179
1039
  module_name=imported_module_name,
1180
- value_name=value_name,
1040
+ value_name=self._getImportedValueName(imported_module_name),
1181
1041
  source_ref=self.source_ref,
1182
1042
  )
1183
1043
 
1184
1044
  return (
1185
1045
  result,
1186
1046
  "new_expression",
1187
- "Lowered import of standard library module '%s' to hard import."
1188
- % imported_module_name.asString(),
1047
+ "Lowered import %s module '%s' to hard import."
1048
+ % (
1049
+ (
1050
+ "hard import"
1051
+ if imported_module_name in hard_modules_non_stdlib
1052
+ else "standard library"
1053
+ ),
1054
+ imported_module_name.asString(),
1055
+ ),
1189
1056
  )
1190
1057
  elif shallWarnUnusualCode():
1191
1058
  unusual_logger.warning(
@@ -1197,23 +1064,24 @@ class ExpressionBuiltinImport(ChildrenExpressionBuiltinImportMixin, ExpressionBa
1197
1064
  )
1198
1065
  )
1199
1066
 
1200
- if self.finding == "built-in":
1201
- if isHardModule(imported_module_name):
1202
- result = ExpressionImportModuleHard(
1203
- module_name=imported_module_name,
1204
- value_name=imported_module_name.getTopLevelPackageName(),
1205
- source_ref=self.source_ref,
1206
- )
1067
+ # Built-in module imports can be specialized right away.
1207
1068
 
1208
- return (
1209
- result,
1210
- "new_expression",
1211
- "Lowered import of built-in module '%s' to hard import."
1212
- % imported_module_name.asString(),
1213
- )
1069
+ if self.finding == "built-in":
1070
+ result = makeExpressionImportModuleBuiltin(
1071
+ using_module_name=self.getParentModule().getFullName(),
1072
+ module_name=imported_module_name,
1073
+ value_name=self._getImportedValueName(imported_module_name),
1074
+ source_ref=self.source_ref,
1075
+ )
1214
1076
 
1215
- self.type_shape = tshape_module_builtin
1216
- self.builtin_module = __import__(imported_module_name.asString())
1077
+ # TODO: This ought to preserve side effects from arguments
1078
+ # for full compatibility with strange uses of __import__
1079
+ return (
1080
+ result,
1081
+ "new_expression",
1082
+ "Lowered import of built-in module '%s' to hard import."
1083
+ % imported_module_name.asString(),
1084
+ )
1217
1085
 
1218
1086
  if self.finding == "not-found":
1219
1087
  if imported_module_name in hard_modules_limited:
@@ -1228,6 +1096,26 @@ class ExpressionBuiltinImport(ChildrenExpressionBuiltinImportMixin, ExpressionBa
1228
1096
  % imported_module_name.asString(),
1229
1097
  )
1230
1098
 
1099
+ elif (
1100
+ isStandaloneMode()
1101
+ and self.used_modules
1102
+ and isExperimental("standalone-imports")
1103
+ ):
1104
+ result = makeExpressionImportModuleFixed(
1105
+ using_module_name=self.getParentModule().getFullName(),
1106
+ module_name=self.used_modules[0].module_name,
1107
+ value_name=self._getImportedValueName(
1108
+ self.used_modules[0].module_name
1109
+ ),
1110
+ source_ref=self.source_ref,
1111
+ )
1112
+
1113
+ return (
1114
+ result,
1115
+ "new_expression",
1116
+ "Lowered import of module '%s' to fixed import."
1117
+ % imported_module_name.asString(),
1118
+ )
1231
1119
  else:
1232
1120
  # TODO: This doesn't preserve side effects.
1233
1121
 
@@ -1263,15 +1151,6 @@ class ExpressionBuiltinImport(ChildrenExpressionBuiltinImportMixin, ExpressionBa
1263
1151
  def mayRaiseException(self, exception_type):
1264
1152
  return self.finding != "built-in"
1265
1153
 
1266
- def mayRaiseExceptionImportName(self, exception_type, import_name):
1267
- if self.finding == "built-in":
1268
- return not hasattr(self.builtin_module, import_name)
1269
- else:
1270
- return True
1271
-
1272
- def getTypeShape(self):
1273
- return self.type_shape
1274
-
1275
1154
 
1276
1155
  class StatementImportStar(StatementImportStarBase):
1277
1156
  kind = "STATEMENT_IMPORT_STAR"
@@ -1354,16 +1233,43 @@ class ExpressionImportName(ChildHavingModuleMixin, ExpressionBase):
1354
1233
  )
1355
1234
 
1356
1235
 
1357
- def makeExpressionImportModuleFixed(module_name, source_ref):
1236
+ def makeExpressionImportModuleFixed(
1237
+ using_module_name, module_name, value_name, source_ref
1238
+ ):
1358
1239
  module_name = resolveModuleName(module_name)
1240
+ value_name = resolveModuleName(value_name)
1359
1241
 
1360
1242
  if isHardModule(module_name):
1361
1243
  return ExpressionImportModuleHard(
1244
+ using_module_name=using_module_name,
1362
1245
  module_name=module_name,
1363
- value_name=module_name.getTopLevelPackageName(),
1246
+ value_name=value_name,
1364
1247
  source_ref=source_ref,
1365
1248
  )
1366
1249
  else:
1367
1250
  return ExpressionImportModuleFixed(
1368
- module_name=module_name, source_ref=source_ref
1251
+ module_name=module_name,
1252
+ value_name=value_name,
1253
+ source_ref=source_ref,
1254
+ )
1255
+
1256
+
1257
+ def makeExpressionImportModuleBuiltin(
1258
+ using_module_name, module_name, value_name, source_ref
1259
+ ):
1260
+ module_name = resolveModuleName(module_name)
1261
+ value_name = resolveModuleName(value_name)
1262
+
1263
+ if isHardModule(module_name):
1264
+ return ExpressionImportModuleHard(
1265
+ using_module_name=using_module_name,
1266
+ module_name=module_name,
1267
+ value_name=value_name,
1268
+ source_ref=source_ref,
1269
+ )
1270
+ else:
1271
+ return ExpressionImportModuleBuiltin(
1272
+ module_name=module_name,
1273
+ value_name=value_name,
1274
+ source_ref=source_ref,
1369
1275
  )