Message104922
| Author |
vstinner |
| Recipients |
Arfrever, gregory.p.smith, vstinner |
| Date |
2010年05月04日.11:10:39 |
| SpamBayes Score |
0.001807147 |
| Marked as misclassified |
No |
| Message-id |
<1272971441.45.0.353328936214.issue8513@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2010年05月04日 11:10:41 | vstinner | set | recipients:
+ vstinner, gregory.p.smith, Arfrever |
| 2010年05月04日 11:10:41 | vstinner | set | messageid: <1272971441.45.0.353328936214.issue8513@psf.upfronthosting.co.za> |
| 2010年05月04日 11:10:40 | vstinner | link | issue8513 messages |
| 2010年05月04日 11:10:39 | vstinner | create |
|