[New-bugs-announce] [issue8017] c_char_p.value does not return a bytes object in Windows.
DavidCzech
report at bugs.python.org
Thu Feb 25 06:11:41 CET 2010
New submission from DavidCzech <davidczech510 at gmail.com>:
c_char_p.value doesn't return a bytes object on Windows.
http://docs.python.org/3.1/library/ctypes.html#fundamental-data-types states that c_char_p is either a "bytes object or None" in Python, not str.
----------
test_c_bug.py
----------
import ctypes
test_string = ctypes.c_char_p("This Is a test string, that should be of type bytes")
print (test_string.value)
print ("Typeof test_string {}",type(test_string))
print ("Typeof test_string {}",type(test_string.value))
assert(type(test_string.value) == bytes)
-----------------
Windows Xp 5.1 SP3
Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit (Intel)] on win32
-----------------
C:\>python test_c_bug.py
This Is a test string, that should be of type bytes
Typeof test_string {} <class 'ctypes.c_char_p'>
Typeof test_string {} <class 'str'>
Traceback (most recent call last):
File "test_c_bug.py", line 9, in <module>
assert(type(test_string.value) == bytes)
AssertionError
-----------------
Ubuntu 9.10 Karmic
Python 3.1.1+ (r311:74480, Nov 2 2009, 14:49:22)
[GCC 4.4.1] on linux2
-----------------
david at Waldorf:~/dev/gtype/gtypes$ python3 test_c_bug.py
b'This Is a test string, that should be of type bytes'
Typeof test_string {} <class 'ctypes.c_char_p'>
Typeof test_string {} <class 'bytes'>
----------
assignee: theller
components: ctypes
files: test_c_bug.py
messages: 100084
nosy: DavidCzech, theller
severity: normal
status: open
title: c_char_p.value does not return a bytes object in Windows.
type: behavior
versions: Python 3.1
Added file: http://bugs.python.org/file16368/test_c_bug.py
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8017>
_______________________________________
More information about the New-bugs-announce
mailing list