Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
e08496b6
Kaydet (Commit)
e08496b6
authored
Kas 27, 2015
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Closes #25742: locale.setlocale() now accepts a Unicode string for its second
parameter.
üst
916c7c7a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
1 deletion
+18
-1
locale.py
Lib/locale.py
+5
-1
test_locale.py
Lib/test/test_locale.py
+10
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/locale.py
Dosyayı görüntüle @
e08496b6
...
...
@@ -18,6 +18,10 @@ import re
import
operator
import
functools
# keep a copy of the builtin str type, because 'str' name is overriden
# in globals by a function below
_str
=
str
try
:
_unicode
=
unicode
except
NameError
:
...
...
@@ -573,7 +577,7 @@ def setlocale(category, locale=None):
category may be given as one of the LC_* values.
"""
if
locale
and
type
(
locale
)
is
not
type
(
""
):
if
locale
and
not
isinstance
(
locale
,
(
_str
,
_unicode
)
):
# convert to string
locale
=
normalize
(
_build_localename
(
locale
))
return
_setlocale
(
category
,
locale
)
...
...
Lib/test/test_locale.py
Dosyayı görüntüle @
e08496b6
...
...
@@ -493,6 +493,16 @@ class TestMiscellaneous(unittest.TestCase):
# longer accept unicode strings.
self
.
assertEqual
(
locale
.
normalize
(
u'en_US'
),
'en_US.ISO8859-1'
)
def
test_setlocale_unicode
(
self
):
old_loc
=
locale
.
getlocale
(
locale
.
LC_ALL
)
try
:
user_locale
=
locale
.
setlocale
(
locale
.
LC_ALL
,
''
)
unicode_locale
=
user_locale
.
decode
(
'utf-8'
)
user_locale2
=
locale
.
setlocale
(
locale
.
LC_ALL
,
unicode_locale
)
self
.
assertEqual
(
user_locale
,
user_locale2
)
finally
:
locale
.
setlocale
(
locale
.
LC_ALL
,
old_loc
)
def
test_main
():
tests
=
[
...
...
Misc/NEWS
Dosyayı görüntüle @
e08496b6
...
...
@@ -20,6 +20,9 @@ Core and Builtins
Library
-------
- Issue #25742: :func:`locale.setlocale` now accepts a Unicode string for
its second parameter.
- Issue #10131: Fixed deep copying of minidom documents. Based on patch
by Marian Ganisin.
...
...
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