[issue8603] Create a bytes version of os.environ and getenvb()

2010-09-10 Thread STINNER Victor
STINNER Victor added the comment: > If you still consider that the change on .data as a bug, > I think that the fix is to remove .data (mark it as > protected: environ.data => environ._data). r84690 marks os.environ.data as protected. Close this issue again. -- status: open -> closed

[issue8603] Create a bytes version of os.environ and getenvb()

2010-07-29 Thread STINNER Victor
STINNER Victor added the comment: Le jeudi 29 juillet 2010 03:00:03, Ezio Melotti a écrit : > FWIW os.environb is missing from os.__all__. Fixed by r83237 -- ___ Python tracker

[issue8603] Create a bytes version of os.environ and getenvb()

2010-07-29 Thread STINNER Victor
STINNER Victor added the comment: Le jeudi 29 juillet 2010 03:08:27, Ezio Melotti a écrit : > A quick search[0] also shows that environ.data is used by several projects. _Environ is a wrapper on data: call putenv() when a value is changed and unputenv() when a value is removed. Since os.enviro

[issue8603] Create a bytes version of os.environ and getenvb()

2010-07-29 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Ezio Melotti wrote: > > Ezio Melotti added the comment: > > A quick search[0] also shows that environ.data is used by several projects. > Changing it from str to bytes will most likely break these programs, so I'm > not sure it's a good idea. > Also, if

[issue8603] Create a bytes version of os.environ and getenvb()

2010-07-28 Thread Ezio Melotti
Ezio Melotti added the comment: A quick search[0] also shows that environ.data is used by several projects. Changing it from str to bytes will most likely break these programs, so I'm not sure it's a good idea. Also, if I understand correctly, on Windows os.environ.data still contains str, so

[issue8603] Create a bytes version of os.environ and getenvb()

2010-07-28 Thread Ezio Melotti
Ezio Melotti added the comment: FWIW os.environb is missing from os.__all__. -- stage: -> committed/rejected type: -> feature request ___ Python tracker ___ ___

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-06 Thread STINNER Victor
STINNER Victor added the comment: Commited as r80885 (py3k), blocked in 3.1 (r80886). Thank you Martin and Marc for your great help and all your reviews ;-) -- resolution: -> fixed status: open -> closed ___ Python tracker

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-06 Thread STINNER Victor
Changes by STINNER Victor : Removed file: http://bugs.python.org/file17199/os_environb-2.patch ___ Python tracker ___ ___ Python-bugs-list mail

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-06 Thread STINNER Victor
Changes by STINNER Victor : Removed file: http://bugs.python.org/file17191/os_environb.patch ___ Python tracker ___ ___ Python-bugs-list mailin

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-06 Thread STINNER Victor
STINNER Victor added the comment: Oh no, I forgot to remove the annotations from getenv() and getenvb() in os.py. I only removed them from the documentation. -- ___ Python tracker _

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-06 Thread STINNER Victor
STINNER Victor added the comment: Patch version 3: - update posix documentation - improve os.environ and os.getenv() documentation: specify the type and document the encoding/error handler, add a link to environb/getenvb - os.environ and os.environb now check the argument types (raise a bett

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-06 Thread STINNER Victor
STINNER Victor added the comment: Aaaah, *posix*.environ, not *os*.environ, ok. I will fix posix documentation. I didn't knew this dictionary :-) -- ___ Python tracker ___ _

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-05 Thread Martin v . Löwis
Martin v. Löwis added the comment: >> I notice an incompatible change: posix.environ has now a >> different element type. This is probably fine. > > I don't understand, what is an "element type"? In a container, the contents is sometimes called "elements"; their type is the element type. Curre

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-05 Thread STINNER Victor
STINNER Victor added the comment: > I notice an incompatible change: posix.environ has now a > different element type. This is probably fine. I don't understand, what is an "element type"? -- ___ Python tracker __

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-05 Thread STINNER Victor
STINNER Victor added the comment: > There is a couple of white-space only changes in the patch; > it would be good if you could reduce them. "When two paths open to you, you should always choose the most difficult" (in french: "Quand deux chemins s'ouvrent à nous, il faut toujours choisir le

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-05 Thread Martin v . Löwis
Martin v. Löwis added the comment: > @loewis: So do you agree to add os.environb and os.getenvb()? I agree with the patch (-2) in principle. I think the error handling needs to improve: py> os.getenvb('PATH') Traceback (most recent call last): File "", line 1, in File "/home/martin/work/3

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-05 Thread STINNER Victor
STINNER Victor added the comment: MaL> Patch looks good. +1 on adding it. Cool. I didn't understood if MvL is +1, but at least he's not -1 on this, and we are at least two at +1 :-) MaL> One nit: I'd rename the keymap function to encodekey. Ok, I will also change that in the final patch. --

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-05 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: STINNER Victor wrote: > > The documentation of os.environb and os.getenvb() in my last patch is very > short. I'm not inspired. > > We told me on IRC to not use function annotations because annotation semantic > was not decided yet. > > I will try to im

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-04 Thread STINNER Victor
STINNER Victor added the comment: @loewis: So do you agree to add os.environb and os.getenvb()? The documentation of os.environb and os.getenvb() in my last patch is very short. I'm not inspired. We told me on IRC to not use function annotations because annotation semantic was not decided ye

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-04 Thread STINNER Victor
STINNER Victor added the comment: New version of my patch, which looks much better. Summary: Issue #8603: Create os.environb and os.getenvb() on POSIX system. os.unsetenv() encodes str argument using file system encoding and surrogateescape error handler (instead of utf8/strict), and acce

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-04 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Martin v. Löwis wrote: > > Martin v. Löwis added the comment: > >> Your name will end up being partially escaped as surrogate: >> >> 'L\udcf6wis' >> >> Further processing will fail > > That depends on the further processing, no? > >> Traceback (most rec

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-03 Thread Martin v . Löwis
Martin v. Löwis added the comment: > I think that a developer will only switch to os.getenvb() if he/she > has troubles with the encodings. That's indeed a positive feature of this proposed change. -- ___ Python tracker

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-03 Thread STINNER Victor
STINNER Victor added the comment: > I also worry that people won't get it right any better than Python (...) Developers coming from Python2 will continue to use os.getenv() and will not worry about encoding, and maybe not notice that the result is now unicode (and not more a byte string). I

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-03 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Martin v. Löwis wrote: > > Martin v. Löwis added the comment: > >> Here's one (RFC 3875, sections 4.1.7 and 4.1.5): >> >> LANG = 'en_US.utf8' >> CONTENT_TYPE = 'application/x-www-form-urlencoded' >> QUERY_STRING = 'type=example&name=Löwis' >> PATH_INFO =

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-03 Thread Martin v . Löwis
Martin v. Löwis added the comment: > Using os.getenvb(), you can decode the string using the right > encoding (which may be different for each variable). Ok. If that's the motivation, the documentation should make that clear (there isn't any documentation in the patch, anyway). I'm worried that

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-03 Thread STINNER Victor
STINNER Victor added the comment: > Can somebody please explain what problem is being solved with this patch? The problem is that we don't have reliable algorithm to get the encoding of each environment variable. We cannot ensure that all variables are encoded "correctly". Using os.getenvb()

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-03 Thread Martin v . Löwis
Martin v. Löwis added the comment: > Your name will end up being partially escaped as surrogate: > > 'L\udcf6wis' > > Further processing will fail That depends on the further processing, no? > Traceback (most recent call last): > File "", line 1, in > UnicodeEncodeError: 'latin-1' codec c

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-03 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Martin v. Löwis wrote: > > Martin v. Löwis added the comment: > >> Set your CODESET to ASCII and watch the surrogate escaping >> begin... seriously, Martin, if you've ever worked with CGI >> or WSGI or FastCGI or SCGI or any of the many other protocols >>

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-03 Thread Martin v . Löwis
Martin v. Löwis added the comment: > Here's one (RFC 3875, sections 4.1.7 and 4.1.5): > > LANG = 'en_US.utf8' > CONTENT_TYPE = 'application/x-www-form-urlencoded' > QUERY_STRING = 'type=example&name=Löwis' > PATH_INFO = '/home/löwis/bin/mycgi.py' > > (HTML uses Latin-1 as default encoding and

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-03 Thread Martin v . Löwis
Martin v. Löwis added the comment: > Set your CODESET to ASCII and watch the surrogate escaping > begin... seriously, Martin, if you've ever worked with CGI > or WSGI or FastCGI or SCGI or any of the many other protocols > that use the OS environment for passing data between processes, > it does

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-03 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Martin v. Löwis wrote: > > Martin v. Löwis added the comment: > >> Please see the discussion on http://bugs.python.org/issue8514 >> for details. > > I can't see any report of actual breakage in that report, only claims of > potential breakage (with no su

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-03 Thread Martin v . Löwis
Martin v. Löwis added the comment: > An issue was opened 2 years ago: "It was brought up in a discussion > of sending non-ASCii data to a CGI-WSGI script where the data would > be transferred via os.environ." => #4006 (closed as "wont fix"). Fortunately, that issue could now be reconsidered as

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-03 Thread STINNER Victor
STINNER Victor added the comment: An issue was opened 2 years ago: "It was brought up in a discussion of sending non-ASCii data to a CGI-WSGI script where the data would be transferred via os.environ." => #4006 (closed as "wont fix"). -- ___ Python

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-03 Thread Martin v . Löwis
Martin v. Löwis added the comment: > Please see the discussion on http://bugs.python.org/issue8514 > for details. I can't see any report of actual breakage in that report, only claims of potential breakage (with no supporting examples) -- ___ Python

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-03 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Martin v. Löwis wrote: > > Martin v. Löwis added the comment: > > Can somebody please explain what problem is being solved with this patch? The way os.environ is currently set up on Unix breaks applications using the environment to pass data to helper ap

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-03 Thread Martin v . Löwis
Martin v. Löwis added the comment: Can somebody please explain what problem is being solved with this patch? -- ___ Python tracker ___ ___

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-03 Thread STINNER Victor
STINNER Victor added the comment: > The patch is also missing code which keeps the two dictionaries in > sync. If os.environ changes, os.environb would have to change as > well. No, it doesn't :-) os.environ and os.environb are synchronized and there is a test for this! ;-) I will see later f

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-03 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: A view comments on the patch: +def __init__(self, data, encodekey, decodekey, encodevalue, decodevalue, putenv, unsetenv): As general guideline: When adding new parameter, please add them to the end of the parameter list and preferably with a default

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-03 Thread STINNER Victor
STINNER Victor added the comment: The patch creates also fsencode()/fsdecode() functions proposed in #8514: I can rename them to use protected name (eg. "_encodeenv" and "_decodeenv") until we decided for these functions. -- ___ Python tracker

[issue8603] Create a bytes version of os.environ and getenvb()

2010-05-03 Thread STINNER Victor
New submission from STINNER Victor : As discussed in issue #8514, I propose a bytes version of os.envionb which would be synchronized with os.environ (which is possible thanks to surrogateescape error handler). I also propose a os.getenvb()->bytes function. I don't know yet if it's a good ide