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
ae557d76
Kaydet (Commit)
ae557d76
authored
Şub 11, 2012
tarafından
Nadeem Vawda
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix seekable() in BZ2File and LZMAFile to check whether the underlying file supports seek().
üst
d7e5c6ed
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
4 deletions
+28
-4
bz2.py
Lib/bz2.py
+5
-2
lzma.py
Lib/lzma.py
+5
-2
test_bz2.py
Lib/test/test_bz2.py
+9
-0
test_lzma.py
Lib/test/test_lzma.py
+9
-0
No files found.
Lib/bz2.py
Dosyayı görüntüle @
ae557d76
...
@@ -138,7 +138,7 @@ class BZ2File(io.BufferedIOBase):
...
@@ -138,7 +138,7 @@ class BZ2File(io.BufferedIOBase):
def
seekable
(
self
):
def
seekable
(
self
):
"""Return whether the file supports seeking."""
"""Return whether the file supports seeking."""
return
self
.
readable
()
return
self
.
readable
()
and
self
.
_fp
.
seekable
()
def
readable
(
self
):
def
readable
(
self
):
"""Return whether the file was opened for reading."""
"""Return whether the file was opened for reading."""
...
@@ -165,9 +165,12 @@ class BZ2File(io.BufferedIOBase):
...
@@ -165,9 +165,12 @@ class BZ2File(io.BufferedIOBase):
raise
io
.
UnsupportedOperation
(
"File not open for writing"
)
raise
io
.
UnsupportedOperation
(
"File not open for writing"
)
def
_check_can_seek
(
self
):
def
_check_can_seek
(
self
):
if
not
self
.
seek
able
():
if
not
self
.
read
able
():
raise
io
.
UnsupportedOperation
(
"Seeking is only supported "
raise
io
.
UnsupportedOperation
(
"Seeking is only supported "
"on files open for reading"
)
"on files open for reading"
)
if
not
self
.
_fp
.
seekable
():
raise
io
.
UnsupportedOperation
(
"The underlying file object "
"does not support seeking"
)
# Fill the readahead buffer if it is empty. Returns False on EOF.
# Fill the readahead buffer if it is empty. Returns False on EOF.
def
_fill_buffer
(
self
):
def
_fill_buffer
(
self
):
...
...
Lib/lzma.py
Dosyayı görüntüle @
ae557d76
...
@@ -165,7 +165,7 @@ class LZMAFile(io.BufferedIOBase):
...
@@ -165,7 +165,7 @@ class LZMAFile(io.BufferedIOBase):
def
seekable
(
self
):
def
seekable
(
self
):
"""Return whether the file supports seeking."""
"""Return whether the file supports seeking."""
return
self
.
readable
()
return
self
.
readable
()
and
self
.
_fp
.
seekable
()
def
readable
(
self
):
def
readable
(
self
):
"""Return whether the file was opened for reading."""
"""Return whether the file was opened for reading."""
...
@@ -192,9 +192,12 @@ class LZMAFile(io.BufferedIOBase):
...
@@ -192,9 +192,12 @@ class LZMAFile(io.BufferedIOBase):
raise
io
.
UnsupportedOperation
(
"File not open for writing"
)
raise
io
.
UnsupportedOperation
(
"File not open for writing"
)
def
_check_can_seek
(
self
):
def
_check_can_seek
(
self
):
if
not
self
.
seek
able
():
if
not
self
.
read
able
():
raise
io
.
UnsupportedOperation
(
"Seeking is only supported "
raise
io
.
UnsupportedOperation
(
"Seeking is only supported "
"on files open for reading"
)
"on files open for reading"
)
if
not
self
.
_fp
.
seekable
():
raise
io
.
UnsupportedOperation
(
"The underlying file object "
"does not support seeking"
)
# Fill the readahead buffer if it is empty. Returns False on EOF.
# Fill the readahead buffer if it is empty. Returns False on EOF.
def
_fill_buffer
(
self
):
def
_fill_buffer
(
self
):
...
...
Lib/test/test_bz2.py
Dosyayı görüntüle @
ae557d76
...
@@ -372,6 +372,15 @@ class BZ2FileTest(BaseTest):
...
@@ -372,6 +372,15 @@ class BZ2FileTest(BaseTest):
bz2f
.
close
()
bz2f
.
close
()
self
.
assertRaises
(
ValueError
,
bz2f
.
seekable
)
self
.
assertRaises
(
ValueError
,
bz2f
.
seekable
)
src
=
BytesIO
(
self
.
DATA
)
src
.
seekable
=
lambda
:
False
bz2f
=
BZ2File
(
fileobj
=
src
)
try
:
self
.
assertFalse
(
bz2f
.
seekable
())
finally
:
bz2f
.
close
()
self
.
assertRaises
(
ValueError
,
bz2f
.
seekable
)
def
testReadable
(
self
):
def
testReadable
(
self
):
bz2f
=
BZ2File
(
fileobj
=
BytesIO
(
self
.
DATA
))
bz2f
=
BZ2File
(
fileobj
=
BytesIO
(
self
.
DATA
))
try
:
try
:
...
...
Lib/test/test_lzma.py
Dosyayı görüntüle @
ae557d76
...
@@ -525,6 +525,15 @@ class FileTestCase(unittest.TestCase):
...
@@ -525,6 +525,15 @@ class FileTestCase(unittest.TestCase):
f
.
close
()
f
.
close
()
self
.
assertRaises
(
ValueError
,
f
.
seekable
)
self
.
assertRaises
(
ValueError
,
f
.
seekable
)
src
=
BytesIO
(
COMPRESSED_XZ
)
src
.
seekable
=
lambda
:
False
f
=
LZMAFile
(
fileobj
=
src
)
try
:
self
.
assertFalse
(
f
.
seekable
())
finally
:
f
.
close
()
self
.
assertRaises
(
ValueError
,
f
.
seekable
)
def
test_readable
(
self
):
def
test_readable
(
self
):
f
=
LZMAFile
(
fileobj
=
BytesIO
(
COMPRESSED_XZ
))
f
=
LZMAFile
(
fileobj
=
BytesIO
(
COMPRESSED_XZ
))
try
:
try
:
...
...
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