32
32
import com .oracle .graal .python .builtins .PythonBuiltinClassType ;
33
33
import com .oracle .graal .python .builtins .objects .PNone ;
34
34
import com .oracle .graal .python .builtins .objects .function .PArguments ;
35
+ import com .oracle .graal .python .builtins .objects .module .PythonModule ;
35
36
import com .oracle .graal .python .builtins .objects .object .PythonObjectLibrary ;
36
37
import com .oracle .graal .python .builtins .objects .str .PString ;
37
38
import com .oracle .graal .python .nodes .ErrorMessages ;
38
39
import com .oracle .graal .python .nodes .PRaiseImportErrorNode ;
39
- import com .oracle .graal .python .nodes .attributes .ReadAttributeFromObjectNode ;
40
40
import com .oracle .graal .python .nodes .frame .WriteNode ;
41
41
import com .oracle .graal .python .nodes .object .IsBuiltinClassProfile ;
42
42
import com .oracle .graal .python .nodes .subscript .GetItemNode ;
@@ -52,7 +52,6 @@ public class ImportFromNode extends AbstractImportNode {
52
52
@ Children private final WriteNode [] aslist ;
53
53
@ Child private PythonObjectLibrary pythonLibrary ;
54
54
@ Child private GetItemNode getItem ;
55
- @ Child private ReadAttributeFromObjectNode readModules ;
56
55
@ Child private PRaiseImportErrorNode raiseNode ;
57
56
58
57
private final String importee ;
@@ -111,7 +110,9 @@ public void executeVoid(VirtualFrame frame) {
111
110
throw pe ;
112
111
}
113
112
String fullname = PString .cat (pkgname , "." , attr );
114
- Object sysModules = ensureReadModulesNode ().execute (getContext ().getCore ().lookupBuiltinModule ("sys" ), "modules" );
113
+ PythonModule sys = getContext ().getCore ().lookupBuiltinModule ("sys" );
114
+ Object sysModules = pol .lookupAttribute (sys , frame , "modules" );
115
+ assert sysModules != PNone .NO_VALUE : "ImportFromNode: sys.modules was not found!" ;
115
116
writeNode .doWrite (frame , ensureGetItemNode ().execute (frame , sysModules , fullname ));
116
117
} catch (PException e2 ) {
117
118
Object modulePath = "unknown location" ;
@@ -158,15 +159,6 @@ private PRaiseImportErrorNode ensureRaiseNode() {
158
159
return raiseNode ;
159
160
}
160
161
161
- private ReadAttributeFromObjectNode ensureReadModulesNode () {
162
- if (readModules == null ) {
163
- CompilerDirectives .transferToInterpreterAndInvalidate ();
164
- getItem = insert (GetItemNode .create ());
165
- readModules = insert (ReadAttributeFromObjectNode .create ());
166
- }
167
- return readModules ;
168
- }
169
-
170
162
private GetItemNode ensureGetItemNode () {
171
163
if (getItem == null ) {
172
164
CompilerDirectives .transferToInterpreterAndInvalidate ();
0 commit comments