eric6/IconEditor/IconEditorWindow.py

changeset 8240
93b8a353c4bf
parent 8222
5994b80b8760
child 8259
2bbec88047dd
diff -r 59a9a658618c -r 93b8a353c4bf eric6/IconEditor/IconEditorWindow.py
--- a/eric6/IconEditor/IconEditorWindow.py	Wed Apr 14 19:38:19 2021 +0200
+++ b/eric6/IconEditor/IconEditorWindow.py	Wed Apr 14 19:59:16 2021 +0200
@@ -8,6 +8,7 @@
 """
 
 import os
+import contextlib
 
 from PyQt5.QtCore import (
     pyqtSignal, Qt, QSize, QSignalMapper, QFileInfo, QFile, QEvent
@@ -154,10 +155,8 @@
         inputFormats = []
         readFormats = QImageReader.supportedImageFormats()
         for readFormat in readFormats:
-            try:
+            with contextlib.suppress(KeyError):
                 inputFormats.append(filters[bytes(readFormat).decode()])
-            except KeyError:
-                pass
         inputFormats.sort()
         inputFormats.append(self.tr("All Files (*)"))
         self.__inputFilter = ';;'.join(inputFormats)
@@ -165,10 +164,8 @@
         outputFormats = []
         writeFormats = QImageWriter.supportedImageFormats()
         for writeFormat in writeFormats:
-            try:
+            with contextlib.suppress(KeyError):
                 outputFormats.append(filters[bytes(writeFormat).decode()])
-            except KeyError:
-                pass
         outputFormats.sort()
         self.__outputFilter = ';;'.join(outputFormats)
         
@@ -1027,12 +1024,10 @@
 
             Preferences.setGeometry("IconEditorGeometry", self.saveGeometry())
             
-            try:
+            with contextlib.suppress(ValueError):
                 if self.fromEric or len(self.__class__.windows) > 1:
                     del self.__class__.windows[
                         self.__class__.windows.index(self)]
-            except ValueError:
-                pass
             
             if not self.fromEric:
                 Preferences.syncPreferences()

eric ide

mercurial