comparison mercurial/hgweb/hgwebdir_mod.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 0a81f3ef054c
children e627cc25b6f3
comparison
equal deleted inserted replaced
52639:9db77d46de79 52640:24ee91ba9aa8
150 path = path[: -len(discarded) - 1] 150 path = path[: -len(discarded) - 1]
151 151
152 try: 152 try:
153 hg.repository(ui, path) 153 hg.repository(ui, path)
154 directory = False 154 directory = False
155 except (IOError, error.RepoError): 155 except (OSError, error.RepoError):
156 pass 156 pass
157 157
158 parts = [ 158 parts = [
159 req.apppath.strip(b'/'), 159 req.apppath.strip(b'/'),
160 subdir.strip(b'/'), 160 subdir.strip(b'/'),
209 continue 209 continue
210 210
211 # update time with local timezone 211 # update time with local timezone
212 try: 212 try:
213 r = hg.repository(ui, path) 213 r = hg.repository(ui, path)
214 except IOError: 214 except OSError:
215 u.warn(_(b'error accessing repository at %s\n') % path) 215 u.warn(_(b'error accessing repository at %s\n') % path)
216 continue 216 continue
217 except error.RepoError: 217 except error.RepoError:
218 u.warn(_(b'error accessing repository at %s\n') % path) 218 u.warn(_(b'error accessing repository at %s\n') % path)
219 continue 219 continue
473 ) 473 )
474 try: 474 try:
475 # ensure caller gets private copy of ui 475 # ensure caller gets private copy of ui
476 repo = hg.repository(self.ui.copy(), real) 476 repo = hg.repository(self.ui.copy(), real)
477 return hgweb_mod.hgweb(repo).run_wsgi(req, res) 477 return hgweb_mod.hgweb(repo).run_wsgi(req, res)
478 except IOError as inst: 478 except OSError as inst:
479 msg = encoding.strtolocal(inst.strerror) 479 msg = encoding.strtolocal(inst.strerror)
480 raise ErrorResponse(HTTP_SERVER_ERROR, msg) 480 raise ErrorResponse(HTTP_SERVER_ERROR, msg)
481 except error.RepoError as inst: 481 except error.RepoError as inst:
482 raise ErrorResponse(HTTP_SERVER_ERROR, bytes(inst)) 482 raise ErrorResponse(HTTP_SERVER_ERROR, bytes(inst))
483 483