[pypy-commit] cffi wchar_t: hg merge default
arigo
noreply at buildbot.pypy.org
Mon Jul 9 16:59:10 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: wchar_t
Changeset: r606:8f96dc63381e
Date: 2012-07-09 16:03 +0200
http://bitbucket.org/cffi/cffi/changeset/8f96dc63381e/
Log: hg merge default
diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -1162,7 +1162,7 @@
else if (cd->c_type->ct_flags & CT_IS_ENUM)
return convert_to_object(cd->c_data, cd->c_type);
else
- return cdata_repr(cd);
+ return Py_TYPE(cd)->tp_repr((PyObject *)cd);
}
#ifdef HAVE_WCHAR_H
@@ -1694,9 +1694,12 @@
bad_number_of_arguments:
{
- PyObject *s = cdata_repr(cd);
- PyErr_Format(PyExc_TypeError, errormsg,
- PyString_AsString(s), nargs_declared, nargs);
+ PyObject *s = Py_TYPE(cd)->tp_repr((PyObject *)cd);
+ if (s != NULL) {
+ PyErr_Format(PyExc_TypeError, errormsg,
+ PyString_AS_STRING(s), nargs_declared, nargs);
+ Py_DECREF(s);
+ }
goto error;
}
diff --git a/c/test_c.py b/c/test_c.py
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -293,8 +293,11 @@
py.test.raises(TypeError, "p[0]")
def test_default_str():
- p = new_primitive_type("int")
- x = cast(p, 42)
+ BInt = new_primitive_type("int")
+ x = cast(BInt, 42)
+ assert str(x) == repr(x)
+ BArray = new_array_type(new_pointer_type(BInt), 10)
+ x = newp(BArray, None)
assert str(x) == repr(x)
def test_cast_from_cdataint():
@@ -847,6 +850,8 @@
assert f(-142) == -141
assert repr(f).startswith(
"<cdata 'int(*)(int)' calling <function cb at 0x")
+ e = py.test.raises(TypeError, f)
+ assert str(e.value) == "%r expects 1 arguments, got 0" % (f,)
def test_callback_return_type():
for rettype in ["signed char", "short", "int", "long", "long long",
More information about the pypy-commit
mailing list