STINNER Victor <victor.stin...@haypocalc.com> added the comment:

Bytes program name problem should be splitted in two parts:

 (a) subprocess.call([b'env']) and subprocess.call([b'env'], env={'PATH': 
'/usr/bin'}): bytes program and unicode environ
 (b) bytes program and bytes environ

Part (a)
--------

(a) would benefit from the creation of os(.path).fsencode() function (issue 
#8514).

Part (b)
--------

If the creation of os.environb is accepted (#8603), I think that subprocess 
should also be modified to support pure bytes environ. Mix bytes and unicode 
variables in env would lead to mojibake and headaches.

So I propose the creation of an "envb" (environment bytes) argument to Popen 
constructor. (b) would be written as:

   subprocess.call([b'env'], envb={b'PATH': b'/usr/bin'})

or

   envb = os.environb.copy()
   envb[b'PATH'] = b'/usr/bin'
   subprocess.call([b'env'], envb=envb)

(and it will not be possible to define env and envb at the same time)

In this case, we will need a pure bytes version of os.get_exec_path(), and 
os._execvpe() should have a "bytes environment" mode (add an optional argument).

--

I have a patch fixing both problems, parts (a) and (b), but the patch depends 
on os.environb. I prefer to wait until os.environb is accepted to submit my 
patch.

----------
dependencies: +Create a bytes version of os.environ and getenvb() -Create 
fsencode() and fsdecode() functions in os.path

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue8513>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to