[Python-Dev] Removal of Win32 ANSI API

Victor Stinner victor.stinner at haypocalc.com
Fri Nov 12 13:15:35 CET 2010


On Thursday 11 November 2010 20:50:35 you wrote:
> > Even if I hate the MBCS encoding, because it replaces undecodable
> > characters by similar glyphs by default, I'm not certain that it is a
> > good idea to drop the bytes API. Can it be a problem to port programs
> > from Python2 to Python3? Do major Python2 programs/libraries rely on the
> > bytes API?
> 
> I don't actually know for a fact, but I expect that the answer is "no".
> 
> The questions is: where do file names typically come from? My guess
> is that they come from
> a) hard-coded strings in the source code
> b) command line arguments/environment variables
> c) directory listings
> [of course, there are other ways, like GUI input, getcwd(), etc]
> 
> In case a), you have filenames such as ".", e.g. as a parameter to
> listdir or walk. These will typically be regular strings in Python 2,
> which become Unicode strings in 3. You would actively need to put b""
> prefixes into the code.
> 
> In case b), they will be Unicode strings in Python 3.
> 
> In case c), they will be Unicode strings if the argument is a Unicode
> string. So by induction, file names will be typically unicode. The
> exception will be libraries/applications which make deliberate attempts
> to get byte-oriented file names.

Ok, good answer. In this case, I vote +1 to remove completly the ANSI version 
from all Python modules.

I consider the ANSI version has a compatibility layer for old applications 
written for MS-Dos or early versions of Windows. Even if these APIs are still 
widely used in C/C++ applications, the wide versions should always be 
preferred.

Victor


More information about the Python-Dev mailing list