[pypy-commit] pypy missing-tp_new: show how not all PyTypeObject slots are filled

mattip pypy.commits at gmail.com
Fri Dec 30 04:58:34 EST 2016


Author: Matti Picus <matti.picus at gmail.com>
Branch: missing-tp_new
Changeset: r89273:69d3b2eddefb
Date: 2016-12-28 21:09 +0200
http://bitbucket.org/pypy/pypy/changeset/69d3b2eddefb/

Log:	show how not all PyTypeObject slots are filled

diff --git a/pypy/module/cpyext/test/test_userslots.py b/pypy/module/cpyext/test/test_userslots.py
--- a/pypy/module/cpyext/test/test_userslots.py
+++ b/pypy/module/cpyext/test/test_userslots.py
@@ -76,7 +76,7 @@
                  PyObject *obj = PyTuple_GET_ITEM(args, 1);
                  if (!type->tp_str)
                  {
-                     PyErr_SetNone(PyExc_ValueError);
+                     PyErr_SetString(PyExc_ValueError, "no tp_str");
                      return NULL;
                  }
                  return type->tp_str(obj);
@@ -91,5 +91,8 @@
             def __str__(self):
                 return "more text"
         assert module.tp_str(int, D(42)) == "42"
+        class A(object):
+            pass
+        s = module.tp_str(type(A()), A())
+        assert 'A object' in s
 
-        


More information about the pypy-commit mailing list