![]() ![]() So I suspect it’s common to mingw-built software (ripgrep is written in rust). This change would be guaranteed to break at least some people, so the evidence is needed to figure out just how many, and the deprecation plan is needed so we can warn the rest as best as we can (though the fact that some people still haven’t realised that Python 2.7 is unsupported means we’ll never reach everyone). In particular, many libraries are not thoroughly tested with new Python versions before some of their users switch to them. On your earlier point, even very aware developers are caught out frequently by our breaking changes. Your best bet is to pass a command line argument to ask the application to use Unicode and also update the encoding parameter so you can decode it. Similarly for those that agree to use the current console encoding. But there’s no good way to do this in a subprocess call. This is another discussion, but should Python on Windows be updating the manifest of its subprocesses to set the active code-page be the same as the running Python?įor applications that agree to use the active code page to communicate over pipes, they’ll inherit the right thing today. ![]() I’m more comfortable using a Unix environment such as Cygwin, MSYS2 or WSL to run Unix tools: > grep = r'C:\Msys\usr\bin\grep.exe' I’d love to find more modern native builds of the GNU tools for Windows that didn’t have these issues, but I’ve been looking for a long time to no avail Either way, set encoding explicitly to whatever the child process uses. The reliable course with subprocess in Windows is to research exactly which standard I/O coding an application uses by default and what command-line options and environment variables it supports to change the default, such as PYTHONIOENCODING for a child Python process. ![]() That won’t be reliable until the Windows NLS team supports an environment variable, checked at startup, that sets the active codepage to UTF-8. There’s nothing in Windows that’s comparable to the Unix LC_CTYPE environment variable in terms of reliably controlling the standard I/O encoding of child processes. If Python’s defaults are changed in such a way that they can cause silent errors in code that runs subprocesses, then we are not helping our users ![]()
0 Comments
Leave a Reply. |