Skip to content

Commit 16178cd

Browse files
committed
__new__ should call __init__ also for subtypes
1 parent 0784cb2 commit 16178cd

File tree

1 file changed

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

1 file changed

+6
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public abstract static class CallNode extends PythonVarargsBuiltinNode {
206206
@Child private LookupAttributeInMRONode lookupNew = LookupAttributeInMRONode.create(__NEW__);
207207
@Child private CallVarargsMethodNode dispatchInit = CallVarargsMethodNode.create();
208208
@Child private LookupAttributeInMRONode lookupInit = LookupAttributeInMRONode.create(__INIT__);
209-
@Child private TypeNodes.IsSameTypeNode isSameTypeNode;
209+
@Child private IsSubtypeNode isSubTypeNode;
210210
@Child private TypeNodes.GetNameNode getNameNode;
211211
@Child private IsBuiltinClassProfile isClassClassProfile = IsBuiltinClassProfile.create();
212212

@@ -354,7 +354,7 @@ private Object op(VirtualFrame frame, Object self, Object[] arguments, PKeyword[
354354
newInstance = dispatchNew.execute(frame, callNewGet.execute(frame, newMethod, PNone.NONE, self), newArgs, keywords);
355355
}
356356
Object newInstanceKlass = lib.getLazyPythonClass(newInstance);
357-
if (isSameType(newInstanceKlass, self)) {
357+
if (isSubType(newInstanceKlass, self)) {
358358
if (arguments.length == 2 && isClassClassProfile.profileClass(self, PythonBuiltinClassType.PythonClass)) {
359359
// do not call init if we are creating a new instance of type and we are
360360
// passing keywords or more than one argument see:
@@ -383,12 +383,12 @@ private Object op(VirtualFrame frame, Object self, Object[] arguments, PKeyword[
383383
}
384384
}
385385

386-
private boolean isSameType(Object left, Object right) {
387-
if (isSameTypeNode == null) {
386+
private boolean isSubType(Object left, Object right) {
387+
if (isSubTypeNode == null) {
388388
CompilerDirectives.transferToInterpreterAndInvalidate();
389-
isSameTypeNode = insert(IsSameTypeNodeGen.create());
389+
isSubTypeNode = insert(IsSubtypeNode.create());
390390
}
391-
return isSameTypeNode.execute(left, right);
391+
return isSubTypeNode.execute(left, right);
392392
}
393393

394394
private String getTypeName(Object clazz) {

0 commit comments

Comments
 (0)