eric6/Graphics/UMLDialog.py

changeset 7785
9978016560ec
parent 7780
41420f82c0ac
child 7836
2f0d208b8137
--- a/eric6/Graphics/UMLDialog.py	Tue Oct 13 19:02:26 2020 +0200
+++ b/eric6/Graphics/UMLDialog.py	Wed Oct 14 17:50:39 2020 +0200
@@ -254,9 +254,8 @@
         lines.extend(self.umlView.getPersistenceData())
         
         try:
-            f = open(filename, "w", encoding="utf-8")
-            f.write("\n".join(lines))
-            f.close()
+            with open(filename, "w", encoding="utf-8") as f:
+                f.write("\n".join(lines))
         except (IOError, OSError) as err:
             E5MessageBox.critical(
                 self,
@@ -284,9 +283,8 @@
             return False
         
         try:
-            f = open(filename, "r", encoding="utf-8")
-            data = f.read()
-            f.close()
+            with open(filename, "r", encoding="utf-8") as f:
+                data = f.read()
         except (IOError, OSError) as err:
             E5MessageBox.critical(
                 self,

eric ide

mercurial