[Python-3000-checkins] r61339 - python/branches/py3k/Lib/locale.py

neal.norwitz python-3000-checkins at python.org
Mon Mar 10 05:49:26 CET 2008


Author: neal.norwitz
Date: Mon Mar 10 05:49:25 2008
New Revision: 61339

Modified:
   python/branches/py3k/Lib/locale.py
Log:
strxfrm and strcoll are conditionally defined, alwsy provide some impl

Modified: python/branches/py3k/Lib/locale.py
==============================================================================
--- python/branches/py3k/Lib/locale.py	(original)
+++ python/branches/py3k/Lib/locale.py	Mon Mar 10 05:49:25 2008
@@ -26,6 +26,18 @@
            "normalize", "LC_CTYPE", "LC_COLLATE", "LC_TIME", "LC_MONETARY",
            "LC_NUMERIC", "LC_ALL", "CHAR_MAX"]
 
+def _strcoll(a,b):
+    """ strcoll(string,string) -> int.
+        Compares two strings according to the locale.
+    """
+    return cmp(a,b)
+
+def _strxfrm(s):
+    """ strxfrm(string) -> string.
+        Returns a string that behaves for cmp locale-aware.
+    """
+    return s
+
 try:
 
     from _locale import *
@@ -76,17 +88,11 @@
             raise Error('_locale emulation only supports "C" locale')
         return 'C'
 
-    def strcoll(a,b):
-        """ strcoll(string,string) -> int.
-            Compares two strings according to the locale.
-        """
-        return cmp(a,b)
-
-    def strxfrm(s):
-        """ strxfrm(string) -> string.
-            Returns a string that behaves for cmp locale-aware.
-        """
-        return s
+# These may or may not exist in _locale, so be sure to set them.
+if 'strxfrm' not in globals():
+    strxfrm = _strxfrm
+if 'strcoll' not in globals():
+    strcoll = _strcoll
 
 ### Number formatting APIs
 


More information about the Python-3000-checkins mailing list