On 16 July 2013 16:22, Paul Moore <p.f.mo...@gmail.com> wrote: > On 16 July 2013 16:09, Oscar Benjamin <oscar.j.benja...@gmail.com> wrote: > >> However, if you also want the program name to be invokable from e.g. >> subprocess with shell=False or from git-bash or Cygwin or many other >> things then neither .bat files nor PATHEXT are sufficient. Wrapper >> .exes are necessary to ensure that this works properly. > > Yes. I have been convinced that ultimately, wrapper exes are the only > "transparent" means of writing command-line applications on Windows. > > Because of this, I'd quite like it if wrapper functionality were added to > the py launcher (most of the functionality is already present, it would > probably be a pretty small change) so that we had a "one obvious way" of > writing wrappers. I may try to put together a patch for CPython to this > effect...
I don't know whether or not you intend to have wrappers also work for Python 2.7 (in a third-party package perhaps) but there is a slightly subtle point to watch out for when non-ASCII characters in sys.argv come into play. Python 2.x uses GetCommandLineA and 3.x uses GetCommandLineW. A wrapper to launch 2.x should use GetCommandLineA and CreateProcessA to ensure that the 8-bit argument strings are passed through unaltered. To launch 3.x it should use the W versions. If not then the MSVC runtime (or the OS?) will convert between the 8-bit and 16-bit encodings using its own lossy routines. Oscar _______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig