[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-porting
Subject:    Re: [Python-porting] Text version of os.environ for six?
From:       Benjamin Peterson <benjamin () python ! org>
Date:       2018-08-08 4:43:31
Message-ID: 1533703411.3920093.1467059248.59F44EE1 () webmail ! messagingengine ! com
[Download RAW message or body]



On Wed, Jul 25, 2018, at 11:05, Toshio Kuratomi wrote:
> Hey al ( benjaminp in particular ;-),
> 
> Today, in my project, I had a need for reading some environment values
> as text strings.  This is automatic in Python3 but in Python2 the
> values are byte strings.  I wrote a little proxy class to do this:
> https://gist.github.com/abadger/6c873f999649a0be0e6ce5a96690ec6f#file-gistfile1-txt-L9
>  
> I was wondering if this is something that would be worthwhile to
> contribute to six?  If so, what requirements would be wanted?  Things
> I can think of:
> 
> * Use sys.getfilesystemencoding() to decode the environment.

Except not on windows where the environment is UTF-16.

> * Cache the decoded values.
> * Where should it live in six?  six.environ ?
> * I assume that in six, we'd want six.environ to be an instance of the
> class rather than making users instantiate their own TetEnviron class,
> correct?

Yes. I suppose the other question is if six.environ would need to have the same \
magical behavior of os.environ. I.e., calling os.getenv and os.putenv on __getitem__ \
and __setitem__.

> 
> Let me know if you think this is within the scope of six and I'll go
> through the normal steps of opening a Pull Request and so forth.

It's at least worth opening a GitHub issue, so others can easily register interest.
_______________________________________________
Python-porting mailing list
Python-porting@python.org
https://mail.python.org/mailman/listinfo/python-porting


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic