Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
af080876
Commit
af080876
authored
Jan 17, 2014
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #20086: Restored the use of locale-independing mapping instead of
locale-depending str.lower() in locale.normalize().
parent
8363f777
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
7 deletions
+13
-7
Lib/locale.py
Lib/locale.py
+3
-3
Lib/test/test_locale.py
Lib/test/test_locale.py
+7
-4
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/locale.py
View file @
af080876
...
@@ -379,7 +379,7 @@ def normalize(localename):
...
@@ -379,7 +379,7 @@ def normalize(localename):
# Normalize the locale name and extract the encoding and modifier
# Normalize the locale name and extract the encoding and modifier
if
isinstance
(
localename
,
_unicode
):
if
isinstance
(
localename
,
_unicode
):
localename
=
localename
.
encode
(
'ascii'
)
localename
=
localename
.
encode
(
'ascii'
)
code
=
localename
.
lower
(
)
code
=
localename
.
translate
(
_ascii_lower_map
)
if
':'
in
code
:
if
':'
in
code
:
# ':' is sometimes used as encoding delimiter.
# ':' is sometimes used as encoding delimiter.
code
=
code
.
replace
(
':'
,
'.'
)
code
=
code
.
replace
(
':'
,
'.'
)
...
@@ -414,7 +414,7 @@ def normalize(localename):
...
@@ -414,7 +414,7 @@ def normalize(localename):
#print('lookup without modifier succeeded')
#print('lookup without modifier succeeded')
if
'@'
not
in
code
:
if
'@'
not
in
code
:
return
code
+
'@'
+
modifier
return
code
+
'@'
+
modifier
if
code
.
split
(
'@'
,
1
)[
1
].
lower
(
)
==
modifier
:
if
code
.
split
(
'@'
,
1
)[
1
].
translate
(
_ascii_lower_map
)
==
modifier
:
return
code
return
code
#print('second lookup failed')
#print('second lookup failed')
...
@@ -439,7 +439,7 @@ def normalize(localename):
...
@@ -439,7 +439,7 @@ def normalize(localename):
if
'@'
not
in
code
:
if
'@'
not
in
code
:
return
_replace_encoding
(
code
,
encoding
)
+
'@'
+
modifier
return
_replace_encoding
(
code
,
encoding
)
+
'@'
+
modifier
code
,
defmod
=
code
.
split
(
'@'
,
1
)
code
,
defmod
=
code
.
split
(
'@'
,
1
)
if
defmod
.
lower
(
)
==
modifier
:
if
defmod
.
translate
(
_ascii_lower_map
)
==
modifier
:
return
_replace_encoding
(
code
,
encoding
)
+
'@'
+
defmod
return
_replace_encoding
(
code
,
encoding
)
+
'@'
+
defmod
return
localename
return
localename
...
...
Lib/test/test_locale.py
View file @
af080876
...
@@ -471,9 +471,13 @@ class TestMiscellaneous(unittest.TestCase):
...
@@ -471,9 +471,13 @@ class TestMiscellaneous(unittest.TestCase):
# Issue #1813: setting and getting the locale under a Turkish locale
# Issue #1813: setting and getting the locale under a Turkish locale
oldlocale
=
locale
.
getlocale
()
oldlocale
=
locale
.
getlocale
()
self
.
addCleanup
(
locale
.
setlocale
,
locale
.
LC_CTYPE
,
oldlocale
)
self
.
addCleanup
(
locale
.
setlocale
,
locale
.
LC_CTYPE
,
oldlocale
)
try
:
for
loc
in
(
'tr_TR'
,
'tr_TR.UTF-8'
,
'tr_TR.ISO8859-9'
):
locale
.
setlocale
(
locale
.
LC_CTYPE
,
'tr_TR'
)
try
:
except
locale
.
Error
:
locale
.
setlocale
(
locale
.
LC_CTYPE
,
loc
)
break
except
locale
.
Error
:
continue
else
:
# Unsupported locale on this system
# Unsupported locale on this system
self
.
skipTest
(
'test needs Turkish locale'
)
self
.
skipTest
(
'test needs Turkish locale'
)
loc
=
locale
.
getlocale
()
loc
=
locale
.
getlocale
()
...
@@ -482,7 +486,6 @@ class TestMiscellaneous(unittest.TestCase):
...
@@ -482,7 +486,6 @@ class TestMiscellaneous(unittest.TestCase):
except
Exception
as
e
:
except
Exception
as
e
:
self
.
fail
(
"Failed to set locale %r (default locale is %r): %r"
%
self
.
fail
(
"Failed to set locale %r (default locale is %r): %r"
%
(
loc
,
oldlocale
,
e
))
(
loc
,
oldlocale
,
e
))
print
(
"set locale %r (default locale is %r)"
%
(
loc
,
oldlocale
))
self
.
assertEqual
(
loc
,
locale
.
getlocale
())
self
.
assertEqual
(
loc
,
locale
.
getlocale
())
def
test_normalize_issue12752
(
self
):
def
test_normalize_issue12752
(
self
):
...
...
Misc/NEWS
View file @
af080876
...
@@ -35,6 +35,9 @@ Core and Builtins
...
@@ -35,6 +35,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #20086: Restored the use of locale-independing mapping instead of
locale-depending str.lower() in locale.normalize().
- Issue #20246: Fix buffer overflow in socket.recvfrom_into.
- Issue #20246: Fix buffer overflow in socket.recvfrom_into.
- Issue #19082: Working SimpleXMLRPCServer and xmlrpclib examples, both in
- Issue #19082: Working SimpleXMLRPCServer and xmlrpclib examples, both in
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment