| Store | Cart

Re: [Python-Dev] Windows: Remove support of bytes filenames in the os module?

From: Victor Stinner <vict...@gmail.com>
Tue, 9 Feb 2016 11:13:58 +0100
Hi,

2016-02-08 18:02 GMT+01:00 Brett Cannon <bre...@python.org>:
> If Unicode string don't work in Python 2 then what is Python 2/3 to do as a> cross-platform solution if we completely remove bytes support in Python 3?> Wouldn't that mean there is no common type between Python 2 & 3 that one can> use which will work with the os module except native strings (which are> difficult to get right)?

IMHO we have to put a line somewhere between Python 2 and Python 3.
For some specific use cases, there is no good solution which works on
both Python versions.

For filenames, there is no simple design on Python 2. bytes is the
natural choice on UNIX, whereas Unicode is preferred on Windows. But
it's difficult to handle two types in the same code base. As a
consequence, most users use bytes on Python 2, which is a bad choice
for Windows...

On Python 3, it's much simpler: always use Unicode. Again, the PEP 383
helps on UNIX.

I wrote a PoC for Mercurial to always use Unicode, but the idea was
rejected since Mercurial must support undecodable filenames on UNIX.
It's possible on Python 3 (str+PEP 383), not on Python 2. I tried to
port Mercurial to Python 3 and use Unicode for filenames in the same
change. It's probably better to do that in two steps: first port to
Python 3, then use Unicode. I guess that the final change is to drop
Python 2? I don't know if it's feasible for Mercurial.

Victor
_______________________________________________
Python-Dev mailing list
Pyth...@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: https://mail.python.org/mailman/options/python-dev/python-dev-ml%40activestate.com

Recent Messages in this Thread
Victor Stinner Feb 08, 2016 02:32 pm
Victor Stinner Feb 08, 2016 02:40 pm
Matthias Bussonnier Feb 08, 2016 04:01 pm
Brett Cannon Feb 08, 2016 05:02 pm
Alexander Walters Feb 08, 2016 05:10 pm
Victor Stinner Feb 09, 2016 10:13 am
Paul Moore Feb 09, 2016 11:35 am
Paul Moore Feb 08, 2016 06:26 pm
Victor Stinner Feb 09, 2016 01:03 pm
Steve Dower Feb 10, 2016 01:37 am
Chris Angelico Feb 10, 2016 01:41 am
Steven DAprano Feb 10, 2016 10:18 am
Victor Stinner Feb 10, 2016 10:37 am
Andrew Barnert via Python-Dev Feb 10, 2016 02:01 am
Steve Dower Feb 10, 2016 02:42 am
Stephen J. Turnbull Feb 10, 2016 04:17 am
Steve Dower Feb 10, 2016 04:40 am
Stephen J. Turnbull Feb 10, 2016 08:00 am
Paul Moore Feb 10, 2016 08:30 am
Victor Stinner Feb 10, 2016 08:45 am
Paul Moore Feb 10, 2016 09:28 am
Stephen J. Turnbull Feb 10, 2016 02:51 pm
Andrew Barnert via Python-Dev Feb 10, 2016 07:56 am
Stephen J. Turnbull Feb 10, 2016 02:50 pm
Chris Barker Feb 08, 2016 08:41 pm
eryk sun Feb 09, 2016 12:37 am
Chris Barker - NOAA Federal Feb 09, 2016 01:57 am
Paul Moore Feb 09, 2016 08:08 am
Stephen J. Turnbull Feb 09, 2016 10:00 am
Victor Stinner Feb 09, 2016 09:21 am
eryk sun Feb 09, 2016 01:27 pm
Victor Stinner Feb 09, 2016 09:22 am
eryk sun Feb 09, 2016 01:33 pm
Serhiy Storchaka Feb 10, 2016 12:41 pm
Messages in this thread