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
90ce5d46
Kaydet (Commit)
90ce5d46
authored
Nis 04, 2016
tarafından
Przemysław Suliga
Kaydeden (comit)
Tim Graham
Nis 05, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #26462 -- Fixed Python 2 UnicodeEncodeError when warning about long cache keys.
üst
369fa471
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
3 deletions
+19
-3
base.py
django/core/cache/backends/base.py
+1
-1
tests.py
tests/cache/tests.py
+18
-2
No files found.
django/core/cache/backends/base.py
Dosyayı görüntüle @
90ce5d46
...
@@ -235,7 +235,7 @@ class BaseCache(object):
...
@@ -235,7 +235,7 @@ class BaseCache(object):
"""
"""
if
len
(
key
)
>
MEMCACHE_MAX_KEY_LENGTH
:
if
len
(
key
)
>
MEMCACHE_MAX_KEY_LENGTH
:
warnings
.
warn
(
'Cache key will cause errors if used with memcached: '
warnings
.
warn
(
'Cache key will cause errors if used with memcached: '
'
%
s
(longer than
%
s)'
%
(
key
,
MEMCACHE_MAX_KEY_LENGTH
),
'
%
r
(longer than
%
s)'
%
(
key
,
MEMCACHE_MAX_KEY_LENGTH
),
CacheKeyWarning
)
CacheKeyWarning
)
for
char
in
key
:
for
char
in
key
:
if
ord
(
char
)
<
33
or
ord
(
char
)
==
127
:
if
ord
(
char
)
<
33
or
ord
(
char
)
==
127
:
...
...
tests/cache/tests.py
Dosyayı görüntüle @
90ce5d46
...
@@ -585,15 +585,31 @@ class BaseCacheTests(object):
...
@@ -585,15 +585,31 @@ class BaseCacheTests(object):
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
"always"
)
warnings
.
simplefilter
(
"always"
)
# memcached does not allow whitespace or control characters in keys
# memcached does not allow whitespace or control characters in keys
cache
.
set
(
'key with spaces'
,
'value'
)
key
=
'key with spaces and 清'
cache
.
set
(
key
,
'value'
)
self
.
assertEqual
(
len
(
w
),
1
)
self
.
assertEqual
(
len
(
w
),
1
)
self
.
assertIsInstance
(
w
[
0
]
.
message
,
CacheKeyWarning
)
self
.
assertIsInstance
(
w
[
0
]
.
message
,
CacheKeyWarning
)
self
.
assertEqual
(
# warnings.warn() crashes on Python 2 if message isn't
# coercible to str.
str
(
w
[
0
]
.
message
.
args
[
0
]),
"Cache key contains characters that will cause errors if used "
"with memcached:
%
r"
%
key
,
)
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
"always"
)
warnings
.
simplefilter
(
"always"
)
# memcached limits key length to 250
# memcached limits key length to 250
cache
.
set
(
'a'
*
251
,
'value'
)
key
=
(
'a'
*
250
)
+
'清'
cache
.
set
(
key
,
'value'
)
self
.
assertEqual
(
len
(
w
),
1
)
self
.
assertEqual
(
len
(
w
),
1
)
self
.
assertIsInstance
(
w
[
0
]
.
message
,
CacheKeyWarning
)
self
.
assertIsInstance
(
w
[
0
]
.
message
,
CacheKeyWarning
)
self
.
assertEqual
(
# warnings.warn() crashes on Python 2 if message isn't
# coercible to str.
str
(
w
[
0
]
.
message
.
args
[
0
]),
'Cache key will cause errors if used with memcached: '
'
%
r (longer than
%
s)'
%
(
key
,
250
),
)
finally
:
finally
:
cache
.
key_func
=
old_func
cache
.
key_func
=
old_func
...
...
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