classification
Title: memmove fails with unicode strings
Type: behavior Stage: resolved
Components: ctypes Versions: Python 2.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: theller Nosy List: eric.smith, theller, verigak
Priority: normal Keywords:

Created on 2009-08-16 21:32 by verigak, last changed 2009-08-17 01:17 by eric.smith. This issue is now closed.

Messages (3)
msg91644 - (view) Author: Giorgos Verigakis (verigak) Date: 2009-08-16 21:32
A demonstration:

>>> buf = create_string_buffer('______')
>>> memmove(buf, 'SPAM', 4)
614584
>>> buf.raw
'SPAM__\x00'

>>> buf = create_string_buffer('______')
>>> memmove(buf, u'SPAM', 4)
614672
>>> buf.raw
'S\x00\x00\x00__\x00'

FWIW memmove fails in Python 3.0 too.
msg91645 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2009-08-16 21:42
What platform is this on? For a ucs4 platform, that is what I'd expect
the result to be. Check sys.maxunicode to see if you have a ucs2 or ucs4
build.

What do you expect as the result?

Remember that memmove takes a count of bytes, not a character count.
msg91654 - (view) Author: Giorgos Verigakis (verigak) Date: 2009-08-16 23:46
Yes, you are right. I thought that the different behavior was weird. Sorry 
this is not a bug.
History
Date User Action Args
2009-08-17 01:17:01eric.smithsetresolution: not a bug
stage: resolved
2009-08-16 23:46:48verigaksetstatus: open -> closed

messages: + msg91654
2009-08-16 21:42:41eric.smithsetnosy: + eric.smith
messages: + msg91645
2009-08-16 21:32:52verigakcreate