eric6/QScintilla/Editor.py

changeset 8240
93b8a353c4bf
parent 8239
59a9a658618c
child 8243
cc717c2ae956
--- a/eric6/QScintilla/Editor.py	Wed Apr 14 19:38:19 2021 +0200
+++ b/eric6/QScintilla/Editor.py	Wed Apr 14 19:59:16 2021 +0200
@@ -10,6 +10,7 @@
 import os
 import re
 import difflib
+import contextlib
 
 from PyQt5.QtCore import (
     pyqtSignal, pyqtSlot, Qt, QDir, QTimer, QModelIndex, QFileInfo,
@@ -3250,16 +3251,10 @@
             except OSError:
                 # if there was an error, ignore it
                 perms_valid = False
-            try:
+            with contextlib.suppress(OSError):
                 os.remove(bfn)
-            except OSError:
-                # if there was an error, ignore it
-                pass
-            try:
+            with contextlib.suppress(OSError):
                 os.rename(fn, bfn)
-            except OSError:
-                # if there was an error, ignore it
-                pass
         
         # now write text to the file fn
         try:

eric ide

mercurial