Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-26 Thread Martin v. Löwis
> Is it possible a conversion from bytes (ANSI) to unicode fails on > windows? It should fail sometimes, right? Not for windows-1252, but certainly for shift-jis (you know better than me). It seems that whether MultiByteToWideChar will fail depends on whether MB_ERR_INVALID_CHARS is given or not.

Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-26 Thread Hirokazu Yamamoto
On 2010/11/12 1:18, Ulrich Eckhardt wrote: # I recently did it for winsound.PlaySound with MvL's approval Interesting, is there a ticket associate with this? Also, was that on Python 3 or 2? Which commits? Sorry for late posting. Rev 86300 and Issue 6317. _

Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-26 Thread Hirokazu Yamamoto
On 2010/11/14 9:06, Victor Stinner wrote: Yes, but how do you check if the input argument is a bytes or a str object with your PyArg_Parse converter? You should use "O" format and manually convert it to unicode, and then convert the result back to bytes (if the input was bytes). It don't think th

Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-14 Thread Nick Coghlan
On Sun, Nov 14, 2010 at 8:14 PM, "Martin v. Löwis" wrote: > I'm in favor of deprecating it first. Aye. I've made the best case I could for keeping it, and even I don't find it terribly convincing. So deprecation for 3.2 sound like a reasonable option. Regards, Nick. -- Nick Coghlan   |   ncogh

Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-14 Thread Martin v. Löwis
> We should also keep in mind that *Microsoft* have chosen to keep the > bytes Win32 APIs around, despite their flaws, all in the name of > backwards compatibility. Of course, Microsoft is in a different position. If they remove a functionality in some release, their users typically can't go back

Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-14 Thread Martin v. Löwis
> If the code is currently working and isn't a security hole, then we > obviously don't "have to". > Apparently several developers "want to", which is different. In case the motivation for that isn't clear: it would produce a significant code reduction, and therefore ease maintenance. Regards, Ma

Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-13 Thread Nick Coghlan
On Sun, Nov 14, 2010 at 10:19 AM, Antoine Pitrou wrote: > On Sun, 14 Nov 2010 01:06:55 +0100 > Victor Stinner wrote: >> >> The code is currently working. The question is if we have to drop the ANSI >> API >> now, later or never. > > If the code is currently working and isn't a security hole, the

Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-13 Thread Antoine Pitrou
On Sun, 14 Nov 2010 01:06:55 +0100 Victor Stinner wrote: > > The code is currently working. The question is if we have to drop the ANSI > API > now, later or never. If the code is currently working and isn't a security hole, then we obviously don't "have to". Apparently several developers "wan

Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-13 Thread Victor Stinner
On Saturday 13 November 2010 17:21:37 you wrote: > On 2010/11/12 4:26, Victor Stinner 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)?

Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-13 Thread Hirokazu Yamamoto
On 2010/11/12 4:26, Victor Stinner 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 enc

Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-12 Thread Nick Coghlan
On Sat, Nov 13, 2010 at 5:46 AM, "Martin v. Löwis" wrote: >> Ok, good answer. In this case, I vote +1 to remove completly the ANSI version >> from all Python modules. > > I think caution is still necessary. So I propose to deprecate byte > filenames on Windows in 3.2, with removal in 3.3. People w

Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-12 Thread Martin v. Löwis
> Ok, good answer. In this case, I vote +1 to remove completly the ANSI version > from all Python modules. I think caution is still necessary. So I propose to deprecate byte filenames on Windows in 3.2, with removal in 3.3. People who think this is a terrible mistake and breaks there applications

Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-12 Thread Martin v. Löwis
> I'm not talking about Windows obviously. POSIX filenames are natively > bytes, so if you get a bytes filename from an external source, it makes > sense to reuse the bytes form. > > I think it would be a mistake to allow bytes filenames under POSIX but > not under Windows. It makes porting harder

Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-12 Thread Antoine Pitrou
On Fri, 12 Nov 2010 13:13:08 +0100 Victor Stinner wrote: > On Thursday 11 November 2010 21:02:43 Antoine Pitrou wrote: > > On Thu, 11 Nov 2010 20:44:52 +0100 > > > > "Martin v. Löwis" wrote: > > > > How do you support cross-platform code using bytes filenames? > > > > IIRC, it has already been a

Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-12 Thread Victor Stinner
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

Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-12 Thread Victor Stinner
On Thursday 11 November 2010 21:02:43 Antoine Pitrou wrote: > On Thu, 11 Nov 2010 20:44:52 +0100 > > "Martin v. Löwis" wrote: > > > How do you support cross-platform code using bytes filenames? > > > IIRC, it has already been argued that it was an important feature. Many > > > filesystem-related

Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-12 Thread Victor Stinner
On Thursday 11 November 2010 23:01:32 you wrote: > > 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? I crea

Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-12 Thread Martin v. Löwis
> Additionally: > > d) Over a socket (like the HTTP protocol) -> Bytes. Sure. However, you can't really expect that the bytes you receive over the socket are a meaningful filename on your local Windows installation. So it would be a bug in the application to not decode the bytes that you receive

Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-11 Thread André Malo
On Thursday 11 November 2010 20:50:35 Martin v. Löwis 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

Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-11 Thread Nick Coghlan
On Fri, Nov 12, 2010 at 5:26 AM, Victor Stinner 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

Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-11 Thread Antoine Pitrou
On Thu, 11 Nov 2010 20:44:52 +0100 "Martin v. Löwis" wrote: > > How do you support cross-platform code using bytes filenames? > > IIRC, it has already been argued that it was an important feature. Many > > filesystem-related utilities might prefer to handle filenames in bytes > > form. > > It wou

Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-11 Thread Martin v. Löwis
> 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

Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-11 Thread Martin v. Löwis
> How do you support cross-platform code using bytes filenames? > IIRC, it has already been argued that it was an important feature. Many > filesystem-related utilities might prefer to handle filenames in bytes > form. It would be a policy decision. However, I think it is hear-say that filesystem-

Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-11 Thread Victor Stinner
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

Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-11 Thread Antoine Pitrou
On Thu, 11 Nov 2010 16:10:35 + Tim Golden wrote: > On 11/11/2010 16:07, 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. > > I think we can simplify the co

Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-11 Thread Ulrich Eckhardt
On Thursday 11 November 2010, Hirokazu Yamamoto wrote: > Is it possible to remove Win32 ANSI API (ie: GetFileAttributesA) > and only use Win32 WIDE API (ie: GetFileAttributesW)? > Mainly in posixmodule.c. > I think we can simplify the code hugely. +1 MS Windows variants that only support the ANSI

Re: [Python-Dev] Removal of Win32 ANSI API

2010-11-11 Thread Tim Golden
On 11/11/2010 16:07, 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. I think we can simplify the code hugely. (This means droping bytes support for os.stat etc on window

[Python-Dev] Removal of Win32 ANSI API

2010-11-11 Thread Hirokazu Yamamoto
Hello. Is it possible to remove Win32 ANSI API (ie: GetFileAttributesA) and only use Win32 WIDE API (ie: GetFileAttributesW)? Mainly in posixmodule.c. I think we can simplify the code hugely. (This means droping bytes support for os.stat etc on windows) # I recently did it for winsound.PlaySound