[Python-Dev] Removal of Win32 ANSI API

Nick Coghlan ncoghlan at gmail.com
Thu Nov 11 23:01:32 CET 2010


On Fri, Nov 12, 2010 at 5:26 AM, Victor Stinner
<victor.stinner at haypocalc.com> wrote:
> On Thursday 11 November 2010 17:07:28 Hirokazu Yamamoto wrote:
>> Hello. Is it possible to remove Win32 ANSI API (ie: GetFileAttributesA)
>> and only use Win32 WIDE API (ie: GetFileAttributesW)?
>> Mainly in posixmodule.c.
>
> 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 think we can simplify the code hugely. (This means droping bytes
>> support for os.stat etc on windows)
>
> Sure, it will divide the number of lines, of the code specific to Windows, by
> two.

Can we get most of the code cleanup benefit without the backwards
compatibility risk by doing the decode from 'mbcs' on our side of the
fence?

That is, have code that was the C equivalent of:

arg_is_bytes = not isinstance(arg, str)
if arg_is_bytes:
  val = _decode_mbcs(arg)
  # Decoding error checking here
else:
  val = arg
# Common processing using WIDE API
if arg_is_bytes:
  result = _encode_mbcs(wide_result)
  # Encoding error checking here
else:
  result = wide_result

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-Dev mailing list