[New-bugs-announce] [issue16587] Py_Initialize breaks wprintf on Windows

Markus Kettunen report at bugs.python.org
Sat Dec 1 01:23:52 CET 2012

New submission from Markus Kettunen:

In a C application on Windows, at least on MSVC 2010 and Windows 7, do this:


Output is:
 T e s t

I was able to track the issue to fileio.c to the following code block by searching where wprintf breaks:

    if (dircheck(self, nameobj) < 0)
        goto error;

#if defined(MS_WINDOWS) || defined(__CYGWIN__)
    /* don't translate newlines (\r\n <=> \n) */
    _setmode(self->fd, O_BINARY); <----- breaks it

    if (PyObject_SetAttrString((PyObject *)self, "name", nameobj) < 0)
        goto error;

This can be easily confirmed by adding wprintfs on both sides of _setmode.

This issue was also raised at http://mail.python.org/pipermail/python-list/2012-February/620528.html but no solution was provided back then.

components: IO, Unicode, Windows
messages: 176732
nosy: ezio.melotti, makegho
priority: normal
severity: normal
status: open
title: Py_Initialize breaks wprintf on Windows
type: behavior
versions: Python 3.3

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list