Author: mattip <[email protected]>
Branch: cpyext-ext
Changeset: r83440:250e674e08c8
Date: 2016-03-30 20:08 +0300
http://bitbucket.org/pypy/pypy/changeset/250e674e08c8/
Log: test for PyString_Concat with unicode, passes with -A, we return
NULL
diff --git a/pypy/module/cpyext/test/test_bytesobject.py
b/pypy/module/cpyext/test/test_bytesobject.py
--- a/pypy/module/cpyext/test/test_bytesobject.py
+++ b/pypy/module/cpyext/test/test_bytesobject.py
@@ -1,3 +1,4 @@
+# encoding: utf-8
from rpython.rtyper.lltypesystem import rffi, lltype
from pypy.module.cpyext.test.test_api import BaseApiTest
from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase
@@ -130,15 +131,29 @@
s = module.getstring()
assert s == 'test'
- def test_py_string_as_string(self):
+ def test_manipulations(self):
module = self.import_extension('foo', [
("string_as_string", "METH_VARARGS",
'''
return PyString_FromStringAndSize(PyString_AsString(
PyTuple_GetItem(args, 0)), 4);
'''
- )])
+ ),
+ ("concat", "METH_VARARGS",
+ """
+ PyObject ** v;
+ PyObject * left = PyTuple_GetItem(args, 0);
+ v = &left;
+ PyString_Concat(v, PyTuple_GetItem(args, 1));
+ return *v;
+ """)])
assert module.string_as_string("huheduwe") == "huhe"
+ ret = module.concat('abc', 'def')
+ assert ret == 'abcdef'
+ ret = module.concat('abc', u'def')
+ assert not isinstance(ret, str)
+ assert isinstance(ret, unicode)
+ assert ret == 'abcdef'
def test_py_string_as_string_None(self):
module = self.import_extension('foo', [
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit