comparison mercurial/manifest.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 6412dcec52d3
children 5cc8deb96b48
comparison
equal deleted inserted replaced
52639:9db77d46de79 52640:24ee91ba9aa8
1580 break 1580 break
1581 value = bytearray(fp.read(size)) 1581 value = bytearray(fp.read(size))
1582 if len(value) != size: 1582 if len(value) != size:
1583 break 1583 break
1584 set(node, value) 1584 set(node, value)
1585 except IOError: 1585 except OSError:
1586 # the file is allowed to be missing 1586 # the file is allowed to be missing
1587 pass 1587 pass
1588 1588
1589 self._read = True 1589 self._read = True
1590 self._dirty = False 1590 self._dirty = False
1604 fp.write(struct.pack(b'>L', len(node.value))) 1604 fp.write(struct.pack(b'>L', len(node.value)))
1605 fp.write(node.value) 1605 fp.write(node.value)
1606 if node is self._head: 1606 if node is self._head:
1607 break 1607 break
1608 node = node.prev 1608 node = node.prev
1609 except IOError: 1609 except OSError:
1610 # We could not write the cache (eg: permission error) 1610 # We could not write the cache (eg: permission error)
1611 # the content can be missing. 1611 # the content can be missing.
1612 # 1612 #
1613 # We could try harder and see if we could recreate a wcache 1613 # We could try harder and see if we could recreate a wcache
1614 # directory were we coudl write too. 1614 # directory were we coudl write too.