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
266e4548
Kaydet (Commit)
266e4548
authored
May 21, 2010
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
ensure the last line has a trailing newline #8782
üst
dd59f1bf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
0 deletions
+17
-0
linecache.py
Lib/linecache.py
+2
-0
test_linecache.py
Lib/test/test_linecache.py
+12
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/linecache.py
Dosyayı görüntüle @
266e4548
...
...
@@ -133,6 +133,8 @@ def updatecache(filename, module_globals=None):
except
IOError
,
msg
:
## print '*** Cannot open', fullname, ':', msg
return
[]
if
lines
and
not
lines
[
-
1
]
.
endswith
(
'
\n
'
):
lines
[
-
1
]
+=
'
\n
'
size
,
mtime
=
stat
.
st_size
,
stat
.
st_mtime
cache
[
filename
]
=
size
,
mtime
,
lines
,
fullname
return
lines
Lib/test/test_linecache.py
Dosyayı görüntüle @
266e4548
...
...
@@ -31,6 +31,11 @@ a = f()
'''
SOURCE_3
=
'''
def f():
return 3'''
# No ending newline
class
LineCacheTests
(
unittest
.
TestCase
):
def
test_getline
(
self
):
...
...
@@ -63,6 +68,13 @@ class LineCacheTests(unittest.TestCase):
empty
=
linecache
.
getlines
(
'a/b/c/__init__.py'
)
self
.
assertEquals
(
empty
,
[])
def
test_no_ending_newline
(
self
):
self
.
addCleanup
(
support
.
unlink
,
support
.
TESTFN
)
with
open
(
support
.
TESTFN
,
"w"
)
as
fp
:
fp
.
write
(
SOURCE_3
)
lines
=
linecache
.
getlines
(
support
.
TESTFN
)
self
.
assertEqual
(
lines
,
[
"
\n
"
,
"def f():
\n
"
,
" return 3
\n
"
])
def
test_clearcache
(
self
):
cached
=
[]
for
entry
in
TESTS
:
...
...
Misc/NEWS
Dosyayı görüntüle @
266e4548
...
...
@@ -29,6 +29,9 @@ C-API
Library
-------
- Issue #8782: Add a trailing newline in linecache.updatecache to the last line
of files without one.
- Issue #8729: Return NotImplemented from collections.Mapping.__eq__ when
comparing to a non-mapping.
...
...
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