On Thu, Oct 13, 2016 at 9:45 PM, Irmen de Jong <irmen.nos...@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
> 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
> (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 . 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:
00000000`52c89bd4 ff15def80200 call qword ptr
0:000> du @rdx
000001d9`c334aee0 ">>> "
0:000> r r8
0:000> dw @rdx l5
000001d9`c334aee0 003e 003e 003e 0020 0000
It's a simple fix. Just use (wlen - 1) instead of wlen.