Skip to content

Commit 4ade311

Browse files
committed
in the generic case for type.__call__, support PythonBuiltinClassTypes
1 parent 7d2411c commit 4ade311

File tree

1 file changed

+8
-1
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type

1 file changed

+8
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeBuiltins.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,14 @@ protected Object doItUnboxed(VirtualFrame frame, @SuppressWarnings("unused") PNo
219219
@Specialization(replaces = "doItUnboxed")
220220
protected Object doItUnboxedIndirect(VirtualFrame frame, @SuppressWarnings("unused") PNone noSelf, Object[] arguments, PKeyword[] keywords) {
221221
Object self = arguments[0];
222-
return op(frame, (PythonAbstractClass) self, arguments, keywords, false);
222+
if (self instanceof PythonAbstractClass) {
223+
return op(frame, (PythonAbstractClass) self, arguments, keywords, false);
224+
} else if (self instanceof PythonBuiltinClassType) {
225+
PythonBuiltinClass actual = getContext().getCore().lookupType((PythonBuiltinClassType) self);
226+
return op(frame, actual, arguments, keywords, false);
227+
} else {
228+
throw raise(TypeError, "descriptor '__call__' requires a 'type' object but received a '%p'", self);
229+
}
223230
}
224231

225232
@Specialization(limit = "getCallSiteInlineCacheMaxDepth()", guards = {"self == cachedSelf"})

0 commit comments

Comments
 (0)