changeset 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 f1622b4f467d
children e7282dede8cd
files mercurial/util.py
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/util.py	Tue Jan 30 18:32:21 2007 -0200
+++ b/mercurial/util.py	Tue Jan 30 18:32:23 2007 -0200
@@ -17,8 +17,11 @@
 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'