[RELEASE] Python 3.6.0b2 is now available

eryk sun eryksun at gmail.com
Thu Oct 13 18:58:26 EDT 2016


On Thu, Oct 13, 2016 at 9:45 PM, Irmen de Jong <irmen.NOSPAM at xs4all.nl> wrote:
>
>>> On 12-10-2016 12:56, Robin Becker wrote:
>>>
>>>> I notice an extra space at the windows command prompt compared with 3.5, is that
>>>> deliberate?
> ....
> Wow that was stupid, sorry. Anyway, I'm not seeing it with 3.6.0b2 either:
>
> Python 3.6.0b2 (v3.6.0b2:b9fadc7d1c3f, Oct 10 2016, 20:36:51) [MSC v.1900 32 bit
> (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import sys
>>>>

I see the problem. In beta 2, PyOS_StdioReadline now decodes the
prompt string as UTF-8 and writes it via WriteConsoleW. This resolves
issue 28333 [1]. In my patch I used the length from strlen(prompt),
which doesn't include the terminating NUL, since it isn't needed when
calling WriteConsoleW. Steve Dower changed this to instead have
MultiByteToWideChar calculate the length, which is fine in itself, but
it does include the trailing NUL. Thus instead of writing ">>> "
(length 4) to the console, it's writing ">>> \x00" (length 5). You can
see this in the debugger when stepping into PyOS_StdioReadline:

    python36!PyOS_StdioReadline+0x14c:
    00000000`52c89bd4 ff15def80200    call    qword ptr
            [python36!_imp_WriteConsoleW (00000000`52cb94b8)]
            ds:00000000`52cb94b8=
                {KERNEL32!WriteConsoleW (00007fff`6d264bc0)}

    0:000> du @rdx
    000001d9`c334aee0  ">>> "
    0:000> r r8
    r8=0000000000000005
    0:000> dw @rdx l5
    000001d9`c334aee0  003e 003e 003e 0020 0000

It's a simple fix. Just use (wlen - 1) instead of wlen.

[1]: http://bugs.python.org/issue28333



More information about the Python-list mailing list