[PATCH stable] encoding: protect against non-ascii default encoding
Cesar Mena
cesar.mena at gmail.com
Mon Apr 23 01:34:37 UTC 2012
# HG changeset patch
# User Cesar Mena <cesarmena at gmail.com>
# Date 1335144472 14400
# Branch stable
# Node ID 8dfd20472015e6424a871c3c07bba19fc265b67a
# Parent cbf2ea2f5ca169d22e0729cb71a21b808574b90e
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 @@
"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):
More information about the Mercurial-devel
mailing list