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
beaa3ada
Kaydet (Commit)
beaa3ada
authored
Şub 09, 2013
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #10355: SpooledTemporaryFile properties and xreadline method now work for unrolled files.
üst
62e709c5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
11 deletions
+48
-11
tempfile.py
Lib/tempfile.py
+12
-11
test_tempfile.py
Lib/test/test_tempfile.py
+31
-0
NEWS
Misc/NEWS
+5
-0
No files found.
Lib/tempfile.py
Dosyayı görüntüle @
beaa3ada
...
...
@@ -546,10 +546,6 @@ class SpooledTemporaryFile:
def
closed
(
self
):
return
self
.
_file
.
closed
@property
def
encoding
(
self
):
return
self
.
_file
.
encoding
def
fileno
(
self
):
self
.
rollover
()
return
self
.
_file
.
fileno
()
...
...
@@ -562,15 +558,17 @@ class SpooledTemporaryFile:
@property
def
mode
(
self
):
return
self
.
_file
.
mode
try
:
return
self
.
_file
.
mode
except
AttributeError
:
return
self
.
_TemporaryFileArgs
[
0
]
@property
def
name
(
self
):
return
self
.
_file
.
name
@property
def
newlines
(
self
):
return
self
.
_file
.
newlines
try
:
return
self
.
_file
.
name
except
AttributeError
:
return
None
def
next
(
self
):
return
self
.
_file
.
next
...
...
@@ -610,4 +608,7 @@ class SpooledTemporaryFile:
return
rv
def
xreadlines
(
self
,
*
args
):
return
self
.
_file
.
xreadlines
(
*
args
)
try
:
return
self
.
_file
.
xreadlines
(
*
args
)
except
AttributeError
:
return
iter
(
self
.
_file
.
readlines
(
*
args
))
Lib/test/test_tempfile.py
Dosyayı görüntüle @
beaa3ada
...
...
@@ -738,6 +738,17 @@ class test_SpooledTemporaryFile(TC):
f
.
write
(
b
'x'
)
self
.
assertTrue
(
f
.
_rolled
)
def
test_xreadlines
(
self
):
f
=
self
.
do_create
(
max_size
=
20
)
f
.
write
(
b
'abc
\n
'
*
5
)
f
.
seek
(
0
)
self
.
assertFalse
(
f
.
_rolled
)
self
.
assertEqual
(
list
(
f
.
xreadlines
()),
[
b
'abc
\n
'
]
*
5
)
f
.
write
(
b
'x
\n
y'
)
self
.
assertTrue
(
f
.
_rolled
)
f
.
seek
(
0
)
self
.
assertEqual
(
list
(
f
.
xreadlines
()),
[
b
'abc
\n
'
]
*
5
+
[
b
'x
\n
'
,
b
'y'
])
def
test_sparse
(
self
):
# A SpooledTemporaryFile that is written late in the file will extend
# when that occurs
...
...
@@ -793,6 +804,26 @@ class test_SpooledTemporaryFile(TC):
seek
(
0
,
0
)
self
.
assertTrue
(
read
(
70
)
==
'a'
*
35
+
'b'
*
35
)
def
test_properties
(
self
):
f
=
tempfile
.
SpooledTemporaryFile
(
max_size
=
10
)
f
.
write
(
b
'x'
*
10
)
self
.
assertFalse
(
f
.
_rolled
)
self
.
assertEqual
(
f
.
mode
,
'w+b'
)
self
.
assertIsNone
(
f
.
name
)
with
self
.
assertRaises
(
AttributeError
):
f
.
newlines
with
self
.
assertRaises
(
AttributeError
):
f
.
encoding
f
.
write
(
b
'x'
)
self
.
assertTrue
(
f
.
_rolled
)
self
.
assertEqual
(
f
.
mode
,
'w+b'
)
self
.
assertIsNotNone
(
f
.
name
)
with
self
.
assertRaises
(
AttributeError
):
f
.
newlines
with
self
.
assertRaises
(
AttributeError
):
f
.
encoding
def
test_context_manager_before_rollover
(
self
):
# A SpooledTemporaryFile can be used as a context manager
with
tempfile
.
SpooledTemporaryFile
(
max_size
=
1
)
as
f
:
...
...
Misc/NEWS
Dosyayı görüntüle @
beaa3ada
...
...
@@ -202,6 +202,11 @@ Core and Builtins
Library
-------
- Issue #10355: In SpooledTemporaryFile class mode and name properties and
xreadlines method now work for unrolled files. encoding and newlines
properties now removed as they have no sense and always produced
AttributeError.
- Issue #16686: Fixed a lot of bugs in audioop module. Fixed crashes in
avgpp(), maxpp() and ratecv(). Fixed an integer overflow in add(), bias(),
and ratecv(). reverse(), lin2lin() and ratecv() no more lose precision for
...
...
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