[pypy-commit] pypy default: Update to cffi/df807c9701bf.

arigo noreply at buildbot.pypy.org
Thu Dec 27 23:02:03 CET 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r59593:17509fae2f9f
Date: 2012-12-27 23:01 +0100
http://bitbucket.org/pypy/pypy/changeset/17509fae2f9f/

Log:	Update to cffi/df807c9701bf.

diff --git a/pypy/module/_cffi_backend/ctypeenum.py b/pypy/module/_cffi_backend/ctypeenum.py
--- a/pypy/module/_cffi_backend/ctypeenum.py
+++ b/pypy/module/_cffi_backend/ctypeenum.py
@@ -67,7 +67,7 @@
         except OperationError, e:
             if not e.match(space, space.w_TypeError):
                 raise
-        if space.isinstance_w(w_ob, space.w_str):
+        if space.isinstance_w(w_ob, space.w_basestring):
             value = self.convert_enum_string_to_int(space.str_w(w_ob))
             value = r_ulonglong(value)
             misc.write_raw_integer_data(cdata, value, self.size)
@@ -78,11 +78,14 @@
         space = self.space
         return self.convert_enum_string_to_int(space.str_w(w_ob))
 
+    def cast_unicode(self, w_ob):
+        return self.cast_str(w_ob)
+
     def convert_enum_string_to_int(self, s):
         space = self.space
         if s.startswith('#'):
             try:
-                return int(s[1:])     # xxx is it RPython?
+                return int(s[1:])
             except ValueError:
                 raise OperationError(space.w_ValueError,
                                      space.wrap("invalid literal after '#'"))
diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py b/pypy/module/_cffi_backend/test/_backend_test_c.py
--- a/pypy/module/_cffi_backend/test/_backend_test_c.py
+++ b/pypy/module/_cffi_backend/test/_backend_test_c.py
@@ -1309,6 +1309,12 @@
     assert p.a1 == "c"
     e = py.test.raises(TypeError, newp, BStructPtr, [None])
     assert "must be a str or int, not NoneType" in str(e.value)
+    if sys.version_info < (3,):
+        p.a1 = unicode("def")
+        assert p.a1 == "def" and type(p.a1) is str
+        py.test.raises(UnicodeEncodeError, "p.a1 = unichr(1234)")
+        BEnum2 = new_enum_type(unicode("foo"), (unicode('abc'),), (5,))
+        assert string(cast(BEnum2, unicode('abc'))) == 'abc'
 
 def test_enum_overflow():
     for ovf in (2**63, -2**63-1, 2**31, -2**31-1):


More information about the pypy-commit mailing list