[Python-porting] Text version of os.environ for six?

Toshio Kuratomi a.badger at gmail.com
Wed Jul 25 14:05:25 EDT 2018


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.
* 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?

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.

Thanks,
-Toshio


More information about the Python-porting mailing list