diff mercurial/httppeer.py @ 52665:24ee91ba9aa8

pyupgrade: drop usage of py3 aliases for `OSError` These were different classes in py2, but now a handful of error classes are just an alias of `OSError`, like `IOError`, `EnvironmentError`, `WindowsError`, etc. This is the result of running a hacked version of `pyupgrade` 3.19.1[1] $ hg files -0 'relglob:**.py' | xargs -0 \ pyupgrade --py38-plus --keep-percent-format --keep-mock --keep-runtime-typing The hack is because it doesn't have command line switches to disable most changes, so it makes tons of unrelated changes all at once. The hack is to 1) patch `pyupgrade._main._fix_tokens()` to immediately return its content arg 2) change `pyupgrade._data.register_decorator()` to only register the function if it's from the fixer we're interested in: if func.__module__ in ( "pyupgrade._plugins.exceptions", ): FUNCS[tp].append(func) return func [1] https://github.com/asottile/pyupgrade
author Matt Harbison <matt_harbison@yahoo.com>
date Sun, 05 Jan 2025 21:03:17 -0500
parents b52f2b365eff
children 5cc8deb96b48
line wrap: on
line diff
--- a/mercurial/httppeer.py	Mon Jan 06 14:15:40 2025 -0500
+++ b/mercurial/httppeer.py	Sun Jan 05 21:03:17 2025 -0500
@@ -11,7 +11,6 @@
 import errno
 import io
 import os
-import socket
 import struct
 import typing
 
@@ -303,7 +302,7 @@
             % urlutil.hidepassword(req.get_full_url())
         )
         ui.traceback()
-        raise IOError(None, inst)
+        raise OSError(None, inst)
     finally:
         if ui.debugflag and ui.configbool(b'devel', b'debug.peer-request'):
             code = res.code if res else -1
@@ -522,7 +521,7 @@
             # like generic socket errors. They lack any values in
             # .args on Python 3 which breaks our socket.error block.
             raise
-        except socket.error as err:
+        except OSError as err:
             if err.args[0] in (errno.ECONNRESET, errno.EPIPE):
                 raise error.Abort(_(b'push failed: %s') % err.args[1])
             raise error.Abort(err.args[1])