eric6/Plugins/VcsPlugins/vcsMercurial/HisteditExtension/HgHisteditCommitEditor.py

changeset 7785
9978016560ec
parent 7780
41420f82c0ac
child 7836
2f0d208b8137
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HisteditExtension/HgHisteditCommitEditor.py	Tue Oct 13 19:02:26 2020 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HisteditExtension/HgHisteditCommitEditor.py	Wed Oct 14 17:50:39 2020 +0200
@@ -49,9 +49,8 @@
         populate the dialog.
         """
         try:
-            f = open(self.__fileName, "r")
-            txt = f.read()
-            f.close()
+            with open(self.__fileName, "r") as f:
+                txt = f.read()
         except (IOError, OSError) as err:
             E5MessageBox.critical(
                 self,
@@ -89,9 +88,8 @@
         """
         msg = self.messageEdit.toPlainText()
         try:
-            f = open(self.__fileName, "w")
-            f.write(msg)
-            f.close()
+            with open(self.__fileName, "w") as f:
+                f.write(msg)
         except (IOError, OSError) as err:
             E5MessageBox.critical(
                 self,

eric ide

mercurial