Author: Matti Picus <[email protected]>
Branch: cpyext-subclass-setattr
Changeset: r94215:dc1bf38e9aed
Date: 2018-04-02 14:08 +0300
http://bitbucket.org/pypy/pypy/changeset/dc1bf38e9aed/

Log:    test places that use is_cpytype, reomve noisy print statements

diff --git a/pypy/module/cpyext/test/array.c b/pypy/module/cpyext/test/array.c
--- a/pypy/module/cpyext/test/array.c
+++ b/pypy/module/cpyext/test/array.c
@@ -2523,13 +2523,17 @@
         return NULL;
     }
     tup = PyTuple_New(0);
+    /*
     #ifdef PYPY_VERSION
         printf("calling addattrib pypylink %lu \n", sub->ob_pypy_link);
     #endif
+    */
     res = PyObject_Call(attrib, tup, NULL);
+    /*
     #ifdef PYPY_VERSION
         printf("after addattrib pypylink %lu \n", sub->ob_pypy_link);
     #endif
+    */
     Py_DECREF(attrib);
     if (res == NULL) {
         Py_DECREF(tup);
@@ -2538,12 +2542,14 @@
     }
     Py_DECREF(res);
     for(i=0; i<10; i++) {
+        /*
         #ifdef PYPY_VERSION
             printf("starting loop iteration %d refcnt %lu pypylink %lu \n", i, 
                 sub->ob_refcnt, sub->ob_pypy_link);
         #else
             printf("starting loop iteration %d refcnt %lu\n", i, 
sub->ob_refcnt);
         #endif
+        */
         attrib =  PyObject_GetAttr(sub, attribname);
         if (!attrib || (attrib == Py_None)) {
             PyErr_SetString(PyExc_ValueError,
diff --git a/pypy/module/cpyext/test/test_arraymodule.py 
b/pypy/module/cpyext/test/test_arraymodule.py
--- a/pypy/module/cpyext/test/test_arraymodule.py
+++ b/pypy/module/cpyext/test/test_arraymodule.py
@@ -194,4 +194,7 @@
                 self.attrib = True
         import gc
         module.subclass_with_attribute(Sub, "addattrib", "attrib", gc.collect)
+        if not self.runappdirect:
+            assert Sub.__module__ == 'pypy.module.cpyext.test.test_arraymodule'
+            assert str(Sub) == "<class 
'pypy.module.cpyext.test.test_arraymodule.Sub'>"
         
diff --git a/pypy/module/cpyext/test/test_typeobject.py 
b/pypy/module/cpyext/test/test_typeobject.py
--- a/pypy/module/cpyext/test/test_typeobject.py
+++ b/pypy/module/cpyext/test/test_typeobject.py
@@ -412,33 +412,42 @@
     def test_type_dict(self):
         foo = self.import_module("foo")
         module = self.import_extension('test', [
-           ("hack_tp_dict", "METH_O",
+           ("hack_tp_dict", "METH_VARARGS",
             '''
-                 PyTypeObject *type = args->ob_type;
+                 PyTypeObject *type, *obj;
                  PyObject *a1 = PyLong_FromLong(1);
                  PyObject *a2 = PyLong_FromLong(2);
                  PyObject *value;
+                 PyObject * key;
+                 if (!PyArg_ParseTuple(args, "OO", &obj, &key))
+                     return NULL;
+                 type = obj->ob_type;
 
-                 if (PyDict_SetItemString(type->tp_dict, "a",
+                 if (PyDict_SetItem(type->tp_dict, key,
                          a1) < 0)
                      return NULL;
                  Py_DECREF(a1);
                  PyType_Modified(type);
-                 value = PyObject_GetAttrString((PyObject *)type, "a");
+                 value = PyObject_GetAttr((PyObject *)type, key);
                  Py_DECREF(value);
 
-                 if (PyDict_SetItemString(type->tp_dict, "a",
+                 if (PyDict_SetItem(type->tp_dict, key,
                          a2) < 0)
                      return NULL;
                  Py_DECREF(a2);
                  PyType_Modified(type);
-                 value = PyObject_GetAttrString((PyObject *)type, "a");
+                 value = PyObject_GetAttr((PyObject *)type, key);
                  return value;
              '''
              )
             ])
         obj = foo.new()
-        assert module.hack_tp_dict(obj) == 2
+        assert module.hack_tp_dict(obj, "a") == 2
+        class Sub(foo.fooType):
+            pass
+        obj = Sub()
+        assert module.hack_tp_dict(obj, "b") == 2
+        
 
     def test_tp_descr_get(self):
         module = self.import_extension('foo', [
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to