[issue8514] Create fsencode() and fsdecode() functions in os.path

2010-05-07 Thread Gregory P. Smith
Gregory P. Smith g...@krypto.org added the comment: +.. function:: fsencode(value) + + Encode *value* to bytes for use in the file system, environment variables or + the command line. Use :func:`sys.getfilesystemencoding` and + ``'surrogateescape'`` error handler for str, and keep bytes

[issue8514] Create fsencode() and fsdecode() functions in os.path

2010-05-06 Thread STINNER Victor
Changes by STINNER Victor victor.stin...@haypocalc.com: Removed file: http://bugs.python.org/file17096/os_path_fs_encode_decode-3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8514 ___

[issue8514] Create fsencode() and fsdecode() functions in os.path

2010-05-06 Thread STINNER Victor
Changes by STINNER Victor victor.stin...@haypocalc.com: Removed file: http://bugs.python.org/file17154/issue8514.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8514 ___

[issue8514] Create fsencode() and fsdecode() functions in os.path

2010-05-06 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: New short, simple and clean path: add os.fsencode() for Unix only. -- Don't create it for Windows to encourage the usage of unicode on Windows (and use MBCS is a bad idea). fsdecode() was a also bad idea: it's better to keep

[issue8514] Create fsencode() and fsdecode() functions in os.path

2010-05-04 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: I think that fsencode() (and fsdecode()) should be specific to POSIX. I don't know any good reason to encode a nice and correctly encoded unicode string to the ugly MBCS encoding. --

[issue8514] Create fsencode() and fsdecode() functions in os.path

2010-05-03 Thread Marc-Andre Lemburg
Marc-Andre Lemburg m...@egenix.com added the comment: I agree with Martin regarding the os.environ changes. Victor, please open a new ticket for this. Martin: As you probably know, these issues are managed as micro- mailing lists. Discussions on these lists often result in new aspects which

[issue8514] Create fsencode() and fsdecode() functions in os.path

2010-05-03 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: loewis I really, really, REALLY think that it is bad to mix issues. loewis This makes patch review impossible. I tried to, but it looks difficult :-) Anyway, I opened #8603. This specific issue is about introducing an fsdecode and

[issue8514] Create fsencode() and fsdecode() functions in os.path

2010-05-03 Thread Martin v . Löwis
Martin v. Löwis mar...@v.loewis.de added the comment: I think that we cannot decide correctly about fs*code() until we decided for os.environb. Why is that? In msg104063, you claim that you want to create these functions to deal with file names (not environment variables), in msg104064, you

[issue8514] Create fsencode() and fsdecode() functions in os.path

2010-05-03 Thread Martin v . Löwis
Martin v. Löwis mar...@v.loewis.de added the comment: STINNER Victor wrote: STINNER Victor victor.stin...@haypocalc.com added the comment: Why is that? In msg104063, you claim that you want to create these functions to deal with file names (not environment variables) Yes, but my

[issue8514] Create fsencode() and fsdecode() functions in os.path

2010-05-03 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: IIUC, that usage is an equivalent transformation, i.e. the code doesn't change its behavior. It is mere refactorization. I changed os.getenv() to accept byte string key (in a previous commit), but I don't like this hack. If we

[issue8514] Create fsencode() and fsdecode() functions in os.path

2010-05-02 Thread Martin v . Löwis
Martin v. Löwis mar...@v.loewis.de added the comment: I really, really, REALLY think that it is bad to mix issues. This makes patch review impossible. This specific issue is about introducing an fsdecode and fsencode function; this is what the bug title says, and what the initial patch did.

[issue8514] Create fsencode() and fsdecode() functions in os.path

2010-05-01 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: In posixmodule.c, the following snippet doesn't make sense anymore: if (k == NULL) { PyErr_Clear(); continue; } If memory allocation of the bytes object fails, we

[issue8514] Create fsencode() and fsdecode() functions in os.path

2010-04-30 Thread Marc-Andre Lemburg
Marc-Andre Lemburg m...@egenix.com added the comment: STINNER Victor wrote: STINNER Victor victor.stin...@haypocalc.com added the comment: Le lundi 26 avril 2010 13:06:48, vous avez écrit : I don't see what environment variables have to do with the file system. A POSIX system only

