[New-bugs-announce] [issue13617] Reject embedded null characters in wchar* strings

STINNER Victor report at bugs.python.org
Sat Dec 17 04:53:42 CET 2011

New submission from STINNER Victor <victor.stinner at haypocalc.com>:

The curses module (only since Python 3.3), locale.strcoll(), locale.strxfrm(), time.strftime() and imp.NullImporter() (only on Windows) accept embedded null characters, whereas they convert the Unicode string to a wide character (wchar_t*) string.

The problem is that the null character truncates the string. Example:

>>> locale.strxfrm('a')
>>> locale.strxfrm('a\0b')

Attached patch fixes these functions. I wrote the patch for Python 3.3.

components: Library (Lib), Unicode
files: embedded_nul.patch
keywords: patch
messages: 149656
nosy: ezio.melotti, haypo
priority: normal
severity: normal
status: open
title: Reject embedded null characters in wchar* strings
versions: Python 3.2, Python 3.3
Added file: http://bugs.python.org/file23984/embedded_nul.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list