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
8aaeb2f4
Kaydet (Commit)
8aaeb2f4
authored
Agu 04, 2012
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge
üst
84869872
8280b4ba
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
36 deletions
+29
-36
asynchat.py
Lib/asynchat.py
+1
-13
bz2.py
Lib/bz2.py
+28
-23
No files found.
Lib/asynchat.py
Dosyayı görüntüle @
8aaeb2f4
...
...
@@ -49,18 +49,6 @@ import socket
import
asyncore
from
collections
import
deque
def
buffer
(
obj
,
start
=
None
,
stop
=
None
):
# if memoryview objects gain slicing semantics,
# this function will change for the better
# memoryview used for the TypeError
memoryview
(
obj
)
if
start
==
None
:
start
=
0
if
stop
==
None
:
stop
=
len
(
obj
)
x
=
obj
[
start
:
stop
]
## print("buffer type is: %s"%(type(x),))
return
x
class
async_chat
(
asyncore
.
dispatcher
):
"""This is an abstract class. You must derive from this class, and add
...
...
@@ -240,7 +228,7 @@ class async_chat (asyncore.dispatcher):
# handle classic producer behavior
obs
=
self
.
ac_out_buffer_size
try
:
data
=
buffer
(
first
,
0
,
obs
)
data
=
first
[:
obs
]
except
TypeError
:
data
=
first
.
more
()
if
data
:
...
...
Lib/bz2.py
Dosyayı görüntüle @
8aaeb2f4
...
...
@@ -174,29 +174,31 @@ class BZ2File(io.BufferedIOBase):
# Fill the readahead buffer if it is empty. Returns False on EOF.
def
_fill_buffer
(
self
):
if
self
.
_buffer
:
return
True
if
self
.
_decompressor
.
unused_data
:
rawblock
=
self
.
_decompressor
.
unused_data
else
:
rawblock
=
self
.
_fp
.
read
(
_BUFFER_SIZE
)
if
not
rawblock
:
if
self
.
_decompressor
.
eof
:
self
.
_mode
=
_MODE_READ_EOF
self
.
_size
=
self
.
_pos
return
False
# Depending on the input data, our call to the decompressor may not
# return any data. In this case, try again after reading another block.
while
True
:
if
self
.
_buffer
:
return
True
if
self
.
_decompressor
.
unused_data
:
rawblock
=
self
.
_decompressor
.
unused_data
else
:
raise
EOFError
(
"Compressed file ended before the "
"end-of-stream marker was reached"
)
# Continue to next stream.
if
self
.
_decompressor
.
eof
:
self
.
_decompressor
=
BZ2Decompressor
()
rawblock
=
self
.
_fp
.
read
(
_BUFFER_SIZE
)
if
not
rawblock
:
if
self
.
_decompressor
.
eof
:
self
.
_mode
=
_MODE_READ_EOF
self
.
_size
=
self
.
_pos
return
False
else
:
raise
EOFError
(
"Compressed file ended before the "
"end-of-stream marker was reached"
)
# Continue to next stream.
if
self
.
_decompressor
.
eof
:
self
.
_decompressor
=
BZ2Decompressor
()
self
.
_buffer
=
self
.
_decompressor
.
decompress
(
rawblock
)
return
True
self
.
_buffer
=
self
.
_decompressor
.
decompress
(
rawblock
)
# Read data until EOF.
# If return_data is false, consume the data without returning it.
...
...
@@ -256,11 +258,14 @@ class BZ2File(io.BufferedIOBase):
return
self
.
_read_block
(
size
)
def
read1
(
self
,
size
=-
1
):
"""Read up to size uncompressed bytes
with at most one rea
d
from the underlying stream.
"""Read up to size uncompressed bytes
, while trying to avoi
d
making multiple reads
from the underlying stream.
Returns b'' if the file is at EOF.
"""
# Usually, read1() calls _fp.read() at most once. However, sometimes
# this does not give enough data for the decompressor to make progress.
# In this case we make multiple reads, to avoid returning b"".
with
self
.
_lock
:
self
.
_check_can_read
()
if
(
size
==
0
or
self
.
_mode
==
_MODE_READ_EOF
or
...
...
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