[ python-Bugs-1646630 ] ctypes.string_at(buf, 0) is seen as zero-terminated-string

SourceForge.net noreply at sourceforge.net
Fri Mar 9 21:23:22 CET 2007


Bugs item #1646630, was opened at 2007-01-28 23:18
Message generated for change (Comment added) made by theller
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1646630&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Extension Modules
Group: Python 2.5
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Johannes Hölzl (johannes)
Assigned to: Thomas Heller (theller)
Summary: ctypes.string_at(buf, 0) is seen as zero-terminated-string

Initial Comment:
ctypes.string_at() interprets size=0 wrong.

When the size argument is 0, ctypes.string_at (and probably wstring_at too) string_at tries to read an zero-terminated string instead of an empty string.

Python 2.5 (r25:51908, Oct  6 2006, 15:22:41) 
[GCC 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import *
>>> bytes = (c_char*3)("1", "2", "\0")
>>> string_at(pointer(bytes))
'12'
>>> string_at(pointer(bytes), 0)
'12'
>>> string_at(pointer(bytes), 1)
'1'

instead of:

>>> string_at(pointer(bytes), 0)
''



----------------------------------------------------------------------

>Comment By: Thomas Heller (theller)
Date: 2007-03-09 21:23

Message:
Logged In: YES 
user_id=11105
Originator: NO

Fixed in rev. 54244 (trunk) and rev. 54246 (release25-maint).

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1646630&group_id=5470


More information about the Python-bugs-list mailing list