Author: Carl Friedrich Bolz <[email protected]>
Branch: py3.5
Changeset: r88185:abdfa58326a0
Date: 2016-11-07 17:09 +0100
http://bitbucket.org/pypy/pypy/changeset/abdfa58326a0/
Log: fix char result handling in _rawffi (argument handling still needs
thinking)
diff --git a/pypy/module/_rawffi/alt/test/test_funcptr.py
b/pypy/module/_rawffi/alt/test/test_funcptr.py
--- a/pypy/module/_rawffi/alt/test/test_funcptr.py
+++ b/pypy/module/_rawffi/alt/test/test_funcptr.py
@@ -377,7 +377,9 @@
libfoo = CDLL(self.libfoo_name)
my_toupper = libfoo.getfunc('my_toupper', [types.char],
types.char)
- assert my_toupper('c') == 'C'
+ res = my_toupper(b'c')
+ assert type(res) is bytes
+ assert res == b'C'
def test_unichar_args(self):
"""
diff --git a/pypy/module/_rawffi/alt/test/test_struct.py
b/pypy/module/_rawffi/alt/test/test_struct.py
--- a/pypy/module/_rawffi/alt/test/test_struct.py
+++ b/pypy/module/_rawffi/alt/test/test_struct.py
@@ -183,8 +183,8 @@
assert struct.getfield('ulong') == sys.maxsize*2 + 1
struct.setfield('ulong', sys.maxsize*2 + 2)
assert struct.getfield('ulong') == 0
- struct.setfield('char', 'a')
- assert struct.getfield('char') == 'a'
+ struct.setfield('char', b'a')
+ assert struct.getfield('char') == b'a'
struct.setfield('unichar', '\u1234')
assert struct.getfield('unichar') == '\u1234'
struct.setfield('ptr', -1)
diff --git a/pypy/module/_rawffi/alt/type_converter.py
b/pypy/module/_rawffi/alt/type_converter.py
--- a/pypy/module/_rawffi/alt/type_converter.py
+++ b/pypy/module/_rawffi/alt/type_converter.py
@@ -225,7 +225,7 @@
return space.wrap(uintval)
elif w_ffitype.is_char():
ucharval = self.get_char(w_ffitype)
- return space.wrap(chr(ucharval))
+ return space.newbytes(chr(ucharval))
elif w_ffitype.is_unichar():
wcharval = self.get_unichar(w_ffitype)
return space.wrap(unichr(wcharval))
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit