[pypy-commit] cffi default: Test and fix: Python 3.5 (at least the current beta) is unhappy

arigo noreply at buildbot.pypy.org
Fri Jun 26 23:46:53 CEST 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r2194:9d86b893ad22
Date: 2015-06-26 23:47 +0200
http://bitbucket.org/cffi/cffi/changeset/9d86b893ad22/

Log:	Test and fix: Python 3.5 (at least the current beta) is unhappy with
	module-like objects without a '__name__'

diff --git a/c/lib_obj.c b/c/lib_obj.c
--- a/c/lib_obj.c
+++ b/c/lib_obj.c
@@ -451,6 +451,11 @@
         PyErr_Clear();
         return _lib_dict(lib);
     }
+    /* this hack is for Python 3.5 */
+    if (strcmp(PyText_AsUTF8(name), "__name__") == 0) {
+        PyErr_Clear();
+        return lib_repr(lib);
+    }
     return NULL;
 }
 
diff --git a/testing/cffi1/test_recompiler.py b/testing/cffi1/test_recompiler.py
--- a/testing/cffi1/test_recompiler.py
+++ b/testing/cffi1/test_recompiler.py
@@ -1,3 +1,4 @@
+
 import sys, os, py
 from cffi import FFI, VerificationError
 from cffi import recompiler
@@ -1079,3 +1080,4 @@
     assert MYFOO == 42
     assert hasattr(lib, '__dict__')
     assert lib.__all__ == ['MYFOO', 'mybar']   # but not 'myvar'
+    assert lib.__name__ == repr(lib)


More information about the pypy-commit mailing list