mirror of
https://github.com/python/cpython.git
synced 2025-09-04 16:01:10 +00:00
strxfrm and strcoll are conditionally defined, alwsy provide some impl
This commit is contained in:
parent
5bacec1864
commit
48b98ded6e
1 changed files with 17 additions and 11 deletions
|
@ -26,6 +26,18 @@ __all__ = ["getlocale", "getdefaultlocale", "getpreferredencoding", "Error",
|
||||||
"normalize", "LC_CTYPE", "LC_COLLATE", "LC_TIME", "LC_MONETARY",
|
"normalize", "LC_CTYPE", "LC_COLLATE", "LC_TIME", "LC_MONETARY",
|
||||||
"LC_NUMERIC", "LC_ALL", "CHAR_MAX"]
|
"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:
|
try:
|
||||||
|
|
||||||
from _locale import *
|
from _locale import *
|
||||||
|
@ -76,17 +88,11 @@ except ImportError:
|
||||||
raise Error('_locale emulation only supports "C" locale')
|
raise Error('_locale emulation only supports "C" locale')
|
||||||
return 'C'
|
return 'C'
|
||||||
|
|
||||||
def strcoll(a,b):
|
# These may or may not exist in _locale, so be sure to set them.
|
||||||
""" strcoll(string,string) -> int.
|
if 'strxfrm' not in globals():
|
||||||
Compares two strings according to the locale.
|
strxfrm = _strxfrm
|
||||||
"""
|
if 'strcoll' not in globals():
|
||||||
return cmp(a,b)
|
strcoll = _strcoll
|
||||||
|
|
||||||
def strxfrm(s):
|
|
||||||
""" strxfrm(string) -> string.
|
|
||||||
Returns a string that behaves for cmp locale-aware.
|
|
||||||
"""
|
|
||||||
return s
|
|
||||||
|
|
||||||
### Number formatting APIs
|
### Number formatting APIs
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue