Author: Amaury Forgeot d'Arc <[email protected]>
Branch: py3k
Changeset: r59098:1d2839de050d
Date: 2012-11-27 23:32 +0100
http://bitbucket.org/pypy/pypy/changeset/1d2839de050d/
Log: Fix most remaining failures in test_typeobject.py
diff --git a/pypy/module/cpyext/test/_sre.c b/pypy/module/cpyext/test/_sre.c
--- a/pypy/module/cpyext/test/_sre.c
+++ b/pypy/module/cpyext/test/_sre.c
@@ -3882,7 +3882,19 @@
{NULL, NULL}
};
-PyMODINIT_FUNC init_sre(void)
+static struct PyModuleDef sremodule = {
+ PyModuleDef_HEAD_INIT,
+ "_" SRE_MODULE,
+ NULL,
+ -1,
+ _functions,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+PyMODINIT_FUNC PyInit__sre(void)
{
PyObject* m;
PyObject* d;
@@ -3891,11 +3903,11 @@
/* Patch object types */
if (PyType_Ready(&Pattern_Type) || PyType_Ready(&Match_Type) ||
PyType_Ready(&Scanner_Type))
- return;
-
- m = Py_InitModule("_" SRE_MODULE, _functions);
+ return NULL;
+
+ m = PyModule_Create(&sremodule);
if (m == NULL)
- return;
+ return NULL;
d = PyModule_GetDict(m);
x = PyLong_FromLong(SRE_MAGIC);
@@ -3915,6 +3927,7 @@
PyDict_SetItemString(d, "copyright", x);
Py_DECREF(x);
}
+ return m;
}
#endif /* !defined(SRE_RECURSIVE) */
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
@@ -86,22 +86,32 @@
};
-void initcomparisons(void)
+static struct PyModuleDef moduledef = {
+ PyModuleDef_HEAD_INIT,
+ "comparisons",
+ "Module Doc",
+ -1,
+ NULL
+};
+
+
+PyObject *PyInit_comparisons(void)
{
PyObject *m, *d;
if (PyType_Ready(&CmpType) < 0)
- return;
+ return NULL;
if (PyType_Ready(&OldCmpType) < 0)
- return;
- m = Py_InitModule("comparisons", NULL);
+ return NULL;
+ m = PyModule_Create(&moduledef);
if (m == NULL)
- return;
+ return NULL;
d = PyModule_GetDict(m);
if (d == NULL)
- return;
+ return NULL;
if (PyDict_SetItemString(d, "CmpType", (PyObject *)&CmpType) < 0)
- return;
+ return NULL;
if (PyDict_SetItemString(d, "OldCmpType", (PyObject *)&OldCmpType) < 0)
- return;
+ return NULL;
+ return m;
}
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
@@ -632,9 +632,17 @@
};
+static struct PyModuleDef moduledef = {
+ PyModuleDef_HEAD_INIT,
+ "foo",
+ "Module Doc",
+ -1,
+ &foo_functions
+};
+
/* Initialize this module. */
-void initfoo(void)
+PyObject *PyInit_foo(void)
{
PyObject *m, *d;
@@ -645,38 +653,39 @@
MetaType.tp_base = &PyType_Type;
if (PyType_Ready(&footype) < 0)
- return;
+ return NULL;
if (PyType_Ready(&UnicodeSubtype) < 0)
- return;
+ return NULL;
if (PyType_Ready(&UnicodeSubtype2) < 0)
- return;
+ return NULL;
if (PyType_Ready(&MetaType) < 0)
- return;
+ return NULL;
if (PyType_Ready(&InitErrType) < 0)
- return;
+ return NULL;
if (PyType_Ready(&SimplePropertyType) < 0)
- return;
+ return NULL;
CustomType.ob_type = &MetaType;
if (PyType_Ready(&CustomType) < 0)
- return;
- m = Py_InitModule("foo", foo_functions);
+ return NULL;
+ m = PyModule_Create(&moduledef);
if (m == NULL)
- return;
+ return NULL;
d = PyModule_GetDict(m);
if (d == NULL)
- return;
+ return NULL;
if (PyDict_SetItemString(d, "fooType", (PyObject *)&footype) < 0)
- return;
+ return NULL;
if (PyDict_SetItemString(d, "UnicodeSubtype", (PyObject *)
&UnicodeSubtype) < 0)
- return;
+ return NULL;
if (PyDict_SetItemString(d, "UnicodeSubtype2", (PyObject *)
&UnicodeSubtype2) < 0)
- return;
+ return NULL;
if (PyDict_SetItemString(d, "MetaType", (PyObject *) &MetaType) < 0)
- return;
+ return NULL;
if (PyDict_SetItemString(d, "InitErrType", (PyObject *) &InitErrType) < 0)
- return;
+ return NULL;
if (PyDict_SetItemString(d, "Property", (PyObject *) &SimplePropertyType)
< 0)
- return;
+ return NULL;
if (PyDict_SetItemString(d, "Custom", (PyObject *) &CustomType) < 0)
- return;
+ return NULL;
+ return m;
}
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
@@ -504,7 +504,7 @@
return NULL;
IntLike_Type.tp_as_number = &intlike_as_number;
- intlike_as_number.nb_nonzero = intlike_nb_nonzero;
+ intlike_as_number.nb_bool = intlike_nb_bool;
if (PyType_Ready(&IntLike_Type) < 0) return NULL;
intObj = PyObject_New(IntLikeObject, &IntLike_Type);
if (!intObj) {
@@ -522,7 +522,7 @@
} IntLikeObject;
static int
- intlike_nb_nonzero(IntLikeObject *v)
+ intlike_nb_bool(IntLikeObject *v)
{
if (v->value == -42) {
PyErr_SetNone(PyExc_ValueError);
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit