Index: mercurial/hgweb/server.py =================================================================== --- mercurial/hgweb/server.py +++ mercurial/hgweb/server.py @@ -9,6 +9,7 @@ from __future__ import absolute_import import errno +import importlib import os import socket import sys @@ -370,7 +371,11 @@ # codec is hardcoded as ascii. sys.argv # unwrap demand-loader so that reload() works - reload(sys) # resurrect sys.setdefaultencoding() + # resurrect sys.setdefaultencoding() + try: + importlib.reload(sys) + except AttributeError: + reload(sys) oldenc = sys.getdefaultencoding() sys.setdefaultencoding("latin1") # or any full 8-bit encoding mimetypes.init() Index: tests/test-check-pyflakes.t =================================================================== --- tests/test-check-pyflakes.t +++ tests/test-check-pyflakes.t @@ -22,4 +22,5 @@ > 2>/dev/null \ > | xargs pyflakes 2>/dev/null | "$TESTDIR/filterpyflakes.py" contrib/perf.py:*: undefined name 'xrange' (glob) (?) + mercurial/hgweb/server.py:*: undefined name 'reload' (glob) (?)