diff --git a/mercurial/hgweb/request.py b/mercurial/hgweb/request.py index 04d5cde28a7fc50d4c4d9b82a59d8bc767141654_bWVyY3VyaWFsL2hnd2ViL3JlcXVlc3QucHk=..9ed281bbf864f735d370ee0b76dbdc2d0fa1564b_bWVyY3VyaWFsL2hnd2ViL3JlcXVlc3QucHk= 100644 --- a/mercurial/hgweb/request.py +++ b/mercurial/hgweb/request.py @@ -11,7 +11,6 @@ from ..thirdparty import attr from .. import ( - encoding, error, pycompat, util, @@ -167,13 +166,7 @@ def tobytes(s): if not isinstance(s, str): return s - if pycompat.iswindows: - # This is what mercurial.encoding does for os.environ on - # Windows. - return encoding.strtolocal(s) - else: - # This is what is documented to be used for os.environ on Unix. - return pycompat.fsencode(s) + return s.encode('iso8859-1') env = {tobytes(k): tobytes(v) for k, v in env.items()} diff --git a/tests/test-wsgirequest.py b/tests/test-wsgirequest.py index 04d5cde28a7fc50d4c4d9b82a59d8bc767141654_dGVzdHMvdGVzdC13c2dpcmVxdWVzdC5weQ==..9ed281bbf864f735d370ee0b76dbdc2d0fa1564b_dGVzdHMvdGVzdC13c2dpcmVxdWVzdC5weQ== 100644 --- a/tests/test-wsgirequest.py +++ b/tests/test-wsgirequest.py @@ -500,16 +500,9 @@ self.assertEqual(r.reponame, b'repo') def testenvencoding(self): - if pycompat.iswindows: - # On Windows, we can't generally know which non-ASCII characters - # are supported. - r = parse(DEFAULT_ENV, extra={'foo': 'bar'}) - self.assertEqual(r.rawenv[b'foo'], b'bar') - else: - # Unix is byte-based. Therefore we test all possible bytes. - b = b''.join(pycompat.bytechr(i) for i in range(256)) - r = parse(DEFAULT_ENV, extra={'foo': pycompat.fsdecode(b)}) - self.assertEqual(r.rawenv[b'foo'], b) + b = b''.join(pycompat.bytechr(i) for i in range(256)) + r = parse(DEFAULT_ENV, extra={'foo': b.decode('iso8859-1')}) + self.assertEqual(r.rawenv[b'foo'], b) if __name__ == '__main__':