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
c9f38462
Commit
c9f38462
authored
Nov 04, 2011
by
Petri Lehtinen
Browse files
Options
Browse Files
Download
Plain Diff
Issue #3067: Fix the error raised by locale.setlocale()
parents
e30c0a10
3c85fe07
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
7 deletions
+23
-7
Lib/locale.py
Lib/locale.py
+11
-7
Lib/test/test_locale.py
Lib/test/test_locale.py
+8
-0
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/locale.py
View file @
c9f38462
...
...
@@ -440,13 +440,17 @@ def _build_localename(localetuple):
No aliasing or normalizing takes place.
"""
language
,
encoding
=
localetuple
if
language
is
None
:
language
=
'C'
if
encoding
is
None
:
return
language
else
:
return
language
+
'.'
+
encoding
try
:
language
,
encoding
=
localetuple
if
language
is
None
:
language
=
'C'
if
encoding
is
None
:
return
language
else
:
return
language
+
'.'
+
encoding
except
(
TypeError
,
ValueError
):
raise
TypeError
(
'Locale must be None, a string, or an iterable of two strings -- language code, encoding.'
)
def
getdefaultlocale
(
envvars
=
(
'LC_ALL'
,
'LC_CTYPE'
,
'LANG'
,
'LANGUAGE'
)):
...
...
Lib/test/test_locale.py
View file @
c9f38462
...
...
@@ -409,6 +409,14 @@ class TestMiscellaneous(unittest.TestCase):
locale
.
setlocale
(
locale
.
LC_CTYPE
,
loc
)
self
.
assertEqual
(
loc
,
locale
.
getlocale
(
locale
.
LC_CTYPE
))
def
test_invalid_locale_format_in_localetuple
(
self
):
with
self
.
assertRaises
(
TypeError
):
locale
.
setlocale
(
locale
.
LC_ALL
,
b'fi_FI'
)
def
test_invalid_iterable_in_localetuple
(
self
):
with
self
.
assertRaises
(
TypeError
):
locale
.
setlocale
(
locale
.
LC_ALL
,
(
b'not'
,
b'valid'
))
def
test_main
():
tests
=
[
...
...
Misc/ACKS
View file @
c9f38462
...
...
@@ -768,6 +768,7 @@ John Popplewell
Amrit Prem
Paul Prescod
Donovan Preston
Jyrki Pulliainen
Steve Purcell
Fernando Pérez
Eduardo Pérez
...
...
Misc/NEWS
View file @
c9f38462
...
...
@@ -350,6 +350,9 @@ Core and Builtins
Library
-------
-
Issue
#
3067
:
locale
.
setlocale
()
now
raises
TypeError
if
the
second
argument
is
an
invalid
iterable
.
Initial
patch
by
Jyrki
Pulliainen
.
-
Issue
#
13140
:
Fix
the
daemon_threads
attribute
of
ThreadingMixIn
.
-
Issue
#
13339
:
Fix
compile
error
in
posixmodule
.
c
due
to
missing
semicolon
.
...
...
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