comparison mercurial/utils/procutil.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 1b9b6b4aa929
children 7a4772e92f23
comparison
equal deleted inserted replaced
52639:9db77d46de79 52640:24ee91ba9aa8
53 53
54 class BadFile(io.RawIOBase): 54 class BadFile(io.RawIOBase):
55 """Dummy file object to simulate closed stdio behavior""" 55 """Dummy file object to simulate closed stdio behavior"""
56 56
57 def readinto(self, b): 57 def readinto(self, b):
58 raise IOError(errno.EBADF, 'Bad file descriptor') 58 raise OSError(errno.EBADF, 'Bad file descriptor')
59 59
60 def write(self, b): 60 def write(self, b):
61 raise IOError(errno.EBADF, 'Bad file descriptor') 61 raise OSError(errno.EBADF, 'Bad file descriptor')
62 62
63 63
64 class LineBufferedWrapper: 64 class LineBufferedWrapper:
65 def __init__(self, orig): 65 def __init__(self, orig):
66 self.orig = orig 66 self.orig = orig