Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
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
django
Commits
142c2721
Kaydet (Commit)
142c2721
authored
May 02, 2014
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #22565 -- Prevented pgettext_lazy crash with bytestring input
Thanks ygbo for the report.
üst
d1799233
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
5 deletions
+21
-5
trans_real.py
django/utils/translation/trans_real.py
+2
-1
1.6.5.txt
docs/releases/1.6.5.txt
+3
-0
tests.py
tests/i18n/tests.py
+16
-4
No files found.
django/utils/translation/trans_real.py
Dosyayı görüntüle @
142c2721
...
...
@@ -314,7 +314,8 @@ def pgettext(context, message):
result
=
ugettext
(
msg_with_ctxt
)
if
CONTEXT_SEPARATOR
in
result
:
# Translation not found
result
=
message
# force unicode, because lazy version expects unicode
result
=
force_text
(
message
)
return
result
...
...
docs/releases/1.6.5.txt
Dosyayı görüntüle @
142c2721
...
...
@@ -11,3 +11,6 @@ Bugfixes
* Made the ``year_lookup_bounds_for_datetime_field`` Oracle backend method
Python 3 compatible (`#22551 <http://code.djangoproject.com/ticket/22551>`_).
* Fixed ``pgettext_lazy`` crash when receiving bytestring content on Python 2
(`#22565 <http://code.djangoproject.com/ticket/22565>`_).
tests/i18n/tests.py
Dosyayı görüntüle @
142c2721
...
...
@@ -9,6 +9,7 @@ from importlib import import_module
import
os
import
pickle
from
threading
import
local
from
unittest
import
skipUnless
from
django.conf
import
settings
from
django.template
import
Template
,
Context
...
...
@@ -30,7 +31,7 @@ from django.utils.translation import (activate, deactivate,
ugettext
,
ugettext_lazy
,
ngettext_lazy
,
ungettext_lazy
,
pgettext
,
pgettext
,
pgettext_lazy
,
npgettext
,
npgettext_lazy
,
check_for_language
,
string_concat
,
LANGUAGE_SESSION_KEY
)
...
...
@@ -94,9 +95,20 @@ class TranslationTests(TestCase):
s4
=
ugettext_lazy
(
'Some other string'
)
self
.
assertEqual
(
False
,
s
==
s4
)
if
six
.
PY2
:
# On Python 2, gettext_lazy should not transform a bytestring to unicode
self
.
assertEqual
(
gettext_lazy
(
b
"test"
)
.
upper
(),
b
"TEST"
)
@skipUnless
(
six
.
PY2
,
"No more bytestring translations on PY3"
)
def
test_lazy_and_bytestrings
(
self
):
# On Python 2, (n)gettext_lazy should not transform a bytestring to unicode
self
.
assertEqual
(
gettext_lazy
(
b
"test"
)
.
upper
(),
b
"TEST"
)
self
.
assertEqual
((
ngettext_lazy
(
b
"
%
d test"
,
b
"
%
d tests"
)
%
1
)
.
upper
(),
b
"1 TEST"
)
# Other versions of lazy functions always return unicode
self
.
assertEqual
(
ugettext_lazy
(
b
"test"
)
.
upper
(),
"TEST"
)
self
.
assertEqual
((
ungettext_lazy
(
b
"
%
d test"
,
b
"
%
d tests"
)
%
1
)
.
upper
(),
"1 TEST"
)
self
.
assertEqual
(
pgettext_lazy
(
b
"context"
,
b
"test"
)
.
upper
(),
"TEST"
)
self
.
assertEqual
(
(
npgettext_lazy
(
b
"context"
,
b
"
%
d test"
,
b
"
%
d tests"
)
%
1
)
.
upper
(),
"1 TEST"
)
def
test_lazy_pickle
(
self
):
s1
=
ugettext_lazy
(
"test"
)
...
...
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