Skip to content

Commit 76a2e4e

Browse files
committed
added deleteDict to PythonObjectLibrary
1 parent f54f676 commit 76a2e4e

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ public void setDict(PDict value) throws UnsupportedMessageException {
169169
throw UnsupportedMessageException.create();
170170
}
171171

172+
@ExportMessage
173+
@SuppressWarnings({"static-method", "unused"})
174+
public void deleteDict() throws UnsupportedMessageException {
175+
throw UnsupportedMessageException.create();
176+
}
177+
172178
@ExportMessage
173179
public Object asIndexWithState(ThreadState threadState,
174180
@CachedLibrary("this") PythonObjectLibrary plib,

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/PythonObject.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,11 @@ public final void setDict(PDict dict,
184184
dylib.put(this, DICT, dict);
185185
}
186186

187+
@ExportMessage
188+
public final void deleteDict(@Shared("dylib") @CachedLibrary(limit = "4") DynamicObjectLibrary dylib) {
189+
dylib.put(this, DICT, null);
190+
}
191+
187192
/* needed for some guards in exported messages of subclasses */
188193
public static int getCallSiteInlineCacheMaxDepth() {
189194
return PythonOptions.getCallSiteInlineCacheMaxDepth();

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/PythonObjectLibrary.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ public void setDict(Object receiver, PDict dict) throws UnsupportedMessageExcept
121121
throw UnsupportedMessageException.create();
122122
}
123123

124+
/**
125+
* Delete the {@code __dict__} attribute of the object
126+
*/
127+
@Abstract(ifExported = "hasDict")
128+
public void deleteDict(Object receiver) throws UnsupportedMessageException {
129+
throw UnsupportedMessageException.create();
130+
}
131+
124132
/**
125133
* @return the Python type of the receiver
126134
*/

0 commit comments

Comments
 (0)