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

Change subject: [IMPR] use context manager to open a file
......................................................................

[IMPR] use context manager to open a file

also remove hidden comment because it is unclear what to do with it

Change-Id: I88814540b446aceb138fdf0b335125e022c3013c
---
M scripts/editarticle.py
1 file changed, 2 insertions(+), 7 deletions(-)

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



diff --git a/scripts/editarticle.py b/scripts/editarticle.py
index 938bde2..f89e58a 100755
--- a/scripts/editarticle.py
+++ b/scripts/editarticle.py
@@ -45,10 +45,6 @@

     """Edit a wiki page."""

-    # join lines if line starts with this ones
-    # TODO: No apparent usage
-    # joinchars = string.letters + '[]' + string.digits
-
     def __init__(self, *args):
         """Constructor."""
         self.set_options(*args)
@@ -85,9 +81,8 @@
     def handle_edit_conflict(self, new):
         """When an edit conflict occures save the new text to a file."""
         fn = os.path.join(tempfile.gettempdir(), self.page.title())
-        fp = open(fn, 'w')
-        fp.write(new)
-        fp.close()
+        with open(fn, 'w') as fp:
+            fp.write(new)
         pywikibot.output(
             "An edit conflict has arisen. Your edit has been saved to %s. "
             "Please try again." % fn)

--
To view, visit https://gerrit.wikimedia.org/r/425465
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I88814540b446aceb138fdf0b335125e022c3013c
Gerrit-Change-Number: 425465
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <i...@gno.de>
Gerrit-Reviewer: Dalba <dalba.w...@gmail.com>
Gerrit-Reviewer: John Vandenberg <jay...@gmail.com>
Gerrit-Reviewer: Zoranzoki21 <zorandori4...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
Pywikibot-commits mailing list
Pywikibot-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to