comparison mercurial/debugcommands.py @ 34144:902219a99901

debuginstall: use codecs.lookup() to detect invalid encoding encoding.fromlocal() never tries to decode an ascii string since 853574db5b12, and there's no universal non-ascii string which can be decoded as any valid character set.
author Yuya Nishihara <yuya@tcha.org>
date Thu, 07 Sep 2017 22:27:23 +0900
parents 07f09995e857
children ada8a19672ab
comparison
equal deleted inserted replaced
34143:82bd4c5a81e5 34144:902219a99901
5 # This software may be used and distributed according to the terms of the 5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version. 6 # GNU General Public License version 2 or any later version.
7 7
8 from __future__ import absolute_import 8 from __future__ import absolute_import
9 9
10 import codecs
10 import collections 11 import collections
11 import difflib 12 import difflib
12 import errno 13 import errno
13 import operator 14 import operator
14 import os 15 import os
995 996
996 # encoding 997 # encoding
997 fm.write('encoding', _("checking encoding (%s)...\n"), encoding.encoding) 998 fm.write('encoding', _("checking encoding (%s)...\n"), encoding.encoding)
998 err = None 999 err = None
999 try: 1000 try:
1000 encoding.fromlocal("test") 1001 codecs.lookup(pycompat.sysstr(encoding.encoding))
1001 except error.Abort as inst: 1002 except LookupError as inst:
1002 err = inst 1003 err = inst
1003 problems += 1 1004 problems += 1
1004 fm.condwrite(err, 'encodingerror', _(" %s\n" 1005 fm.condwrite(err, 'encodingerror', _(" %s\n"
1005 " (check that your locale is properly set)\n"), err) 1006 " (check that your locale is properly set)\n"), err)
1006 1007