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
9e62ff28
Kaydet (Commit)
9e62ff28
authored
Eki 18, 2003
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Patch #822994: Consolidate tests for self.closed.
üst
6828e18a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
18 deletions
+14
-18
StringIO.py
Lib/StringIO.py
+14
-18
No files found.
Lib/StringIO.py
Dosyayı görüntüle @
9e62ff28
...
@@ -35,6 +35,10 @@ except ImportError:
...
@@ -35,6 +35,10 @@ except ImportError:
__all__
=
[
"StringIO"
]
__all__
=
[
"StringIO"
]
def
_complain_ifclosed
(
closed
):
if
closed
:
raise
ValueError
,
"I/O operation on closed file"
class
StringIO
:
class
StringIO
:
"""class StringIO([buffer])
"""class StringIO([buffer])
...
@@ -55,7 +59,7 @@ class StringIO:
...
@@ -55,7 +59,7 @@ class StringIO:
self
.
len
=
len
(
buf
)
self
.
len
=
len
(
buf
)
self
.
buflist
=
[]
self
.
buflist
=
[]
self
.
pos
=
0
self
.
pos
=
0
self
.
closed
=
0
self
.
closed
=
False
self
.
softspace
=
0
self
.
softspace
=
0
def
__iter__
(
self
):
def
__iter__
(
self
):
...
@@ -73,17 +77,15 @@ class StringIO:
...
@@ -73,17 +77,15 @@ class StringIO:
"""Free the memory buffer.
"""Free the memory buffer.
"""
"""
if
not
self
.
closed
:
if
not
self
.
closed
:
self
.
closed
=
1
self
.
closed
=
True
del
self
.
buf
,
self
.
pos
del
self
.
buf
,
self
.
pos
def
isatty
(
self
):
def
isatty
(
self
):
if
self
.
closed
:
_complain_ifclosed
(
self
.
closed
)
raise
ValueError
,
"I/O operation on closed file"
return
False
return
False
def
seek
(
self
,
pos
,
mode
=
0
):
def
seek
(
self
,
pos
,
mode
=
0
):
if
self
.
closed
:
_complain_ifclosed
(
self
.
closed
)
raise
ValueError
,
"I/O operation on closed file"
if
self
.
buflist
:
if
self
.
buflist
:
self
.
buf
+=
''
.
join
(
self
.
buflist
)
self
.
buf
+=
''
.
join
(
self
.
buflist
)
self
.
buflist
=
[]
self
.
buflist
=
[]
...
@@ -94,13 +96,11 @@ class StringIO:
...
@@ -94,13 +96,11 @@ class StringIO:
self
.
pos
=
max
(
0
,
pos
)
self
.
pos
=
max
(
0
,
pos
)
def
tell
(
self
):
def
tell
(
self
):
if
self
.
closed
:
_complain_ifclosed
(
self
.
closed
)
raise
ValueError
,
"I/O operation on closed file"
return
self
.
pos
return
self
.
pos
def
read
(
self
,
n
=
-
1
):
def
read
(
self
,
n
=
-
1
):
if
self
.
closed
:
_complain_ifclosed
(
self
.
closed
)
raise
ValueError
,
"I/O operation on closed file"
if
self
.
buflist
:
if
self
.
buflist
:
self
.
buf
+=
''
.
join
(
self
.
buflist
)
self
.
buf
+=
''
.
join
(
self
.
buflist
)
self
.
buflist
=
[]
self
.
buflist
=
[]
...
@@ -113,8 +113,7 @@ class StringIO:
...
@@ -113,8 +113,7 @@ class StringIO:
return
r
return
r
def
readline
(
self
,
length
=
None
):
def
readline
(
self
,
length
=
None
):
if
self
.
closed
:
_complain_ifclosed
(
self
.
closed
)
raise
ValueError
,
"I/O operation on closed file"
if
self
.
buflist
:
if
self
.
buflist
:
self
.
buf
+=
''
.
join
(
self
.
buflist
)
self
.
buf
+=
''
.
join
(
self
.
buflist
)
self
.
buflist
=
[]
self
.
buflist
=
[]
...
@@ -143,8 +142,7 @@ class StringIO:
...
@@ -143,8 +142,7 @@ class StringIO:
return
lines
return
lines
def
truncate
(
self
,
size
=
None
):
def
truncate
(
self
,
size
=
None
):
if
self
.
closed
:
_complain_ifclosed
(
self
.
closed
)
raise
ValueError
,
"I/O operation on closed file"
if
size
is
None
:
if
size
is
None
:
size
=
self
.
pos
size
=
self
.
pos
elif
size
<
0
:
elif
size
<
0
:
...
@@ -154,8 +152,7 @@ class StringIO:
...
@@ -154,8 +152,7 @@ class StringIO:
self
.
buf
=
self
.
getvalue
()[:
size
]
self
.
buf
=
self
.
getvalue
()[:
size
]
def
write
(
self
,
s
):
def
write
(
self
,
s
):
if
self
.
closed
:
_complain_ifclosed
(
self
.
closed
)
raise
ValueError
,
"I/O operation on closed file"
if
not
s
:
return
if
not
s
:
return
# Force s to be a string or unicode
# Force s to be a string or unicode
if
not
isinstance
(
s
,
basestring
):
if
not
isinstance
(
s
,
basestring
):
...
@@ -185,8 +182,7 @@ class StringIO:
...
@@ -185,8 +182,7 @@ class StringIO:
self
.
write
(
''
.
join
(
list
))
self
.
write
(
''
.
join
(
list
))
def
flush
(
self
):
def
flush
(
self
):
if
self
.
closed
:
_complain_ifclosed
(
self
.
closed
)
raise
ValueError
,
"I/O operation on closed file"
def
getvalue
(
self
):
def
getvalue
(
self
):
"""
"""
...
...
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