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
4cfae027
Kaydet (Commit)
4cfae027
authored
Tem 24, 2011
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #1813: Fix codec lookup and setting/getting locales under Turkish locales.
üst
a620facc
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
2 deletions
+39
-2
locale.py
Lib/locale.py
+8
-1
test_codecs.py
Lib/test/test_codecs.py
+14
-0
test_locale.py
Lib/test/test_locale.py
+13
-0
NEWS
Misc/NEWS
+3
-0
codecs.c
Python/codecs.c
+1
-1
No files found.
Lib/locale.py
Dosyayı görüntüle @
4cfae027
...
@@ -331,6 +331,13 @@ def _test():
...
@@ -331,6 +331,13 @@ def _test():
# overridden below)
# overridden below)
_setlocale
=
setlocale
_setlocale
=
setlocale
# Avoid relying on the locale-dependent .lower() method
# (see issue #1813).
_ascii_lower_map
=
''
.
join
(
chr
(
x
+
32
if
x
>=
ord
(
'A'
)
and
x
<=
ord
(
'Z'
)
else
x
)
for
x
in
range
(
256
)
)
def
normalize
(
localename
):
def
normalize
(
localename
):
""" Returns a normalized locale code for the given locale
""" Returns a normalized locale code for the given locale
...
@@ -348,7 +355,7 @@ def normalize(localename):
...
@@ -348,7 +355,7 @@ def normalize(localename):
"""
"""
# Normalize the locale name and extract the encoding
# Normalize the locale name and extract the encoding
fullname
=
localename
.
lower
(
)
fullname
=
localename
.
translate
(
_ascii_lower_map
)
if
':'
in
fullname
:
if
':'
in
fullname
:
# ':' is sometimes used as encoding delimiter.
# ':' is sometimes used as encoding delimiter.
fullname
=
fullname
.
replace
(
':'
,
'.'
)
fullname
=
fullname
.
replace
(
':'
,
'.'
)
...
...
Lib/test/test_codecs.py
Dosyayı görüntüle @
4cfae027
from
test
import
test_support
from
test
import
test_support
import
unittest
import
unittest
import
codecs
import
codecs
import
locale
import
sys
,
StringIO
,
_testcapi
import
sys
,
StringIO
,
_testcapi
class
Queue
(
object
):
class
Queue
(
object
):
...
@@ -1153,6 +1154,19 @@ class CodecsModuleTest(unittest.TestCase):
...
@@ -1153,6 +1154,19 @@ class CodecsModuleTest(unittest.TestCase):
self
.
assertRaises
(
TypeError
,
codecs
.
getwriter
)
self
.
assertRaises
(
TypeError
,
codecs
.
getwriter
)
self
.
assertRaises
(
LookupError
,
codecs
.
getwriter
,
"__spam__"
)
self
.
assertRaises
(
LookupError
,
codecs
.
getwriter
,
"__spam__"
)
def
test_lookup_issue1813
(
self
):
# Issue #1813: under Turkish locales, lookup of some codecs failed
# because 'I' is lowercased as a dotless "i"
oldlocale
=
locale
.
getlocale
(
locale
.
LC_CTYPE
)
self
.
addCleanup
(
locale
.
setlocale
,
locale
.
LC_CTYPE
,
oldlocale
)
try
:
locale
.
setlocale
(
locale
.
LC_CTYPE
,
'tr_TR'
)
except
locale
.
Error
:
# Unsupported locale on this system
self
.
skipTest
(
'test needs Turkish locale'
)
c
=
codecs
.
lookup
(
'ASCII'
)
self
.
assertEqual
(
c
.
name
,
'ascii'
)
class
StreamReaderTest
(
unittest
.
TestCase
):
class
StreamReaderTest
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
...
...
Lib/test/test_locale.py
Dosyayı görüntüle @
4cfae027
...
@@ -396,6 +396,19 @@ class TestMiscellaneous(unittest.TestCase):
...
@@ -396,6 +396,19 @@ class TestMiscellaneous(unittest.TestCase):
# crasher from bug #7419
# crasher from bug #7419
self
.
assertRaises
(
locale
.
Error
,
locale
.
setlocale
,
12345
)
self
.
assertRaises
(
locale
.
Error
,
locale
.
setlocale
,
12345
)
def
test_getsetlocale_issue1813
(
self
):
# Issue #1813: setting and getting the locale under a Turkish locale
oldlocale
=
locale
.
getlocale
()
self
.
addCleanup
(
locale
.
setlocale
,
locale
.
LC_CTYPE
,
oldlocale
)
try
:
locale
.
setlocale
(
locale
.
LC_CTYPE
,
'tr_TR'
)
except
locale
.
Error
:
# Unsupported locale on this system
self
.
skipTest
(
'test needs Turkish locale'
)
loc
=
locale
.
getlocale
()
locale
.
setlocale
(
locale
.
LC_CTYPE
,
loc
)
self
.
assertEqual
(
loc
,
locale
.
getlocale
())
def
test_main
():
def
test_main
():
tests
=
[
tests
=
[
...
...
Misc/NEWS
Dosyayı görüntüle @
4cfae027
...
@@ -37,6 +37,9 @@ Core and Builtins
...
@@ -37,6 +37,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #1813: Fix codec lookup and setting/getting locales under Turkish
locales.
- Issue #10883: Fix socket leaks in urllib when using FTP.
- Issue #10883: Fix socket leaks in urllib when using FTP.
- Issue #12592: Make Python build on OpenBSD 5 (and future major releases).
- Issue #12592: Make Python build on OpenBSD 5 (and future major releases).
...
...
Python/codecs.c
Dosyayı görüntüle @
4cfae027
...
@@ -70,7 +70,7 @@ PyObject *normalizestring(const char *string)
...
@@ -70,7 +70,7 @@ PyObject *normalizestring(const char *string)
if
(
ch
==
' '
)
if
(
ch
==
' '
)
ch
=
'-'
;
ch
=
'-'
;
else
else
ch
=
tolower
(
Py_CHARMASK
(
ch
));
ch
=
Py_TOLOWER
(
Py_CHARMASK
(
ch
));
p
[
i
]
=
ch
;
p
[
i
]
=
ch
;
}
}
return
v
;
return
v
;
...
...
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