comparison mercurial/httppeer.py @ 52640: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
comparison
equal deleted inserted replaced
52639:9db77d46de79 52640:24ee91ba9aa8
9 from __future__ import annotations 9 from __future__ import annotations
10 10
11 import errno 11 import errno
12 import io 12 import io
13 import os 13 import os
14 import socket
15 import struct 14 import struct
16 import typing 15 import typing
17 16
18 from concurrent import futures 17 from concurrent import futures
19 from .i18n import _ 18 from .i18n import _
301 ui.debug( 300 ui.debug(
302 b'http error requesting %s\n' 301 b'http error requesting %s\n'
303 % urlutil.hidepassword(req.get_full_url()) 302 % urlutil.hidepassword(req.get_full_url())
304 ) 303 )
305 ui.traceback() 304 ui.traceback()
306 raise IOError(None, inst) 305 raise OSError(None, inst)
307 finally: 306 finally:
308 if ui.debugflag and ui.configbool(b'devel', b'debug.peer-request'): 307 if ui.debugflag and ui.configbool(b'devel', b'debug.peer-request'):
309 code = res.code if res else -1 308 code = res.code if res else -1
310 dbg( 309 dbg(
311 line 310 line
520 except urlerr.httperror: 519 except urlerr.httperror:
521 # Catch and re-raise these so we don't try and treat them 520 # Catch and re-raise these so we don't try and treat them
522 # like generic socket errors. They lack any values in 521 # like generic socket errors. They lack any values in
523 # .args on Python 3 which breaks our socket.error block. 522 # .args on Python 3 which breaks our socket.error block.
524 raise 523 raise
525 except socket.error as err: 524 except OSError as err:
526 if err.args[0] in (errno.ECONNRESET, errno.EPIPE): 525 if err.args[0] in (errno.ECONNRESET, errno.EPIPE):
527 raise error.Abort(_(b'push failed: %s') % err.args[1]) 526 raise error.Abort(_(b'push failed: %s') % err.args[1])
528 raise error.Abort(err.args[1]) 527 raise error.Abort(err.args[1])
529 finally: 528 finally:
530 fp.close() 529 fp.close()