[pypy-commit] pypy py3.5: Don't allow passing str to ctypes.c_char or bytes to ctypes.c_wchar

rlamy pypy.commits at gmail.com
Mon Oct 16 11:53:24 EDT 2017


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3.5
Changeset: r92780:09772d33fc36
Date: 2017-10-16 17:50 +0200
http://bitbucket.org/pypy/pypy/changeset/09772d33fc36/

Log:	Don't allow passing str to ctypes.c_char or bytes to ctypes.c_wchar

diff --git a/lib_pypy/_ctypes/primitive.py b/lib_pypy/_ctypes/primitive.py
--- a/lib_pypy/_ctypes/primitive.py
+++ b/lib_pypy/_ctypes/primitive.py
@@ -232,9 +232,6 @@
 
         elif tp == 'u':
             def _setvalue(self, val):
-                if isinstance(val, bytes):
-                    val = val.decode(ConvMode.encoding, ConvMode.errors)
-                # possible if we use 'ignore'
                 if val:
                     self._buffer[0] = val
             def _getvalue(self):
@@ -243,8 +240,6 @@
 
         elif tp == 'c':
             def _setvalue(self, val):
-                if isinstance(val, str):
-                    val = val.encode(ConvMode.encoding, ConvMode.errors)
                 if val:
                     self._buffer[0] = val
             def _getvalue(self):


More information about the pypy-commit mailing list