[CalendarServer-changes] [13126] twext/trunk/twext/who/expression.py

source_changes at macosforge.org source_changes at macosforge.org
Wed Apr 2 12:12:33 PDT 2014


Revision: 13126
          http://trac.calendarserver.org//changeset/13126
Author:   wsanchez at apple.com
Date:     2014-04-02 12:12:33 -0700 (Wed, 02 Apr 2014)
Log Message:
-----------
Attenmpt to lowercase (unicode) text only for case insensitive normalization.

Modified Paths:
--------------
    twext/trunk/twext/who/expression.py

Modified: twext/trunk/twext/who/expression.py
===================================================================
--- twext/trunk/twext/who/expression.py	2014-04-02 18:59:40 UTC (rev 13125)
+++ twext/trunk/twext/who/expression.py	2014-04-02 19:12:33 UTC (rev 13126)
@@ -135,14 +135,12 @@
         predicate = lambda x: x
         normalize = lambda x: x
 
-        def maybeLower(x):
-            """
-            Not all values have lower(), so handle that case by returning the
-            original
-            """
-            try:
+        def lower(x):
+            # Case insensitive only makes sense conceptually for text
+            # Note we are intentionally not treating bytes as text
+            if isinstance(x, unicode):
                 return x.lower()
-            except AttributeError:
+            else:
                 return x
 
         if flags is None:
@@ -152,7 +150,7 @@
                 if flag == MatchFlags.NOT:
                     predicate = lambda x: not x
                 elif flag == MatchFlags.caseInsensitive:
-                    normalize = maybeLower
+                    normalize = lower
                 else:
                     raise NotImplementedError(
                         "Unknown query flag: {0}".format(describe(flag))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140402/99562b02/attachment.html>


More information about the calendarserver-changes mailing list