Skip to content

Commit df3979b

Browse files
committed
Fix error handling in super with no __class__
1 parent a4992ab commit df3979b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/superobject/SuperBuiltins.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ protected boolean isInBuiltinFunctionRoot() {
216216
protected ReadLocalVariableNode createRead(VirtualFrame frame) {
217217
FrameSlot slot = frame.getFrameDescriptor().findFrameSlot(SpecialAttributeNames.__CLASS__);
218218
if (slot == null) {
219-
throw raise(PythonErrorType.RuntimeError, ErrorMessages.EMPTY_CLASS_CELL);
219+
throw raise(PythonErrorType.RuntimeError, ErrorMessages.SUPER_NO_CLASS);
220220
}
221221
return ReadLocalVariableNode.create(slot);
222222
}
@@ -238,7 +238,7 @@ PNone initInPlace(VirtualFrame frame, SuperObject self, @SuppressWarnings("unuse
238238
cls = getGetRefNode().execute((PCell) cls);
239239
}
240240
if (cls == PNone.NONE) {
241-
throw raise(PythonErrorType.RuntimeError, ErrorMessages.EMPTY_CLASS_CELL, "super()");
241+
throw raise(PythonErrorType.RuntimeError, ErrorMessages.SUPER_NO_CLASS);
242242
}
243243
return init(frame, self, cls, obj);
244244
}
@@ -276,7 +276,7 @@ private Object getClassFromTarget(VirtualFrame frame, PFrame target, HashingStor
276276
if (cls instanceof PCell) {
277277
cls = getGetRefNode().execute((PCell) cls);
278278
if (cls == null) {
279-
throw raise(PythonErrorType.RuntimeError, ErrorMessages.EMPTY_CLASS_CELL, "super()");
279+
throw raise(PythonErrorType.RuntimeError, ErrorMessages.SUPER_NO_CLASS);
280280
}
281281
}
282282
return cls != null ? cls : PNone.NONE;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public abstract class ErrorMessages {
167167
public static final String DICT_UPDATE_SEQ_ELEM_HAS_LENGTH_2_REQUIRED = "dictionary update sequence element #%d has length %d; 2 is required";
168168
public static final String DIVISION_BY_ZERO = "division by zero";
169169
public static final String S_DIVISION_BY_ZERO = "%s division by zero";
170-
public static final String EMPTY_CLASS_CELL = "%s: empty __class__ cell";
170+
public static final String SUPER_NO_CLASS = "super(): no arguments";
171171
public static final String EMPTY_SEPARATOR = "empty separator";
172172
public static final String EMPTY_STR_FOR_COMPLEX = "empty string for complex()";
173173
public static final String END_MUST_BE_NONE_OR_STRING = "end must be None or a string, not %p";

0 commit comments

Comments
 (0)