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 2013年02月24日 12:20 by Baptiste.Lepilleur, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (3) | |||
|---|---|---|---|
| msg182872 - (view) | Author: Baptiste Lepilleur (Baptiste.Lepilleur) | Date: 2013年02月24日 12:20 | |
It tooks me a while to figure out that using universal_newlines was the solution to "tell" subprocess that I wanted text string output instead of byte string. A search on stackoverflow shows that this issue is common and the solution nearly unknown (answer is usually to decode the byte string manually)... Because dealing with text output is IMHO the most common use case, the subprocess documentation should make it easier to "find" the recipe. I would suggest changing the documentation so that the universal_newlines is made obvious as it is very important: 1) the first /bin/vikings example be modified to show the use of this flag (at the top of the documentation, most people copy/past that): >>> p = subprocess.Popen(args, universal_newlines=True) # Success! and at a small comment below the example to explain that flag 2) change other example similarly when that make sense, IMHO: - ifconfig example - one of the subprocess.check_output example - subprocess.check_output() example, consider separating the byte string / text string example for increased visibility 3) consider adding a section with an obvious title "Dealing with binary and text input/output", providing examples and pointer to the correct documentation (I would place it after the convenience functions section for visibility). I think this would help attracting "eye" on this large piece of documentation. |
|||
| msg223384 - (view) | Author: Mark Lawrence (BreamoreBoy) * | Date: 2014年07月17日 22:27 | |
@Baptiste can you provide a patch for this? |
|||
| msg312868 - (view) | Author: bbayles (bbayles) * | Date: 2018年02月25日 23:19 | |
This is fixed in 3.7 with the `text` parameter. See GitHub PR 4049: https://github.com/python/cpython/pull/4049 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:42 | admin | set | github: 61488 |
| 2018年06月11日 13:13:21 | cheryl.sabella | set | status: open -> closed superseder: subprocess.run should alias universal_newlines to text resolution: duplicate stage: needs patch -> resolved |
| 2018年02月26日 15:37:23 | BreamoreBoy | set | nosy:
- BreamoreBoy |
| 2018年02月25日 23:19:08 | bbayles | set | nosy:
+ bbayles messages: + msg312868 |
| 2014年08月29日 21:24:42 | terry.reedy | set | stage: needs patch versions: + Python 3.4, Python 3.5, - Python 3.1, Python 3.2, Python 3.3 |
| 2014年07月17日 22:27:29 | BreamoreBoy | set | nosy:
+ BreamoreBoy messages: + msg223384 |
| 2013年02月24日 12:20:55 | Baptiste.Lepilleur | create | |