merge with crew-stable stable
authorBryan O'Sullivan <bryano@fb.com>
Mon, 23 Jul 2012 15:40:19 -0700
branchstable
changeset 17238 57a47190e96c
parent 17236 9fb8312dbdbd (diff)
parent 17237 e73128535105 (current diff)
child 17240 ffc49100151b
merge with crew-stable
--- 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: