Mercurial > public > mercurial-scm > hg-stable
diff i18n/polib.py @ 52681:3e84e001b6c1
pyupgrade: drop redundant `open()` modes
On one hand, this gets rid of some py2 cruft (like `U` and `t` modes). OTOH, I
like being explict. But there's no way to disable individual transformations
(and this change is part of `_fix_tokens()`, which is even harder to selectively
use locally), and I'd rather have less noise when using `pyupgrade`.
Warning: `contrib/synthrepo.py` appears not to have been updated to py3, as it's
passing str to `error.Abort`. But since it was opening the file in unicode on
py2, this change is a no-op.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 07 Jan 2025 17:28:46 -0500 |
parents | f19a3f1437f3 |
children |
line wrap: on
line diff
--- a/i18n/polib.py Mon Jan 06 01:44:46 2025 -0500 +++ b/i18n/polib.py Tue Jan 07 17:28:46 2025 -0500 @@ -1252,10 +1252,10 @@ enc = kwargs.get('encoding', default_encoding) if _is_file(pofile): try: - self.fhandle = open(pofile, 'rt', encoding=enc) + self.fhandle = open(pofile, encoding=enc) except LookupError: enc = default_encoding - self.fhandle = open(pofile, 'rt', encoding=enc) + self.fhandle = open(pofile, encoding=enc) else: self.fhandle = pofile.splitlines()