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

2010-05-07 Thread Gregory P. Smith
Gregory P. Smith 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 unchanged. I'd w

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

2010-05-06 Thread STINNER Victor
STINNER Victor 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 bytes unchanged on Unix, and it's

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

2010-05-06 Thread STINNER Victor
Changes by STINNER Victor : Removed file: http://bugs.python.org/file17154/issue8514.patch ___ Python tracker ___ ___ Python-bugs-list mailing

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

2010-05-06 Thread STINNER Victor
Changes by STINNER Victor : Removed file: http://bugs.python.org/file17096/os_path_fs_encode_decode-3.patch ___ Python tracker ___ ___ Python-b

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

2010-05-04 Thread STINNER Victor
STINNER Victor 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". -- ___ Python tracker

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

2010-05-03 Thread STINNER Victor
STINNER Victor 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 have os.environb, os.getenv()

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

2010-05-03 Thread Martin v . Löwis
Martin v. Löwis added the comment: STINNER Victor wrote: > STINNER Victor 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 os_path_fs_encode_decode-3.patch uses it in get

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

2010-05-03 Thread STINNER Victor
STINNER Victor 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 os_path_fs_encode_decode-3.patch uses it in getenv() which is maybe a bad idea: os.environb may avoid this. > in m

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

2010-05-03 Thread Martin v . Löwis
Martin v. Löwis 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 claim that #8513

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

2010-05-03 Thread STINNER Victor
STINNER Victor 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 fsencode > function; thi

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

2010-05-03 Thread Marc-Andre Lemburg
Marc-Andre Lemburg 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 then drift off to n

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

2010-05-02 Thread Martin v . Löwis
Martin v. Löwis 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. Whether or not byte

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

2010-05-01 Thread Antoine Pitrou
Antoine Pitrou 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 should error out.

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

2010-04-30 Thread STINNER Victor
STINNER Victor 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) - create os.getenvb()->bytes - os.e

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

2010-04-30 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: STINNER Victor wrote: > > STINNER Victor 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

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

2010-04-30 Thread STINNER Victor
STINNER Victor 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 continue to use unicode environme

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

2010-04-30 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: STINNER Victor wrote: > > STINNER Victor 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 adjustabl

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

2010-04-30 Thread STINNER Victor
STINNER Victor 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 encoding issues. Examples: su

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

2010-04-30 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: STINNER Victor wrote: > > STINNER Victor 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 encod

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

2010-04-26 Thread STINNER Victor
Changes by STINNER Victor : Removed file: http://bugs.python.org/file17082/os_path_fs_encode_decode-2.patch ___ Python tracker ___ ___ Python-b

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

2010-04-26 Thread STINNER Victor
STINNER Victor 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 ___ Python tracker

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

2010-04-26 Thread STINNER Victor
STINNER Victor 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 the filenames, environment

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

2010-04-26 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: STINNER Victor wrote: > > STINNER Victor 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

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

2010-04-26 Thread STINNER Victor
STINNER Victor 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 in ntpath.fsencode()/.fsdeco

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

2010-04-26 Thread STINNER Victor
STINNER Victor 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 sys.getfilesystemencoding()+surro

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

2010-04-25 Thread Gregory P. Smith
Gregory P. Smith 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. But other than jus

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

2010-04-25 Thread STINNER Victor
STINNER Victor added the comment: Oops, "Update path": I mean "Update patch" ;-) -- ___ Python tracker ___ ___ Python-bugs-list mailin

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

2010-04-25 Thread STINNER Victor
Changes by STINNER Victor : Removed file: http://bugs.python.org/file17061/os_path_fs_encode_decode.patch ___ Python tracker ___ ___ Python-bug

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

2010-04-25 Thread STINNER Victor
STINNER Victor 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: http://bugs.python.org/file17082/os_path_fs_encode_deco