Author: thomas.heller
Date: Fri Jul 13 14:07:59 2007
New Revision: 56344

Modified:
   python/branches/py3k-struni/Lib/ctypes/test/test_bytes.py
   python/branches/py3k-struni/Modules/_ctypes/callproc.c
   python/branches/py3k-struni/Modules/_ctypes/cfield.c
Log:
Do not accept str8 type in function calls any longer.
Accept bytes instead of str8 in the (unexposed in ctypes) BSTR type.

Modified: python/branches/py3k-struni/Lib/ctypes/test/test_bytes.py
==============================================================================
--- python/branches/py3k-struni/Lib/ctypes/test/test_bytes.py   (original)
+++ python/branches/py3k-struni/Lib/ctypes/test/test_bytes.py   Fri Jul 13 
14:07:59 2007
@@ -1,5 +1,6 @@
 """Test where byte objects are accepted"""
 import unittest
+import sys
 from ctypes import *
 
 class BytesTest(unittest.TestCase):
@@ -37,5 +38,14 @@
         X("abc")
         X(b"abc")
 
+    if sys.platform == "win32":
+        def test_BSTR(self):
+            from _ctypes import _SimpleCData
+            class BSTR(_SimpleCData):
+                _type_ = "X"
+
+            BSTR("abc")
+            BSTR(b"abc")
+
 if __name__ == '__main__':
     unittest.main()

Modified: python/branches/py3k-struni/Modules/_ctypes/callproc.c
==============================================================================
--- python/branches/py3k-struni/Modules/_ctypes/callproc.c      (original)
+++ python/branches/py3k-struni/Modules/_ctypes/callproc.c      Fri Jul 13 
14:07:59 2007
@@ -507,15 +507,6 @@
                return 0;
        }
 
-       /* XXX struni remove later */
-       if (PyString_Check(obj)) {
-               pa->ffi_type = &ffi_type_pointer;
-               pa->value.p = PyString_AS_STRING(obj);
-               Py_INCREF(obj);
-               pa->keep = obj;
-               return 0;
-       }
-
        if (PyBytes_Check(obj)) {
                pa->ffi_type = &ffi_type_pointer;
                pa->value.p = PyBytes_AsString(obj);

Modified: python/branches/py3k-struni/Modules/_ctypes/cfield.c
==============================================================================
--- python/branches/py3k-struni/Modules/_ctypes/cfield.c        (original)
+++ python/branches/py3k-struni/Modules/_ctypes/cfield.c        Fri Jul 13 
14:07:59 2007
@@ -1501,7 +1501,7 @@
        /* convert value into a PyUnicodeObject or NULL */
        if (Py_None == value) {
                value = NULL;
-       } else if (PyString_Check(value)) {
+       } else if (PyBytes_Check(value)) {
                value = PyUnicode_FromEncodedObject(value,
                                                    conversion_mode_encoding,
                                                    conversion_mode_errors);
_______________________________________________
Python-3000-checkins mailing list
Python-3000-checkins@python.org
http://mail.python.org/mailman/listinfo/python-3000-checkins

Reply via email to