jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/341201 )

Change subject: Avoid ResourceWarning using subprocess in python 3.6
......................................................................


Avoid ResourceWarning using subprocess in python 3.6

Bug: T159646
Change-Id: I41779be701cdef29c5a42a2702903e56893260a1
---
M pywikibot/version.py
1 file changed, 6 insertions(+), 6 deletions(-)

Approvals:
  jenkins-bot: Verified
  Xqt: Looks good to me, approved



diff --git a/pywikibot/version.py b/pywikibot/version.py
index 2cc8ba3..3025532 100644
--- a/pywikibot/version.py
+++ b/pywikibot/version.py
@@ -298,21 +298,21 @@
         tag = tag[(s + 6):e]
         t = tag.strip().split('/')
         tag = '[%s] %s' % (t[0][:-1], '-'.join(t[3:]))
-    with subprocess.Popen([cmd, '--no-pager',
+    dp = 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()
+                          stdout=subprocess.PIPE)
+    info, stderr = dp.communicate()
     info = info.decode(config.console_encoding).split('|')
     date = info[0][:-6]
     date = time.strptime(date.strip('"'), '%Y-%m-%d %H:%M:%S')
-    with subprocess.Popen([cmd, 'rev-list', 'HEAD'],
+    dp = subprocess.Popen([cmd, 'rev-list', 'HEAD'],
                           cwd=_program_dir,
-                          stdout=subprocess.PIPE).stdout as stdout:
-        rev = stdout.read()
+                          stdout=subprocess.PIPE)
+    rev, stderr = dp.communicate()
     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/341201
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I41779be701cdef29c5a42a2702903e56893260a1
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.w...@gmail.com>
Gerrit-Reviewer: DrTrigon <dr.tri...@surfeu.ch>
Gerrit-Reviewer: John Vandenberg <jay...@gmail.com>
Gerrit-Reviewer: Magul <tomasz.magul...@gmail.com>
Gerrit-Reviewer: Xqt <i...@gno.de>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to