Skip to content

Commit c8ced0c

Browse files
committed
GR-26037: execute IMPORT_NAME before IMPORT_FROM
- style fixes
1 parent 2eb3dec commit c8ced0c

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PConstructAndRaiseNode.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,19 @@ PException constructAndRaiseNoFormatString(VirtualFrame frame, PythonBuiltinClas
109109
return raiseInternal(frame, type, arguments, keywords, callNode, language, core);
110110
}
111111

112-
@Specialization(guards = {"arguments == null"})
112+
@Specialization(guards = {"format != null", "arguments == null"})
113113
PException constructAndRaiseNoArgs(VirtualFrame frame, PythonBuiltinClassType type, String format, Object[] formatArgs,
114114
@SuppressWarnings("unused") Object[] arguments, PKeyword[] keywords,
115115
@Cached.Shared("callNode") @Cached CallVarargsMethodNode callNode,
116116
@Cached.Shared("pol") @CachedLibrary(limit = "3") PythonObjectLibrary pol,
117117
@CachedLanguage PythonLanguage language,
118118
@CachedContext(PythonLanguage.class) PythonContext context) {
119119
PythonCore core = context.getCore();
120-
Object[] args = new Object[]{getFormattedMessage(pol, format, formatArgs)};
120+
Object[] args = new Object[]{formatArgs != null ? getFormattedMessage(pol, format, formatArgs) : format};
121121
return raiseInternal(frame, type, args, keywords, callNode, language, core);
122122
}
123123

124-
@Specialization(guards = {"arguments != null"})
124+
@Specialization(guards = {"format != null", "arguments != null"})
125125
PException constructAndRaise(VirtualFrame frame, PythonBuiltinClassType type, String format, Object[] formatArgs,
126126
Object[] arguments, PKeyword[] keywords,
127127
@Cached.Shared("callNode") @Cached CallVarargsMethodNode callNode,

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/parser/sst/FactorySSTVisitor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,8 @@ public PNode visit(ImportSSTNode node) {
995995
}
996996

997997
WriteNode readNode = (WriteNode) scopeEnvironment.findVariable(node.asName).makeWriteNode(EmptyNode.create());
998-
result = nodeFactory.createImportFrom(from, new String[]{parts[parts.length - 1]}, new WriteNode[]{readNode}, level);
998+
StatementNode importFrom = nodeFactory.createImportFrom(from, new String[]{parts[parts.length - 1]}, new WriteNode[]{readNode}, level);
999+
result = nodeFactory.createBlock(importNode.asStatement(), importFrom);
9991000
} else {
10001001
result = scopeEnvironment.findVariable(node.asName).makeWriteNode(importNode);
10011002
}

0 commit comments

Comments
 (0)