Author: Matti Picus <[email protected]>
Branch: better-PyDict_Next
Changeset: r88883:e012751a80df
Date: 2016-12-04 22:25 +0200
http://bitbucket.org/pypy/pypy/changeset/e012751a80df/
Log: try to identify and convert a GetSetProperty to a W_GetSetPropertyEx
diff --git a/pypy/module/cpyext/dictobject.py b/pypy/module/cpyext/dictobject.py
--- a/pypy/module/cpyext/dictobject.py
+++ b/pypy/module/cpyext/dictobject.py
@@ -1,4 +1,8 @@
from rpython.rtyper.lltypesystem import rffi, lltype
+from rpython.rlib.objectmodel import specialize
+from pypy.interpreter.error import OperationError
+from pypy.objspace.std.classdict import ClassDictStrategy
+from pypy.interpreter.typedef import GetSetProperty
from pypy.module.cpyext.api import (
cpython_api, CANNOT_FAIL, build_type_checkers, Py_ssize_t,
Py_ssize_tP, CONST_STRING, PyObjectFields, cpython_struct,
@@ -7,8 +11,7 @@
make_typedescr, track_reference, create_ref, from_ref, Py_DecRef,
Py_IncRef)
from pypy.module.cpyext.pyerrors import PyErr_BadInternalCall
-from pypy.interpreter.error import OperationError
-from rpython.rlib.objectmodel import specialize
+from pypy.module.cpyext.typeobject import W_GetSetPropertyEx
PyDictObjectStruct = lltype.ForwardReference()
PyDictObject = lltype.Ptr(PyDictObjectStruct)
@@ -258,6 +261,10 @@
return 0
w_key = space.listview(w_keys)[pos]
w_value = space.getitem(w_dict, w_key)
+ if isinstance(w_value, GetSetProperty):
+ # XXX doesn't quite work, need to convert GetSetProperty
+ # to PyGetSetDef, with c_name, c_get, c_set, c_doc, c_closure
+ w_value = W_GetSetPropertyEx(w_value, w_dict.dstorage._x)
if pkey:
pkey[0] = as_pyobj(space, w_key)
if pvalue:
diff --git a/pypy/module/cpyext/test/test_dictobject.py
b/pypy/module/cpyext/test/test_dictobject.py
--- a/pypy/module/cpyext/test/test_dictobject.py
+++ b/pypy/module/cpyext/test/test_dictobject.py
@@ -1,7 +1,7 @@
import py
from rpython.rtyper.lltypesystem import rffi, lltype
from pypy.module.cpyext.test.test_api import BaseApiTest
-from pypy.module.cpyext.api import Py_ssize_tP, PyObjectP
+from pypy.module.cpyext.api import Py_ssize_tP, PyObjectP, PyTypeObjectPtr
from pypy.module.cpyext.pyobject import make_ref, from_ref
from pypy.interpreter.error import OperationError
from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase
@@ -182,8 +182,8 @@
assert api.PyDictProxy_Check(w_proxy)
def test_typedict(self, space, api):
- py_type = make_ref(space, space.w_type)
- py_dict = py_type.c_ob_type.c_tp_dict
+ py_type = make_ref(space, space.w_int)
+ py_dict = rffi.cast(PyTypeObjectPtr, py_type).c_tp_dict
ppos = lltype.malloc(Py_ssize_tP.TO, 1, flavor='raw')
ppos[0] = 0
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit