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
aadaa361
Kaydet (Commit)
aadaa361
authored
Mar 08, 2016
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #15068: Avoid creating a reference loop in fileinput.
üst
39f57caf
0554d83f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
13 deletions
+15
-13
fileinput.py
Lib/fileinput.py
+15
-13
No files found.
Lib/fileinput.py
Dosyayı görüntüle @
aadaa361
...
...
@@ -209,7 +209,6 @@ class FileInput:
self
.
_startlineno
=
0
self
.
_filelineno
=
0
self
.
_file
=
None
self
.
_readline
=
self
.
_start_readline
self
.
_isstdin
=
False
self
.
_backupfilename
=
None
# restrict mode argument to reading modes
...
...
@@ -247,15 +246,15 @@ class FileInput:
return
self
def
__next__
(
self
):
line
=
self
.
_readline
()
if
line
:
self
.
_filelineno
+=
1
return
line
if
not
self
.
_file
:
raise
StopIteration
self
.
nextfile
()
# Recursive call
return
self
.
__next__
()
while
True
:
line
=
self
.
_readline
()
if
line
:
self
.
_filelineno
+=
1
return
line
if
not
self
.
_file
:
raise
StopIteration
self
.
nextfile
()
# repeat with next file
def
__getitem__
(
self
,
i
):
if
i
!=
self
.
lineno
():
...
...
@@ -279,7 +278,10 @@ class FileInput:
finally
:
file
=
self
.
_file
self
.
_file
=
None
self
.
_readline
=
self
.
_start_readline
try
:
del
self
.
_readline
# restore FileInput._readline
except
AttributeError
:
pass
try
:
if
file
and
not
self
.
_isstdin
:
file
.
close
()
...
...
@@ -303,7 +305,7 @@ class FileInput:
self
.
nextfile
()
# repeat with next file
def
_
start_
readline
(
self
):
def
_readline
(
self
):
if
not
self
.
_files
:
if
'b'
in
self
.
_mode
:
return
b
''
...
...
@@ -358,7 +360,7 @@ class FileInput:
self
.
_file
=
self
.
_openhook
(
self
.
_filename
,
self
.
_mode
)
else
:
self
.
_file
=
open
(
self
.
_filename
,
self
.
_mode
)
self
.
_readline
=
self
.
_file
.
readline
self
.
_readline
=
self
.
_file
.
readline
# hide FileInput._readline
return
self
.
_readline
()
def
filename
(
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