[issue8514] Create fsencode() and fsdecode() functions in os.path

2010-04-30 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: Le vendredi 30 avril 2010 15:58:28, vous avez écrit : It's better to let the application decide how to solve this problem and in order to allow for this, the encodings must be adjustable. On POSIX, use byte strings to avoid

[issue8514] Create fsencode() and fsdecode() functions in os.path

2010-04-30 Thread Marc-Andre Lemburg
Marc-Andre Lemburg m...@egenix.com added the comment: STINNER Victor wrote: STINNER Victor victor.stin...@haypocalc.com added the comment: Le vendredi 30 avril 2010 15:58:28, vous avez écrit : It's better to let the application decide how to solve this problem and in order to allow for

[issue8514] Create fsencode() and fsdecode() functions in os.path

2010-04-30 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: No, you store the environment data as bytes and only decode in getenv() ... Yes, this is the best solution for POSIX. We need maybe also a os.getenvb()-bytes function, maybe only on POSIX. But I think that Windows should

[issue8514] Create fsencode() and fsdecode() functions in os.path

2010-04-30 Thread Marc-Andre Lemburg
Marc-Andre Lemburg m...@egenix.com added the comment: STINNER Victor wrote: STINNER Victor victor.stin...@haypocalc.com added the comment: No, you store the environment data as bytes and only decode in getenv() ... Yes, this is the best solution for POSIX. We need maybe also a

[issue8514] Create fsencode() and fsdecode() functions in os.path

2010-04-30 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: Ok, here is a first version of my patch to implement os.environb: - os.environb is the bytes version of os.environ, both are synchronized - os.environ(b).data stores bytes keys and values on POSIX (but unicode on Windows) -

[issue8514] Create fsencode() and fsdecode() functions in os.path

2010-04-26 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: They're also useful for dealing with environment variables which are not strictly filesystem (fs) related but also suffer from the same issue requiring surrogate escape. Yes, Python3 decodes environment variables using

[issue8514] Create fsencode() and fsdecode() functions in os.path

2010-04-26 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: Oh! In Python3, ntpath.expanduser() supports bytes path and uses sys.getfilesystemencoding() to encode an unicode environment variable to a byte string. Should we remove bytes path support in ntpath.expanduser(), or support bytes

[issue8514] Create fsencode() and fsdecode() functions in os.path

2010-04-26 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: Le lundi 26 avril 2010 13:06:48, vous avez écrit : I don't see what environment variables have to do with the file system. A POSIX system only offers *one* function about the encoding: nl_langinfo(CODESET) and Python3 uses it for

[issue8514] Create fsencode() and fsdecode() functions in os.path

2010-04-26 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: Version 3 of the patch: fix also os.getenv() which rejects now bytes on Windows (one of the goals of this issue). -- Added file: http://bugs.python.org/file17096/os_path_fs_encode_decode-3.patch

[issue8514] Create fsencode() and fsdecode() functions in os.path

2010-04-26 Thread STINNER Victor
Changes by STINNER Victor victor.stin...@haypocalc.com: Removed file: http://bugs.python.org/file17082/os_path_fs_encode_decode-2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8514 ___

[issue8514] Create fsencode() and fsdecode() functions in os.path

2010-04-25 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: Update path: rename fs_encode/fs_decode to fsencode/fsdecode. -- title: Create fs_encode() and fs_decode() functions in os.path - Create fsencode() and fsdecode() functions in os.path Added file:

[issue8514] Create fsencode() and fsdecode() functions in os.path

2010-04-25 Thread STINNER Victor
Changes by STINNER Victor victor.stin...@haypocalc.com: Removed file: http://bugs.python.org/file17061/os_path_fs_encode_decode.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8514 ___

[issue8514] Create fsencode() and fsdecode() functions in os.path

2010-04-25 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: Oops, Update path: I mean Update patch ;-) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8514 ___

[issue8514] Create fsencode() and fsdecode() functions in os.path

2010-04-25 Thread Gregory P. Smith
Gregory P. Smith g...@krypto.org added the comment: i'm +0.7 on fsencode/fsdecode going into os.path. My bikeshed 0.7? They're also useful for dealing with environment variables which are not strictly filesystem (fs) related but also suffer from the same issue requiring surrogate escape.