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)
5528
5528
PyObject *
5529
5529
PyObject_GenericGetDict (PyObject * obj , void * context )
5530
5530
{
5531
+ // GraalPy change: upcall for managed
5532
+ if (points_to_py_handle_space (obj )) {
5533
+ return GraalPyTruffleObject_GenericGetDict (obj );
5534
+ }
5531
5535
PyObject * dict ;
5532
5536
// GraalPy change: we don't have inlined values in managed dict
5533
5537
PyObject * * dictptr = _PyObject_GetDictPtr (obj );
Original file line number Diff line number Diff line change @@ -1595,6 +1595,26 @@ def __hash__(self):
1595
1595
cmpfunc = unhandled_error_compare
1596
1596
)
1597
1597
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
+
1598
1618
1599
1619
class TestPickleNative :
1600
1620
def test_pickle_native (self ):
Original file line number Diff line number Diff line change 126
126
import com .oracle .graal .python .nodes .call .CallNode ;
127
127
import com .oracle .graal .python .nodes .classes .IsSubtypeNode ;
128
128
import com .oracle .graal .python .nodes .object .GetClassNode ;
129
+ import com .oracle .graal .python .nodes .object .GetOrCreateDictNode ;
129
130
import com .oracle .graal .python .nodes .util .CannotCastException ;
130
131
import com .oracle .graal .python .nodes .util .CastToJavaStringNode ;
131
132
import com .oracle .graal .python .nodes .util .CastToTruffleStringNode ;
@@ -739,4 +740,14 @@ static Object dir(Object object,
739
740
return dir .execute (null , inliningTarget , object );
740
741
}
741
742
}
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
+ }
742
753
}
You can’t perform that action at this time.
0 commit comments