This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2008年10月03日 23:38 by vstinner, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| os_exec_bytes-2.patch | vstinner, 2008年10月08日 00:38 | |||
| Messages (11) | |||
|---|---|---|---|
| msg74283 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2008年10月03日 23:38 | |
os.exec*() functions doesn't support bytes if the program name doesn't
use absolute path. The problem is that PATH is used to complete the
full path but Python3 disallows bytes+str (which is a good thing!).
Example:
python -c "import os; os.execvp('pwd', 'pwd')"
Traceback (most recent call last):
...
File "/home/haypo/prog/py3k/Lib/os.py", line 328, in execvp
_execvpe(file, args)
File "/home/haypo/prog/py3k/Lib/os.py", line 364, in _execvpe
func(fullname, *argrest)
TypeError: execv() arg 2 must be a tuple or list
Attached patch allows bytes in os.exec*(). It converts each directory
of PATH using sys.getfilesystemencoding().
|
|||
| msg74304 - (view) | Author: Martin v. Löwis (loewis) * (Python committer) | Date: 2008年10月04日 08:03 | |
This is incorrect. On Windows, if the path contains characters with no representation in CP_ACP, encoding the path as bytes makes it invalid. |
|||
| msg74313 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2008年10月04日 11:31 | |
The fix can be changed to be specific to POSIX system:
+ if name == 'posix' \
+ and isinstance(file, bytes):
+ encoding = sys.getfilesystemencoding()
+ PATH = (bytes(dir, encoding) for dir in PATH)
My example was incorrect. The good example is:
python -c "import os; os.execvp('pwd', ['pwd'])
|
|||
| msg74449 - (view) | Author: Martin v. Löwis (loewis) * (Python committer) | Date: 2008年10月07日 13:43 | |
Can you come up with a test case? Also, it would probably be good to document what parameters can have what datatypes in the exec family of functions. |
|||
| msg74451 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2008年10月07日 14:19 | |
The patch is incomplete. It allows bytes for the arguments but not for the environment variables: posix_execve() in Modules/posixmodule.c uses: PyArg_Parse(key "s", &k) PyArg_Parse(val "s", &v) |
|||
| msg74503 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2008年10月08日 00:38 | |
Improved patch: - support bytes in the env dictionary using the file system default encoding - support bytes for program arguments but only on a POSIX system Document is not updated yet. |
|||
| msg78681 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2009年01月01日 02:19 | |
Hmm, I think the supported types should be the same for all platforms, otherwise it creates unnecessary headaches. Perhaps, in addition to the proposed behaviour on Posix (convert everything to bytes if the program name is a bytes object), the reverse could be done under Windows (convert the program name to str if it is a bytes object). |
|||
| msg78718 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2009年01月01日 18:56 | |
> Hmm, I think the supported types should be the same for all > platforms, otherwise it creates unnecessary headaches. I'm don't know Windows very well, but I read many times that Windows uses unicode everywhere. I'm unable to decide if it's a good thing or not to support also bytes on Windows, and anyway I'm unable to write such patch. See also issue #4036 (bytes for subprocess.Popen), especially Martin's message msg74305 (Martin is our Windows expert ;-)). |
|||
| msg78739 - (view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) | Date: 2009年01月01日 23:44 | |
Every function of the Windows API comes in pair: an Ansi function (which accepts char* names) and a Wide function (which accepts wchar_t* names; Py_UNICODE* can be passed as-is) Don't perform conversion on Windows, just call the proper function. |
|||
| msg78829 - (view) | Author: Martin v. Löwis (loewis) * (Python committer) | Date: 2009年01月02日 16:15 | |
Any discussion in the tracker should be deferred until a PEP has been written, discussed, and accepted. Then the question whether to accept a specific patch shouldn't be a matter of taste, but should follow from the general rules that the PEP has set up. |
|||
| msg100355 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2010年03月03日 22:09 | |
Fixed by r72313 (PEP 383). |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:40 | admin | set | github: 48285 |
| 2010年03月03日 22:09:01 | vstinner | set | status: open -> closed keywords: patch, patch resolution: fixed messages: + msg100355 |
| 2009年05月17日 02:43:02 | ajaksu2 | set | versions:
+ Python 3.1, - Python 3.0 nosy: loewis, amaury.forgeotdarc, pitrou, vstinner priority: high components: + Library (Lib) keywords: patch, patch type: enhancement |
| 2009年01月02日 16:16:00 | loewis | set | keywords:
patch, patch messages: + msg78829 |
| 2009年01月01日 23:44:20 | amaury.forgeotdarc | set | keywords:
patch, patch nosy: + amaury.forgeotdarc messages: + msg78739 |
| 2009年01月01日 18:56:02 | vstinner | set | keywords:
patch, patch messages: + msg78718 |
| 2009年01月01日 02:19:37 | pitrou | set | keywords:
patch, patch nosy: + pitrou messages: + msg78681 |
| 2008年10月08日 00:43:39 | vstinner | link | issue4036 dependencies |
| 2008年10月08日 00:39:37 | vstinner | set | files: - os_exec_bytes.patch |
| 2008年10月08日 00:38:29 | vstinner | set | keywords:
patch, patch files: + os_exec_bytes-2.patch messages: + msg74503 |
| 2008年10月07日 14:19:54 | vstinner | set | keywords:
patch, patch messages: + msg74451 |
| 2008年10月07日 13:43:35 | loewis | set | keywords:
patch, patch messages: + msg74449 |
| 2008年10月04日 11:31:27 | vstinner | set | keywords:
patch, patch messages: + msg74313 |
| 2008年10月04日 08:03:08 | loewis | set | keywords:
patch, patch nosy: + loewis messages: + msg74304 |
| 2008年10月03日 23:38:23 | vstinner | create | |