Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1898)

Issue 3441041: Context management for subprocess.Popen (Python #10554)

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years, 4 months ago by merwok
Modified:
13 years, 4 months ago
Reviewers:
Base URL:
http://svn.python.org/view/*checkout*/python/branches/py3k/
Visibility:
Public.

Patch Set 1 #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+62 lines, -1 line) Patch
Doc/library/subprocess.rst View 1 chunk +9 lines, -0 lines 1 comment Download
Lib/subprocess.py View 1 chunk +10 lines, -0 lines 1 comment Download
Lib/test/test_subprocess.py View 2 chunks +43 lines, -1 line 1 comment Download

Messages

Total messages: 2
merwok
13 years, 4 months ago (2010-12-03 01:51:57 UTC) #1
merwok
13 years, 4 months ago (2010-12-03 01:57:07 UTC) #2
Two details and one question.

http://codereview.appspot.com/3441041/diff/1/Doc/library/subprocess.rst
File Doc/library/subprocess.rst (right):

http://codereview.appspot.com/3441041/diff/1/Doc/library/subprocess.rst#newco...
Doc/library/subprocess.rst:214: with Popen([sys.executable, "-c", "import
sys;sys.stdout.write('hello')"], stdout=PIPE) as proc:
Maybe a simpler example would be as good and less noisy:

"-c", "print('hello,')"

http://codereview.appspot.com/3441041/diff/1/Lib/subprocess.py
File Lib/subprocess.py (right):

http://codereview.appspot.com/3441041/diff/1/Lib/subprocess.py#newcode709
Lib/subprocess.py:709: self.stdin.close()
There is some other cleanup done in __del__; I don’t know if it should be done
in __exit__ too.

(Implementation detail: To not run it twice, it would be factored out in another
method, called from __exit__ and from __del__ (if not already called))

http://codereview.appspot.com/3441041/diff/1/Lib/test/test_subprocess.py
File Lib/test/test_subprocess.py (right):

http://codereview.appspot.com/3441041/diff/1/Lib/test/test_subprocess.py#newc...
Lib/test/test_subprocess.py:1236: ContextManagerTests)
Maybe it’s the opportunity to use this diff-friendly idiom:

CommandsWithSpaces,
ContextManagerTests,
)
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b