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
bbbbe8eb
Kaydet (Commit)
bbbbe8eb
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 now work for unrolled files.
Remove obsoleted xreadline method.
üst
4b109cb4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
10 deletions
+63
-10
tempfile.py
Lib/tempfile.py
+20
-10
test_tempfile.py
Lib/test/test_tempfile.py
+39
-0
NEWS
Misc/NEWS
+4
-0
No files found.
Lib/tempfile.py
Dosyayı görüntüle @
bbbbe8eb
...
@@ -546,7 +546,12 @@ class SpooledTemporaryFile:
...
@@ -546,7 +546,12 @@ class SpooledTemporaryFile:
@property
@property
def
encoding
(
self
):
def
encoding
(
self
):
return
self
.
_file
.
encoding
try
:
return
self
.
_file
.
encoding
except
AttributeError
:
if
'b'
in
self
.
_TemporaryFileArgs
[
'mode'
]:
raise
return
self
.
_TemporaryFileArgs
[
'encoding'
]
def
fileno
(
self
):
def
fileno
(
self
):
self
.
rollover
()
self
.
rollover
()
...
@@ -560,18 +565,26 @@ class SpooledTemporaryFile:
...
@@ -560,18 +565,26 @@ class SpooledTemporaryFile:
@property
@property
def
mode
(
self
):
def
mode
(
self
):
return
self
.
_file
.
mode
try
:
return
self
.
_file
.
mode
except
AttributeError
:
return
self
.
_TemporaryFileArgs
[
'mode'
]
@property
@property
def
name
(
self
):
def
name
(
self
):
return
self
.
_file
.
name
try
:
return
self
.
_file
.
name
except
AttributeError
:
return
None
@property
@property
def
newlines
(
self
):
def
newlines
(
self
):
return
self
.
_file
.
newlines
try
:
return
self
.
_file
.
newlines
def
next
(
self
):
except
AttributeError
:
return
self
.
_file
.
next
if
'b'
in
self
.
_TemporaryFileArgs
[
'mode'
]:
raise
return
self
.
_TemporaryFileArgs
[
'newline'
]
def
read
(
self
,
*
args
):
def
read
(
self
,
*
args
):
return
self
.
_file
.
read
(
*
args
)
return
self
.
_file
.
read
(
*
args
)
...
@@ -607,9 +620,6 @@ class SpooledTemporaryFile:
...
@@ -607,9 +620,6 @@ class SpooledTemporaryFile:
self
.
_check
(
file
)
self
.
_check
(
file
)
return
rv
return
rv
def
xreadlines
(
self
,
*
args
):
return
self
.
_file
.
xreadlines
(
*
args
)
class
TemporaryDirectory
(
object
):
class
TemporaryDirectory
(
object
):
"""Create and return a temporary directory. This has the same
"""Create and return a temporary directory. This has the same
...
...
Lib/test/test_tempfile.py
Dosyayı görüntüle @
bbbbe8eb
...
@@ -808,6 +808,26 @@ class test_SpooledTemporaryFile(TC):
...
@@ -808,6 +808,26 @@ class test_SpooledTemporaryFile(TC):
seek
(
0
,
0
)
seek
(
0
,
0
)
self
.
assertEqual
(
read
(
70
),
b
'a'
*
35
+
b
'b'
*
35
)
self
.
assertEqual
(
read
(
70
),
b
'a'
*
35
+
b
'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
,
'rb+'
)
self
.
assertIsNotNone
(
f
.
name
)
with
self
.
assertRaises
(
AttributeError
):
f
.
newlines
with
self
.
assertRaises
(
AttributeError
):
f
.
encoding
def
test_text_mode
(
self
):
def
test_text_mode
(
self
):
# Creating a SpooledTemporaryFile with a text mode should produce
# Creating a SpooledTemporaryFile with a text mode should produce
# a file object reading and writing (Unicode) text strings.
# a file object reading and writing (Unicode) text strings.
...
@@ -818,6 +838,12 @@ class test_SpooledTemporaryFile(TC):
...
@@ -818,6 +838,12 @@ class test_SpooledTemporaryFile(TC):
f
.
write
(
"def
\n
"
)
f
.
write
(
"def
\n
"
)
f
.
seek
(
0
)
f
.
seek
(
0
)
self
.
assertEqual
(
f
.
read
(),
"abc
\n
def
\n
"
)
self
.
assertEqual
(
f
.
read
(),
"abc
\n
def
\n
"
)
self
.
assertFalse
(
f
.
_rolled
)
self
.
assertEqual
(
f
.
mode
,
'w+'
)
self
.
assertIsNone
(
f
.
name
)
self
.
assertIsNone
(
f
.
newlines
)
self
.
assertIsNone
(
f
.
encoding
)
f
.
write
(
"xyzzy
\n
"
)
f
.
write
(
"xyzzy
\n
"
)
f
.
seek
(
0
)
f
.
seek
(
0
)
self
.
assertEqual
(
f
.
read
(),
"abc
\n
def
\n
xyzzy
\n
"
)
self
.
assertEqual
(
f
.
read
(),
"abc
\n
def
\n
xyzzy
\n
"
)
...
@@ -825,6 +851,11 @@ class test_SpooledTemporaryFile(TC):
...
@@ -825,6 +851,11 @@ class test_SpooledTemporaryFile(TC):
f
.
write
(
"foo
\x1a
bar
\n
"
)
f
.
write
(
"foo
\x1a
bar
\n
"
)
f
.
seek
(
0
)
f
.
seek
(
0
)
self
.
assertEqual
(
f
.
read
(),
"abc
\n
def
\n
xyzzy
\n
foo
\x1a
bar
\n
"
)
self
.
assertEqual
(
f
.
read
(),
"abc
\n
def
\n
xyzzy
\n
foo
\x1a
bar
\n
"
)
self
.
assertTrue
(
f
.
_rolled
)
self
.
assertEqual
(
f
.
mode
,
'w+'
)
self
.
assertIsNotNone
(
f
.
name
)
self
.
assertEqual
(
f
.
newlines
,
'
\n
'
)
self
.
assertIsNotNone
(
f
.
encoding
)
def
test_text_newline_and_encoding
(
self
):
def
test_text_newline_and_encoding
(
self
):
f
=
tempfile
.
SpooledTemporaryFile
(
mode
=
'w+'
,
max_size
=
10
,
f
=
tempfile
.
SpooledTemporaryFile
(
mode
=
'w+'
,
max_size
=
10
,
...
@@ -833,11 +864,19 @@ class test_SpooledTemporaryFile(TC):
...
@@ -833,11 +864,19 @@ class test_SpooledTemporaryFile(TC):
f
.
seek
(
0
)
f
.
seek
(
0
)
self
.
assertEqual
(
f
.
read
(),
"
\u039B\r\n
"
)
self
.
assertEqual
(
f
.
read
(),
"
\u039B\r\n
"
)
self
.
assertFalse
(
f
.
_rolled
)
self
.
assertFalse
(
f
.
_rolled
)
self
.
assertEqual
(
f
.
mode
,
'w+'
)
self
.
assertIsNone
(
f
.
name
)
self
.
assertIsNone
(
f
.
newlines
)
self
.
assertIsNone
(
f
.
encoding
)
f
.
write
(
"
\u039B
"
*
20
+
"
\r\n
"
)
f
.
write
(
"
\u039B
"
*
20
+
"
\r\n
"
)
f
.
seek
(
0
)
f
.
seek
(
0
)
self
.
assertEqual
(
f
.
read
(),
"
\u039B\r\n
"
+
(
"
\u039B
"
*
20
)
+
"
\r\n
"
)
self
.
assertEqual
(
f
.
read
(),
"
\u039B\r\n
"
+
(
"
\u039B
"
*
20
)
+
"
\r\n
"
)
self
.
assertTrue
(
f
.
_rolled
)
self
.
assertTrue
(
f
.
_rolled
)
self
.
assertEqual
(
f
.
mode
,
'w+'
)
self
.
assertIsNotNone
(
f
.
name
)
self
.
assertIsNotNone
(
f
.
newlines
)
self
.
assertEqual
(
f
.
encoding
,
'utf-8'
)
def
test_context_manager_before_rollover
(
self
):
def
test_context_manager_before_rollover
(
self
):
# A SpooledTemporaryFile can be used as a context manager
# A SpooledTemporaryFile can be used as a context manager
...
...
Misc/NEWS
Dosyayı görüntüle @
bbbbe8eb
...
@@ -215,6 +215,10 @@ Core and Builtins
...
@@ -215,6 +215,10 @@ Core and Builtins
Library
Library
-------
-------
- Issue #10355: In SpooledTemporaryFile class mode, name, encoding and
newlines properties now work for unrolled files. Obsoleted and never
working on Python 3 xreadline method now removed.
- Issue #16686: Fixed a lot of bugs in audioop module. Fixed crashes in
- Issue #16686: Fixed a lot of bugs in audioop module. Fixed crashes in
avgpp(), maxpp() and ratecv(). Fixed an integer overflow in add(), bias(),
avgpp(), maxpp() and ratecv(). Fixed an integer overflow in add(), bias(),
and ratecv(). reverse(), lin2lin() and ratecv() no more lose precision for
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