aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2008-03-10 04:49:25 +0000
committerNeal Norwitz <nnorwitz@gmail.com>2008-03-10 04:49:25 +0000
commit48b98ded6ef4d9760eeab38c5757988b5daadd1b (patch)
tree332224537a1048d7279d898529945d119c622dbb /Lib/locale.py
parentFix another buffer overflow. (diff)
downloadcpython-48b98ded6ef4d9760eeab38c5757988b5daadd1b.tar.gz
cpython-48b98ded6ef4d9760eeab38c5757988b5daadd1b.tar.bz2
cpython-48b98ded6ef4d9760eeab38c5757988b5daadd1b.zip
strxfrm and strcoll are conditionally defined, alwsy provide some impl
Diffstat (limited to 'Lib/locale.py')
-rw-r--r--Lib/locale.py28
1 files changed, 17 insertions, 11 deletions
diff --git a/Lib/locale.py b/Lib/locale.py
index 448b018a618..eb8b33d5ec0 100644
--- a/Lib/locale.py
+++ b/Lib/locale.py
@@ -26,6 +26,18 @@ __all__ = ["getlocale", "getdefaultlocale", "getpreferredencoding", "Error",
"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 @@ except ImportError:
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