Issue17286
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 | |