Mercurial > public > mercurial-scm > hg
comparison contrib/synthrepo.py @ 52656: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 | abc327f9628b |
children |
comparison
equal
deleted
inserted
replaced
52655:5027ae0d89b3 | 52656:3e84e001b6c1 |
---|---|
324 linesinfilesadded = cdf(desc['linesinfilesadded']) | 324 linesinfilesadded = cdf(desc['linesinfilesadded']) |
325 tzoffset = cdf(desc['tzoffset']) | 325 tzoffset = cdf(desc['tzoffset']) |
326 | 326 |
327 dictfile = opts.get('dict') or '/usr/share/dict/words' | 327 dictfile = opts.get('dict') or '/usr/share/dict/words' |
328 try: | 328 try: |
329 fp = open(dictfile, 'rU') | 329 fp = open(dictfile) |
330 except OSError as err: | 330 except OSError as err: |
331 raise error.Abort('%s: %s' % (dictfile, err.strerror)) | 331 raise error.Abort('%s: %s' % (dictfile, err.strerror)) |
332 words = fp.read().splitlines() | 332 words = fp.read().splitlines() |
333 fp.close() | 333 fp.close() |
334 | 334 |