eric6/WebBrowser/Sync/SyncHandler.py

changeset 7785
9978016560ec
parent 7781
607a6098cb44
child 7836
2f0d208b8137
--- a/eric6/WebBrowser/Sync/SyncHandler.py	Tue Oct 13 19:02:26 2020 +0200
+++ b/eric6/WebBrowser/Sync/SyncHandler.py	Wed Oct 14 17:50:39 2020 +0200
@@ -208,9 +208,8 @@
         """
         if os.path.exists(fileName):
             try:
-                inputFile = open(fileName, "rb")
-                data = inputFile.read()
-                inputFile.close()
+                with open(fileName, "rb") as inputFile:
+                    data = inputFile.read()
             except IOError:
                 return QByteArray()
             
@@ -271,9 +270,8 @@
                 return False, self.tr("Data cannot be decrypted.")
         
         try:
-            outputFile = open(fileName, "wb")
-            outputFile.write(data)
-            outputFile.close()
+            with open(fileName, "wb") as outputFile:
+                outputFile.write(data)
             if timestamp > 0:
                 os.utime(fileName, (timestamp, timestamp))
             return True, ""

eric ide

mercurial