jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1337401?usp=email )

Change subject: Replace legacy I/O exception aliases with OSError
......................................................................

Replace legacy I/O exception aliases with OSError

IOError and EnvironmentError are aliases of OSError on all supported
Python versions. Use the canonical name in exception handlers, the
DjVu file test, and exception documentation.

Change-Id: Ibfc9c2b758dd3b427034b6b2ee2061b5e70602d0
---
M pywikibot/page/_filepage.py
M pywikibot/throttle.py
M pywikibot/tools/__init__.py
M scripts/category.py
M scripts/solve_disambiguation.py
M tests/djvu_tests.py
6 files changed, 6 insertions(+), 6 deletions(-)

Approvals:
  jenkins-bot: Verified
  Xqt: Looks good to me, approved




diff --git a/pywikibot/page/_filepage.py b/pywikibot/page/_filepage.py
index 1ed52d9..6fa662a 100644
--- a/pywikibot/page/_filepage.py
+++ b/pywikibot/page/_filepage.py
@@ -396,7 +396,7 @@
         :param url_height: Download thumbnail with given height
         :param url_param: Download thumbnail with given param
         :return: True if download is successful, False otherwise.
-        :raises IOError: If filename cannot be written for any reason.
+        :raises OSError: If filename cannot be written for any reason.
         """
         if not filename:
             path = Path()
diff --git a/pywikibot/throttle.py b/pywikibot/throttle.py
index b9013a1..7a5d205 100644
--- a/pywikibot/throttle.py
+++ b/pywikibot/throttle.py
@@ -169,7 +169,7 @@
         """Write process entries to file."""
         processes = sorted(processes, key=lambda p: (p.pid, p.site))

-        with suppress(IOError), open(self.ctrlfilename, 'w') as f:
+        with suppress(OSError), open(self.ctrlfilename, 'w') as f:
             f.writelines(FORMAT_LINE.format_map(p._asdict())
                          for p in processes)

diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index 9e5952a..48e9e7d 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -860,7 +860,7 @@
     :param mode: Requested file mode
     :param quiet: Warn about file mode change if False.
     :param create: Create the file if it does not exist already
-    :raise IOError: The file does not exist and `create` is False.
+    :raise OSError: The file does not exist and `create` is False.
     """
     try:
         st_mode = os.stat(filename).st_mode
diff --git a/scripts/category.py b/scripts/category.py
index 88d2b8f..f91148f 100755
--- a/scripts/category.py
+++ b/scripts/category.py
@@ -446,7 +446,7 @@
                     suppress(pickle.PicklingError):
                 pickle.dump(databases, f, protocol=config.pickle_protocol)
         else:
-            with suppress(EnvironmentError):
+            with suppress(OSError):
                 os.remove(filename)
                 pywikibot.info(
                     f'Database is empty. {config.shortpath(filename)} removed')
diff --git a/scripts/solve_disambiguation.py b/scripts/solve_disambiguation.py
index db69baf..8152861 100755
--- a/scripts/solve_disambiguation.py
+++ b/scripts/solve_disambiguation.py
@@ -504,7 +504,7 @@
                 self.disamb_page.title(as_url=True) + '.txt')

             # Open file for appending. If none exists, create a new one.
-            with suppress(IOError), open(filename, 'a', encoding='utf-8') as f:
+            with suppress(OSError), open(filename, 'a', encoding='utf-8') as f:
                 f.write('\n'.join(page_titles) + '\n')
 

diff --git a/tests/djvu_tests.py b/tests/djvu_tests.py
index 038eb87..f2af733 100755
--- a/tests/djvu_tests.py
+++ b/tests/djvu_tests.py
@@ -122,7 +122,7 @@
     def test_file_existence(self) -> None:
         """Test file existence checks."""
         self.assertEqual(os.path.abspath(file_djvu), self.djvu.file)
-        with self.assertRaises(IOError):
+        with self.assertRaises(OSError):
             DjVuFile(self.file_djvu_not_existing)

     def test_str_method(self) -> None:

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1337401?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ibfc9c2b758dd3b427034b6b2ee2061b5e70602d0
Gerrit-Change-Number: 1337401
Gerrit-PatchSet: 2
Gerrit-Owner: Mahveotm <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to