[pypy-svn] r73370 - in pypy/branch/cpython-extension/pypy/module/cpyext: . test
agaynor at codespeak.net
agaynor at codespeak.net
Sun Apr 4 19:36:19 CEST 2010
Author: agaynor
Date: Sun Apr 4 19:36:17 2010
New Revision: 73370
Modified:
pypy/branch/cpython-extension/pypy/module/cpyext/object.py
pypy/branch/cpython-extension/pypy/module/cpyext/stubs.py
pypy/branch/cpython-extension/pypy/module/cpyext/test/test_object.py
pypy/branch/cpython-extension/pypy/module/cpyext/test/test_typeobject.py
Log:
Implement PYObject_GetItem.
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/object.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/object.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/object.py Sun Apr 4 19:36:17 2010
@@ -58,3 +58,8 @@
and 0 otherwise. This function always succeeds."""
return int(space.is_true(space.callable(w_obj)))
+ at cpython_api([PyObject, PyObject], PyObject)
+def PyObject_GetItem(space, w_obj, w_key):
+ """Return element of o corresponding to the object key or NULL on failure.
+ This is the equivalent of the Python expression o[key]."""
+ return space.getitem(w_obj, w_key)
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/stubs.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/stubs.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/stubs.py Sun Apr 4 19:36:17 2010
@@ -4616,12 +4616,6 @@
changes in your code for properly supporting 64-bit systems."""
raise NotImplementedError
- at cpython_api([PyObject, PyObject], PyObject)
-def PyObject_GetItem(space, o, key):
- """Return element of o corresponding to the object key or NULL on failure.
- This is the equivalent of the Python expression o[key]."""
- raise NotImplementedError
-
@cpython_api([PyObject, PyObject, PyObject], rffi.INT_real)
def PyObject_SetItem(space, o, key, v):
"""Map the object key to the value v. Returns -1 on failure. This is the
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/test/test_object.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/test/test_object.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/test_object.py Sun Apr 4 19:36:17 2010
@@ -40,3 +40,11 @@
assert api.PyObject_HasAttr(space.wrap(x), space.wrap('test'))
api.PyObject_SetAttr(space.wrap(x), space.wrap('test'), space.wrap(10))
assert x.test == 10
+
+ def test_getitem(self, space, api):
+ w_t = space.wrap((1, 2, 3, 4, 5))
+ assert space.unwrap(api.PyObject_GetItem(w_t, space.wrap(3))) == 4
+
+ w_d = space.newdict()
+ space.setitem(w_d, space.wrap("a key!"), space.wrap(72))
+ assert space.unwrap(api.PyObject_GetItem(w_d, space.wrap("a key!"))) == 72
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/test/test_typeobject.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/test/test_typeobject.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/test_typeobject.py Sun Apr 4 19:36:17 2010
@@ -83,6 +83,5 @@
assert fuu2(u"abc").baz().escape()
def test_sre(self):
- skip("In Progress")
module = self.import_module(name='_sre')
More information about the Pypy-commit
mailing list