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
1e9ac504
Kaydet (Commit)
1e9ac504
authored
Kas 21, 2014
tarafından
Sergey Fedoseev
Kaydeden (comit)
Tim Graham
Kas 24, 2014
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #23888 -- Fixed crash in File.__repr__() when name contains unicode.
üst
ebb927c4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
9 deletions
+12
-9
base.py
django/core/files/base.py
+4
-3
1.7.2.txt
docs/releases/1.7.2.txt
+3
-0
tests.py
tests/files/tests.py
+5
-6
No files found.
django/core/files/base.py
Dosyayı görüntüle @
1e9ac504
...
...
@@ -3,10 +3,11 @@ from __future__ import unicode_literals
import
os
from
io
import
BytesIO
,
StringIO
,
UnsupportedOperation
from
django.utils.encoding
import
smart_text
from
django.core.files.utils
import
FileProxyMixin
from
django.utils
import
six
from
django.utils.encoding
import
force_bytes
,
python_2_unicode_compatible
from
django.utils.encoding
import
(
force_bytes
,
force_str
,
python_2_unicode_compatible
,
smart_text
,
)
@python_2_unicode_compatible
...
...
@@ -25,7 +26,7 @@ class File(FileProxyMixin):
return
smart_text
(
self
.
name
or
''
)
def
__repr__
(
self
):
return
"<
%
s:
%
s>"
%
(
self
.
__class__
.
__name__
,
self
or
"None"
)
return
force_str
(
"<
%
s:
%
s>"
%
(
self
.
__class__
.
__name__
,
self
or
"None"
)
)
def
__bool__
(
self
):
return
bool
(
self
.
name
)
...
...
docs/releases/1.7.2.txt
Dosyayı görüntüle @
1e9ac504
...
...
@@ -77,3 +77,6 @@ Bugfixes
* Fixed a crash in migrations when deleting a field that is part of a
``index/unique_together`` constraint (:ticket:`23794`).
* Fixed ``django.core.files.File.__repr__()`` when the file's ``name`` contains
Unicode characters (:ticket:`23888`).
tests/files/tests.py
Dosyayı görüntüle @
1e9ac504
...
...
@@ -26,13 +26,12 @@ else:
class
FileTests
(
unittest
.
TestCase
):
def
test_unicode_uploadedfile_name
(
self
):
"""
Regression test for #8156: files with unicode names I can't quite figure
out the encoding situation between doctest and this file, but the actual
repr doesn't matter; it just shouldn't return a unicode object.
"""
uf
=
UploadedFile
(
name
=
'¿Cómo?'
,
content_type
=
'text'
)
self
.
assertEqual
(
type
(
uf
.
__repr__
()),
str
)
self
.
assertIs
(
type
(
repr
(
uf
)),
str
)
def
test_unicode_file_name
(
self
):
f
=
File
(
None
,
'djángö'
)
self
.
assertIs
(
type
(
repr
(
f
)),
str
)
def
test_context_manager
(
self
):
orig_file
=
tempfile
.
TemporaryFile
()
...
...
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