Mercurial > hg-stable
changeset 49291:44b26349127b
hgweb: remove dead code handling UnicodeDecodeError
I’m quite confident that the error can’t happen on Python 3, as the main
motivation for separating bytes and str in Python 3 was to avoid this class of
errors.
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Sun, 29 May 2022 12:38:54 +0200 |
parents | d7f3f745f20c |
children | d44e3c45f0e4 |
files | mercurial/hgweb/server.py tests/test-check-pyflakes.t |
diffstat | 2 files changed, 2 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hgweb/server.py Sun May 29 12:28:31 2022 +0200 +++ b/mercurial/hgweb/server.py Sun May 29 12:38:54 2022 +0200 @@ -8,7 +8,6 @@ import errno -import importlib import os import socket import sys @@ -404,26 +403,9 @@ cls = MercurialHTTPServer # ugly hack due to python issue5853 (for threaded use) - try: - import mimetypes - - mimetypes.init() - except UnicodeDecodeError: - # Python 2.x's mimetypes module attempts to decode strings - # from Windows' ANSI APIs as ascii (fail), then re-encode them - # as ascii (clown fail), because the default Python Unicode - # codec is hardcoded as ascii. + import mimetypes - sys.argv # unwrap demand-loader so that reload() works - # resurrect sys.setdefaultencoding() - try: - importlib.reload(sys) - except AttributeError: - reload(sys) - oldenc = sys.getdefaultencoding() - sys.setdefaultencoding(b"latin1") # or any full 8-bit encoding - mimetypes.init() - sys.setdefaultencoding(oldenc) + mimetypes.init() address = ui.config(b'web', b'address') port = urlutil.getport(ui.config(b'web', b'port'))
--- a/tests/test-check-pyflakes.t Sun May 29 12:28:31 2022 +0200 +++ b/tests/test-check-pyflakes.t Sun May 29 12:38:54 2022 +0200 @@ -20,7 +20,6 @@ > 2>/dev/null \ > | xargs "$PYTHON" -m pyflakes 2>/dev/null | "$TESTDIR/filterpyflakes.py" contrib/perf.py:*:* undefined name 'xrange' (glob) (?) - mercurial/hgweb/server.py:*:* undefined name 'reload' (glob) (?) mercurial/pycompat.py:*:* 'codecs' imported but unused (glob) mercurial/pycompat.py:*:* 'concurrent.futures' imported but unused (glob) mercurial/pycompat.py:*:* 'http.client as httplib' imported but unused (glob)