# HG changeset patch # User Alexis S. L. Carvalho # Date 1170189143 7200 # Node ID 3600b84656d335e6d847440247b7ff3f46512f4c # Parent f1622b4f467dd6434b8dc8c409358582fe1081cc Fallback to ascii if getpreferredencoding raises an exception Fixes issue478. diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -17,8 +17,11 @@ from demandload import * demandload(globals(), "cStringIO errno getpass popen2 re shutil sys tempfile") demandload(globals(), "os threading time calendar ConfigParser locale glob") -_encoding = os.environ.get("HGENCODING") or locale.getpreferredencoding() \ - or "ascii" +try: + _encoding = os.environ.get("HGENCODING") or locale.getpreferredencoding() \ + or "ascii" +except locale.Error: + _encoding = 'ascii' _encodingmode = os.environ.get("HGENCODINGMODE", "strict") _fallbackencoding = 'ISO-8859-1'