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
2626ea4a
Kaydet (Commit)
2626ea4a
authored
May 31, 2012
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #14681 -- Do not set mode to None on file-like objects.
gzip.GzipFile does not support files with mode set to None.
üst
4b28ea37
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
base.py
django/core/files/base.py
+2
-1
tests.py
tests/modeltests/files/tests.py
+12
-1
No files found.
django/core/files/base.py
Dosyayı görüntüle @
2626ea4a
...
...
@@ -12,7 +12,8 @@ class File(FileProxyMixin):
if
name
is
None
:
name
=
getattr
(
file
,
'name'
,
None
)
self
.
name
=
name
self
.
mode
=
getattr
(
file
,
'mode'
,
None
)
if
hasattr
(
file
,
'mode'
):
self
.
mode
=
file
.
mode
def
__str__
(
self
):
return
smart_str
(
self
.
name
or
''
)
...
...
tests/modeltests/files/tests.py
Dosyayı görüntüle @
2626ea4a
from
__future__
import
absolute_import
import
gzip
import
shutil
import
tempfile
...
...
@@ -8,11 +9,12 @@ from django.core.files import File
from
django.core.files.base
import
ContentFile
from
django.core.files.uploadedfile
import
SimpleUploadedFile
from
django.test
import
TestCase
from
django.utils
import
unittest
from
.models
import
Storage
,
temp_storage
,
temp_storage_location
class
FileTests
(
TestCase
):
class
File
Storage
Tests
(
TestCase
):
def
tearDown
(
self
):
shutil
.
rmtree
(
temp_storage_location
)
...
...
@@ -106,6 +108,8 @@ class FileTests(TestCase):
obj3
.
default
.
delete
()
obj4
.
random
.
delete
()
class
FileTests
(
unittest
.
TestCase
):
def
test_context_manager
(
self
):
orig_file
=
tempfile
.
TemporaryFile
()
base_file
=
File
(
orig_file
)
...
...
@@ -114,3 +118,10 @@ class FileTests(TestCase):
self
.
assertFalse
(
f
.
closed
)
self
.
assertTrue
(
f
.
closed
)
self
.
assertTrue
(
orig_file
.
closed
)
def
test_file_mode
(
self
):
# Should not set mode to None if it is not present.
# See #14681, stdlib gzip module crashes if mode is set to None
file
=
SimpleUploadedFile
(
"mode_test.txt"
,
"content"
)
self
.
assertFalse
(
hasattr
(
file
,
'mode'
))
g
=
gzip
.
GzipFile
(
fileobj
=
file
)
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