Issue 7461: os.popen() objects don't support the context manager protocol (original) (raw)

Issue7461

Created on 2009-12-08 19:52 by pitrou, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
with_popen.patch amaury.forgeotdarc,2009-12-08 22:18
Messages (5)
msg96151 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-12-08 19:52
This works under trunk but fails under py3k: >>> import os >>> with os.popen("ls", "r") as f: ... print(f.read()) ... Traceback (most recent call last): File "", line 1, in AttributeError: __exit__
msg96156 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-12-08 22:18
Here is a patch+test
msg96158 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-12-08 23:46
We should also proxy other special methods. There is __iter__, __next__, what else?
msg96160 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-12-08 23:58
Ah, iterating already works. Sorry for the noise.
msg96161 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-12-09 00:04
I added a test for iterating and committed the patch in r76723 and r76724. Thanks!
History
Date User Action Args
2022-04-11 14:56:55 admin set github: 51710
2009-12-09 00:04:04 pitrou set status: open -> closedresolution: fixedmessages: +
2009-12-08 23:58:05 pitrou set messages: +
2009-12-08 23:46:28 pitrou set messages: +
2009-12-08 22🔞40 amaury.forgeotdarc set files: + with_popen.patchnosy: + amaury.forgeotdarcmessages: + keywords: + patch
2009-12-08 19:52:31 pitrou create