Skip to content

Commit a8484af

Browse files
committed
Support native member 'tp_new'.
1 parent 6a2319c commit a8484af

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/NativeMemberNames.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public abstract class NativeMemberNames {
5858
public static final String TP_SETATTR = "tp_setattr";
5959
public static final String TP_GETATTRO = "tp_getattro";
6060
public static final String TP_SETATTRO = "tp_setattro";
61+
public static final String TP_NEW = "tp_new";
6162
public static final String _BASE = "_base";
6263
public static final String OB_ITEM = "ob_item";
6364
public static final String MA_USED = "ma_used";
@@ -96,6 +97,7 @@ public static boolean isValid(String key) {
9697
case TP_SETATTR:
9798
case TP_GETATTRO:
9899
case TP_SETATTRO:
100+
case TP_NEW:
99101
case _BASE:
100102
case OB_ITEM:
101103
case MA_USED:

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/PythonObjectNativeWrapperMR.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ Object doTpAsBuffer(PythonClass object, @SuppressWarnings("unused") String key)
212212
return getToSulongNode().execute(PNone.NO_VALUE);
213213
}
214214

215+
@Specialization(guards = "eq(TP_NEW, key)")
216+
Object doTpNew(PythonClass object, @SuppressWarnings("unused") String key,
217+
@Cached("create()") GetAttributeNode getAttrNode) {
218+
return getToSulongNode().execute(getAttrNode.execute(object, SpecialAttributeNames.__NEW__));
219+
}
220+
215221
@Specialization(guards = "eq(TP_HASH, key)")
216222
Object doTpHash(PythonClass object, @SuppressWarnings("unused") String key,
217223
@Cached("create()") GetAttributeNode getHashNode) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public abstract class SpecialAttributeNames {
6565
public static final String __CACHED__ = "__cached__";
6666
public static final String __TRACEBACK__ = "__traceback__";
6767
public static final String __BASICSIZE__ = "__basicsize__";
68+
public static final String __NEW__ = "__new__";
6869

6970
/* hidden keys */
7071
public static final HiddenKey __GET_BUFFER__ = new HiddenKey("__get_buffer__");

0 commit comments

Comments
 (0)