jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Close subprocess stdout streams
......................................................................
[FIX] Close subprocess stdout streams
Bug: 70969
Change-Id: I839ef18cd40758fb331a85e615b39063e95f9915
---
M pywikibot/version.py
1 file changed, 12 insertions(+), 10 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/version.py b/pywikibot/version.py
index c8cb36c..994f387 100644
--- a/pywikibot/version.py
+++ b/pywikibot/version.py
@@ -204,19 +204,21 @@
tag = tag[(s + 6):e]
t = tag.strip().split('/')
tag = '[%s] %s' % (t[0][:-1], '-'.join(t[3:]))
- info = subprocess.Popen([cmd, '--no-pager',
- 'log', '-1',
- '--pretty=format:"%ad|%an|%h|%H|%d"'
- '--abbrev-commit',
- '--date=iso'],
- cwd=_program_dir,
- stdout=subprocess.PIPE).stdout.read()
+ with subprocess.Popen([cmd, '--no-pager',
+ 'log', '-1',
+ '--pretty=format:"%ad|%an|%h|%H|%d"'
+ '--abbrev-commit',
+ '--date=iso'],
+ cwd=_program_dir,
+ stdout=subprocess.PIPE).stdout as stdout:
+ info = stdout.read()
info = info.decode(config.console_encoding).split('|')
date = info[0][:-6]
date = time.strptime(date.strip('"'), '%Y-%m-%d %H:%M:%S')
- rev = subprocess.Popen([cmd, 'rev-list', 'HEAD'],
- cwd=_program_dir,
- stdout=subprocess.PIPE).stdout.read()
+ with subprocess.Popen([cmd, 'rev-list', 'HEAD'],
+ cwd=_program_dir,
+ stdout=subprocess.PIPE).stdout as stdout:
+ rev = stdout.read()
rev = 'g%s' % len(rev.splitlines())
hsh = info[3] # also stored in '.git/refs/heads/master'
if (not date or not tag or not rev) and not path:
--
To view, visit
https://gerrit.wikimedia.org/r/161227
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I839ef18cd40758fb331a85e615b39063e95f9915
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>