File tree Expand file tree Collapse file tree 3 files changed +35
-0
lines changed
com.oracle.graal.python.cext/src
com.oracle.graal.python.test/src/tests/cpyext
com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -5528,6 +5528,10 @@ _PyObject_FreeInstanceAttributes(PyObject *self)
55285528PyObject *
55295529PyObject_GenericGetDict (PyObject * obj , void * context )
55305530{
5531+ // GraalPy change: upcall for managed
5532+ if (points_to_py_handle_space (obj )) {
5533+ return GraalPyTruffleObject_GenericGetDict (obj );
5534+ }
55315535 PyObject * dict ;
55325536 // GraalPy change: we don't have inlined values in managed dict
55335537 PyObject * * dictptr = _PyObject_GetDictPtr (obj );
Original file line number Diff line number Diff line change @@ -1595,6 +1595,26 @@ def __hash__(self):
15951595 cmpfunc = unhandled_error_compare
15961596 )
15971597
1598+ object_with_attributes = MyObject ()
1599+ object_with_attributes .foo = 1
1600+
1601+ test_PyObject_GenericGetDict = CPyExtFunction (
1602+ lambda args : args [0 ].__dict__ ,
1603+ lambda : (
1604+ (TestObjectFunctions .object_with_attributes ,),
1605+ ),
1606+ code = '''
1607+ static PyObject* wrap_PyObject_GenericGetDict(PyObject* obj) {
1608+ return PyObject_GenericGetDict(obj, NULL);
1609+ }
1610+ ''' ,
1611+ arguments = ["PyObject* obj" ],
1612+ resultspec = "O" ,
1613+ argspec = "O" ,
1614+ callfunction = "wrap_PyObject_GenericGetDict" ,
1615+ cmpfunc = unhandled_error_compare
1616+ )
1617+
15981618
15991619class TestPickleNative :
16001620 def test_pickle_native (self ):
Original file line number Diff line number Diff line change 126126import com .oracle .graal .python .nodes .call .CallNode ;
127127import com .oracle .graal .python .nodes .classes .IsSubtypeNode ;
128128import com .oracle .graal .python .nodes .object .GetClassNode ;
129+ import com .oracle .graal .python .nodes .object .GetOrCreateDictNode ;
129130import com .oracle .graal .python .nodes .util .CannotCastException ;
130131import com .oracle .graal .python .nodes .util .CastToJavaStringNode ;
131132import com .oracle .graal .python .nodes .util .CastToTruffleStringNode ;
@@ -739,4 +740,14 @@ static Object dir(Object object,
739740 return dir .execute (null , inliningTarget , object );
740741 }
741742 }
743+
744+ @ CApiBuiltin (ret = PyObjectTransfer , args = {PyObject }, call = Ignored )
745+ abstract static class PyTruffleObject_GenericGetDict extends CApiUnaryBuiltinNode {
746+ @ Specialization
747+ static Object getDict (Object object ,
748+ @ Bind ("this" ) Node inliningTarget ,
749+ @ Cached GetOrCreateDictNode getDict ) {
750+ return getDict .execute (inliningTarget , object );
751+ }
752+ }
742753}
You can’t perform that action at this time.
0 commit comments