changeset 17238:57a47190e96c stable

merge with crew-stable
author Bryan O'Sullivan <bryano@fb.com>
date Mon, 23 Jul 2012 15:40:19 -0700
parents 9fb8312dbdbd (diff) e73128535105 (current diff)
children ffc49100151b
files
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/encoding.py	Mon Jul 23 15:38:43 2012 -0700
+++ b/mercurial/encoding.py	Mon Jul 23 15:40:19 2012 -0700
@@ -168,8 +168,9 @@
 def lower(s):
     "best-effort encoding-aware case-folding of local string s"
     try:
-        return s.encode('ascii').lower()
-    except UnicodeError:
+        s.decode('ascii') # throw exception for non-ASCII character
+        return s.lower()
+    except UnicodeDecodeError:
         pass
     try:
         if isinstance(s, localstr):
@@ -189,6 +190,11 @@
 def upper(s):
     "best-effort encoding-aware case-folding of local string s"
     try:
+        s.decode('ascii') # throw exception for non-ASCII character
+        return s.upper()
+    except UnicodeDecodeError:
+        pass
+    try:
         if isinstance(s, localstr):
             u = s._utf8.decode("utf-8")
         else: