Author: Armin Rigo <[email protected]>
Branch: cpyext-ext
Changeset: r83718:33ba697be3c6
Date: 2016-04-17 18:26 +0200
http://bitbucket.org/pypy/pypy/changeset/33ba697be3c6/

Log:    A failing test

diff --git a/pypy/module/cpyext/include/complexobject.h 
b/pypy/module/cpyext/include/complexobject.h
--- a/pypy/module/cpyext/include/complexobject.h
+++ b/pypy/module/cpyext/include/complexobject.h
@@ -6,14 +6,16 @@
 extern "C" {
 #endif
 
-/* fake PyComplexObject so that code that doesn't do direct field access works 
*/
-#define PyComplexObject PyObject
-
 typedef struct Py_complex_t {
     double real;
     double imag;
 } Py_complex;
 
+typedef struct {
+    PyObject_HEAD
+    Py_complex cval;
+} PyComplexObject;
+
 /* generated function */
 PyAPI_FUNC(int) _PyComplex_AsCComplex(PyObject *, Py_complex *);
 PyAPI_FUNC(PyObject *) _PyComplex_FromCComplex(Py_complex *);
diff --git a/pypy/module/cpyext/test/test_complexobject.py 
b/pypy/module/cpyext/test/test_complexobject.py
--- a/pypy/module/cpyext/test/test_complexobject.py
+++ b/pypy/module/cpyext/test/test_complexobject.py
@@ -40,3 +40,16 @@
                  return PyComplex_FromCComplex(c);
              """)])
         assert module.test() == 1.2 + 3.4j
+
+    def test_PyComplex_to_WComplex(self):
+        module = self.import_extension('foo', [
+            ("test", "METH_NOARGS",
+             """
+                 Py_complex c = {1.2, 3.4};
+                 PyObject *obj = PyObject_Malloc(sizeof(PyComplexObject));
+                 obj = PyObject_Init(obj, &PyComplex_Type);
+                 assert(obj != NULL);
+                 ((PyComplexObject *)obj)->cval = c;
+                 return obj;
+             """)])
+        assert module.test() == 1.2 + 3.4j
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to