eric6/PipInterface/PipPackagesWidget.py

changeset 8240
93b8a353c4bf
parent 8218
7c09585bd960
--- a/eric6/PipInterface/PipPackagesWidget.py	Wed Apr 14 19:38:19 2021 +0200
+++ b/eric6/PipInterface/PipPackagesWidget.py	Wed Apr 14 19:59:16 2021 +0200
@@ -10,6 +10,7 @@
 import textwrap
 import os
 import html.parser
+import contextlib
 
 from PyQt5.QtCore import pyqtSlot, Qt, QUrl, QUrlQuery
 from PyQt5.QtNetwork import QNetworkReply, QNetworkRequest
@@ -1213,12 +1214,8 @@
             return
         
         if not os.path.exists(cfgFile):
-            try:
-                with open(cfgFile, "w") as f:
-                    f.write("[global]\n")
-            except OSError:
-                # ignore these
-                pass
+            with contextlib.suppress(OSError), open(cfgFile, "w") as f:
+                f.write("[global]\n")
         
         # check, if the destination is writeable
         if not os.access(cfgFile, os.W_OK):

eric ide

mercurial