# HG changeset patch # User Cesar Mena # Date 2012-04-23 01:27:52 # Node ID 72c6240a4b7d294f663007f6dcc5b61c7758f533 # Parent 774e2dcd0a65129f23260c0eae4a855b6bb7ed12 encoding: protect against non-ascii default encoding If the default python encoding was changed from ascii, the attempt to encode as ascii before lower() could throw a UnicodeEncodeError. Catch UnicodeError instead to prevent an unhandled exception. diff --git a/mercurial/encoding.py b/mercurial/encoding.py --- a/mercurial/encoding.py +++ b/mercurial/encoding.py @@ -169,7 +169,7 @@ def lower(s): "best-effort encoding-aware case-folding of local string s" try: return s.encode('ascii').lower() - except UnicodeDecodeError: + except UnicodeError: pass try: if isinstance(s, localstr):