[pypy-commit] pypy default: Implement _PyString_Eq()
amauryfa
noreply at buildbot.pypy.org
Sat Jun 4 01:11:10 CEST 2011
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch:
Changeset: r44672:909b0c1c7ecd
Date: 2011-05-27 18:41 +0200
http://bitbucket.org/pypy/pypy/changeset/909b0c1c7ecd/
Log: Implement _PyString_Eq()
diff --git a/pypy/module/cpyext/stringobject.py b/pypy/module/cpyext/stringobject.py
--- a/pypy/module/cpyext/stringobject.py
+++ b/pypy/module/cpyext/stringobject.py
@@ -2,7 +2,7 @@
from pypy.rpython.lltypesystem import rffi, lltype
from pypy.module.cpyext.api import (
cpython_api, cpython_struct, bootstrap_function, build_type_checkers,
- PyObjectFields, Py_ssize_t, CONST_STRING)
+ PyObjectFields, Py_ssize_t, CONST_STRING, CANNOT_FAIL)
from pypy.module.cpyext.pyerrors import PyErr_BadArgument
from pypy.module.cpyext.pyobject import (
PyObject, PyObjectP, Py_DecRef, make_ref, from_ref, track_reference,
@@ -203,6 +203,10 @@
ref[0] = rffi.cast(PyObject, py_newstr)
return 0
+ at cpython_api([PyObject, PyObject], rffi.INT, error=CANNOT_FAIL)
+def _PyString_Eq(space, w_str1, w_str2):
+ return space.eq_w(w_str1, w_str2)
+
@cpython_api([PyObjectP, PyObject], lltype.Void)
def PyString_Concat(space, ref, w_newpart):
"""Create a new string object in *string containing the contents of newpart
diff --git a/pypy/module/cpyext/test/test_stringobject.py b/pypy/module/cpyext/test/test_stringobject.py
--- a/pypy/module/cpyext/test/test_stringobject.py
+++ b/pypy/module/cpyext/test/test_stringobject.py
@@ -283,3 +283,7 @@
self.raises(space, api, TypeError, api.PyString_AsEncodedObject,
space.wrap(2), lltype.nullptr(rffi.CCHARP.TO), lltype.nullptr(rffi.CCHARP.TO)
)
+
+ def test_eq(self, space, api):
+ assert 1 == api._PyString_Eq(space.wrap("hello"), space.wrap("hello"))
+ assert 0 == api._PyString_Eq(space.wrap("hello"), space.wrap("world"))
More information about the pypy-commit
mailing list