Mercurial > public > mercurial-scm > hg-stable
diff mercurial/i18n.py @ 52664:9db77d46de79
py3: drop redundant `u''` prefixes on string literals
Strings are unicode on Python 3. These were rewritten by `pyupgrade`.
It's arguably better to fix the `contrib` stuff upstream and then re-vendor it,
but I don't feel like waiting for that, and then all of the regression testing
involved to get a minor improvement in the codebase. It was last vendored 5
years ago, and will likely be a large change anyway to drop py2 support. Also,
we've already made minor formatting changes to it locally.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Mon, 06 Jan 2025 14:15:40 -0500 |
parents | f4733654f144 |
children |
line wrap: on
line diff
--- a/mercurial/i18n.py Mon Jan 06 14:07:43 2025 -0500 +++ b/mercurial/i18n.py Mon Jan 06 14:15:40 2025 -0500 @@ -86,14 +86,14 @@ if message not in cache: if type(message) is str: # goofy unicode docstrings in test - paragraphs: List[str] = message.split(u'\n\n') + paragraphs: List[str] = message.split('\n\n') else: # should be ascii, but we have unicode docstrings in test, which # are converted to utf-8 bytes on Python 3. paragraphs = [p.decode("utf-8") for p in message.split(b'\n\n')] # Be careful not to translate the empty string -- it holds the # meta data of the .po file. - u = u'\n\n'.join([p and _ugettext(p) or u'' for p in paragraphs]) + u = '\n\n'.join([p and _ugettext(p) or '' for p in paragraphs]) try: # encoding.tolocal cannot be used since it will first try to # decode the Unicode string. Calling u.decode(enc) really