eric6/ViewManager/ViewManager.py

changeset 7785
9978016560ec
parent 7775
4a1db75550bd
child 7824
096b3ebc1409
child 7836
2f0d208b8137
diff -r 3257703e10c5 -r 9978016560ec eric6/ViewManager/ViewManager.py
--- a/eric6/ViewManager/ViewManager.py	Tue Oct 13 19:02:26 2020 +0200
+++ b/eric6/ViewManager/ViewManager.py	Wed Oct 14 17:50:39 2020 +0200
@@ -6583,9 +6583,8 @@
         """
         if os.path.exists(dictionaryFile):
             try:
-                f = open(dictionaryFile, "r", encoding="utf-8")
-                data = f.read()
-                f.close()
+                with open(dictionaryFile, "r", encoding="utf-8") as f:
+                    data = f.read()
             except (IOError, OSError) as err:
                 E5MessageBox.critical(
                     self.ui,
@@ -6613,9 +6612,8 @@
             if dlg.exec() == QDialog.Accepted:
                 data = dlg.getData()
                 try:
-                    f = open(dictionaryFile, "w", encoding="utf-8")
-                    f.write(data)
-                    f.close()
+                    with open(dictionaryFile, "w", encoding="utf-8") as f:
+                        f.write(data)
                 except (IOError, OSError) as err:
                     E5MessageBox.critical(
                         self.ui,

eric ide

mercurial