Author: Matti Picus <[email protected]>
Branch:
Changeset: r90813:8db3b9a6b0a2
Date: 2017-03-26 20:57 +0300
http://bitbucket.org/pypy/pypy/changeset/8db3b9a6b0a2/
Log: clean up tests, tp_new is set by PyType_Ready
diff --git a/pypy/module/cpyext/test/buffer_test.c
b/pypy/module/cpyext/test/buffer_test.c
--- a/pypy/module/cpyext/test/buffer_test.c
+++ b/pypy/module/cpyext/test/buffer_test.c
@@ -344,7 +344,6 @@
#endif
if (m == NULL)
INITERROR;
- PyMyArrayType.tp_new = PyType_GenericNew;
if (PyType_Ready(&PyMyArrayType) < 0)
INITERROR;
Py_INCREF(&PyMyArrayType);
diff --git a/pypy/module/cpyext/test/comparisons.c
b/pypy/module/cpyext/test/comparisons.c
--- a/pypy/module/cpyext/test/comparisons.c
+++ b/pypy/module/cpyext/test/comparisons.c
@@ -112,8 +112,6 @@
return;
if (PyType_Ready(&OldCmpType) < 0)
return;
- CmpType.tp_new = PyType_GenericNew;
- OldCmpType.tp_new = PyType_GenericNew;
m = Py_InitModule("comparisons", NULL);
if (m == NULL)
return;
diff --git a/pypy/module/cpyext/test/foo.c b/pypy/module/cpyext/test/foo.c
--- a/pypy/module/cpyext/test/foo.c
+++ b/pypy/module/cpyext/test/foo.c
@@ -36,14 +36,14 @@
Py_ssize_t foo_ssizet;
} fooobject;
-static PyTypeObject footype;
+static PyTypeObject fooType;
static fooobject *
newfooobject(void)
{
fooobject *foop;
- foop = PyObject_New(fooobject, &footype);
+ foop = PyObject_New(fooobject, &fooType);
if (foop == NULL)
return NULL;
@@ -194,7 +194,7 @@
PyDoc_STRVAR(foo_doc, "foo is for testing.");
-static PyTypeObject footype = {
+static PyTypeObject fooType = {
PyVarObject_HEAD_INIT(NULL, 0)
"foo.foo", /*tp_name*/
sizeof(fooobject), /*tp_size*/
@@ -706,13 +706,11 @@
if (module == NULL)
INITERROR;
- footype.tp_new = PyType_GenericNew;
-
UnicodeSubtype.tp_base = &PyUnicode_Type;
UnicodeSubtype2.tp_base = &UnicodeSubtype;
MetaType.tp_base = &PyType_Type;
- if (PyType_Ready(&footype) < 0)
+ if (PyType_Ready(&fooType) < 0)
INITERROR;
if (PyType_Ready(&UnicodeSubtype) < 0)
INITERROR;
@@ -725,8 +723,6 @@
if (PyType_Ready(&SimplePropertyType) < 0)
INITERROR;
- SimplePropertyType.tp_new = PyType_GenericNew;
- InitErrType.tp_new = PyType_GenericNew;
Py_TYPE(&CustomType) = &MetaType;
if (PyType_Ready(&CustomType) < 0)
@@ -748,7 +744,7 @@
d = PyModule_GetDict(module);
if (d == NULL)
INITERROR;
- if (PyDict_SetItemString(d, "fooType", (PyObject *)&footype) < 0)
+ if (PyDict_SetItemString(d, "fooType", (PyObject *)&fooType) < 0)
INITERROR;
if (PyDict_SetItemString(d, "UnicodeSubtype", (PyObject *)
&UnicodeSubtype) < 0)
INITERROR;
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
@@ -13,12 +13,12 @@
assert 'foo' in sys.modules
assert "copy" in dir(module.fooType)
obj = module.new()
- print(obj.foo)
+ #print(obj.foo)
assert obj.foo == 42
- print("Obj has type", type(obj))
+ #print("Obj has type", type(obj))
assert type(obj) is module.fooType
- print("type of obj has type", type(type(obj)))
- print("type of type of obj has type", type(type(type(obj))))
+ #print("type of obj has type", type(type(obj)))
+ #print("type of type of obj has type", type(type(type(obj))))
assert module.fooType.__doc__ == "foo is for testing."
def test_typeobject_method_descriptor(self):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit