Mercurial > public > mercurial-scm > hg
comparison mercurial/util.py @ 4057:3600b84656d3
Fallback to ascii if getpreferredencoding raises an exception
Fixes issue478.
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Tue, 30 Jan 2007 18:32:23 -0200 |
parents | e37786b29bed |
children | 431f3c1d3a37 c620376b8fd6 |
comparison
equal
deleted
inserted
replaced
4056:f1622b4f467d | 4057:3600b84656d3 |
---|---|
15 from i18n import gettext as _ | 15 from i18n import gettext as _ |
16 from demandload import * | 16 from demandload import * |
17 demandload(globals(), "cStringIO errno getpass popen2 re shutil sys tempfile") | 17 demandload(globals(), "cStringIO errno getpass popen2 re shutil sys tempfile") |
18 demandload(globals(), "os threading time calendar ConfigParser locale glob") | 18 demandload(globals(), "os threading time calendar ConfigParser locale glob") |
19 | 19 |
20 _encoding = os.environ.get("HGENCODING") or locale.getpreferredencoding() \ | 20 try: |
21 or "ascii" | 21 _encoding = os.environ.get("HGENCODING") or locale.getpreferredencoding() \ |
22 or "ascii" | |
23 except locale.Error: | |
24 _encoding = 'ascii' | |
22 _encodingmode = os.environ.get("HGENCODINGMODE", "strict") | 25 _encodingmode = os.environ.get("HGENCODINGMODE", "strict") |
23 _fallbackencoding = 'ISO-8859-1' | 26 _fallbackencoding = 'ISO-8859-1' |
24 | 27 |
25 def tolocal(s): | 28 def tolocal(s): |
26 """ | 29 """ |