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
2380feef
Kaydet (Commit)
2380feef
authored
Ara 25, 2012
tarafından
Kristján Valur Jónsson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
issue #879399
Fix line buffering of socket._fileobject
üst
513e9b4f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
3 deletions
+61
-3
socket.py
Lib/socket.py
+2
-2
test_socket.py
Lib/test/test_socket.py
+59
-1
No files found.
Lib/socket.py
Dosyayı görüntüle @
2380feef
...
@@ -319,8 +319,8 @@ class _fileobject(object):
...
@@ -319,8 +319,8 @@ class _fileobject(object):
self
.
_wbuf
.
append
(
data
)
self
.
_wbuf
.
append
(
data
)
self
.
_wbuf_len
+=
len
(
data
)
self
.
_wbuf_len
+=
len
(
data
)
if
(
self
.
_wbufsize
==
0
or
if
(
self
.
_wbufsize
==
0
or
self
.
_wbufsize
==
1
and
'
\n
'
in
data
or
(
self
.
_wbufsize
==
1
and
'
\n
'
in
data
)
or
self
.
_wbuf_len
>=
self
.
_wbufsize
):
(
self
.
_wbufsize
>
1
and
self
.
_wbuf_len
>=
self
.
_wbufsize
)
):
self
.
flush
()
self
.
flush
()
def
writelines
(
self
,
list
):
def
writelines
(
self
,
list
):
...
...
Lib/test/test_socket.py
Dosyayı görüntüle @
2380feef
...
@@ -962,8 +962,8 @@ class FileObjectClassTestCase(SocketConnectedTest):
...
@@ -962,8 +962,8 @@ class FileObjectClassTestCase(SocketConnectedTest):
def
tearDown
(
self
):
def
tearDown
(
self
):
self
.
serv_file
.
close
()
self
.
serv_file
.
close
()
self
.
assertTrue
(
self
.
serv_file
.
closed
)
self
.
assertTrue
(
self
.
serv_file
.
closed
)
self
.
serv_file
=
None
SocketConnectedTest
.
tearDown
(
self
)
SocketConnectedTest
.
tearDown
(
self
)
self
.
serv_file
=
None
def
clientSetUp
(
self
):
def
clientSetUp
(
self
):
SocketConnectedTest
.
clientSetUp
(
self
)
SocketConnectedTest
.
clientSetUp
(
self
)
...
@@ -1151,6 +1151,64 @@ class LineBufferedFileObjectClassTestCase(FileObjectClassTestCase):
...
@@ -1151,6 +1151,64 @@ class LineBufferedFileObjectClassTestCase(FileObjectClassTestCase):
bufsize
=
1
# Default-buffered for reading; line-buffered for writing
bufsize
=
1
# Default-buffered for reading; line-buffered for writing
class
SocketMemo
(
object
):
"""A wrapper to keep track of sent data, needed to examine write behaviour"""
def
__init__
(
self
,
sock
):
self
.
_sock
=
sock
self
.
sent
=
[]
def
send
(
self
,
data
,
flags
=
0
):
n
=
self
.
_sock
.
send
(
data
,
flags
)
self
.
sent
.
append
(
data
[:
n
])
return
n
def
sendall
(
self
,
data
,
flags
=
0
):
self
.
_sock
.
sendall
(
data
,
flags
)
self
.
sent
.
append
(
data
)
def
__getattr__
(
self
,
attr
):
return
getattr
(
self
.
_sock
,
attr
)
def
getsent
(
self
):
return
[
e
.
tobytes
()
if
isinstance
(
e
,
memoryview
)
else
e
for
e
in
self
.
sent
]
def
setUp
(
self
):
FileObjectClassTestCase
.
setUp
(
self
)
self
.
serv_file
.
_sock
=
self
.
SocketMemo
(
self
.
serv_file
.
_sock
)
def
testLinebufferedWrite
(
self
):
# Write two lines, in small chunks
msg
=
MSG
.
strip
()
print
>>
self
.
serv_file
,
msg
,
print
>>
self
.
serv_file
,
msg
# second line:
print
>>
self
.
serv_file
,
msg
,
print
>>
self
.
serv_file
,
msg
,
print
>>
self
.
serv_file
,
msg
# third line
print
>>
self
.
serv_file
,
''
self
.
serv_file
.
flush
()
msg1
=
"
%
s
%
s
\n
"
%
(
msg
,
msg
)
msg2
=
"
%
s
%
s
%
s
\n
"
%
(
msg
,
msg
,
msg
)
msg3
=
"
\n
"
self
.
assertEqual
(
self
.
serv_file
.
_sock
.
getsent
(),
[
msg1
,
msg2
,
msg3
])
def
_testLinebufferedWrite
(
self
):
msg
=
MSG
.
strip
()
msg1
=
"
%
s
%
s
\n
"
%
(
msg
,
msg
)
msg2
=
"
%
s
%
s
%
s
\n
"
%
(
msg
,
msg
,
msg
)
msg3
=
"
\n
"
l1
=
self
.
cli_file
.
readline
()
self
.
assertEqual
(
l1
,
msg1
)
l2
=
self
.
cli_file
.
readline
()
self
.
assertEqual
(
l2
,
msg2
)
l3
=
self
.
cli_file
.
readline
()
self
.
assertEqual
(
l3
,
msg3
)
class
SmallBufferedFileObjectClassTestCase
(
FileObjectClassTestCase
):
class
SmallBufferedFileObjectClassTestCase
(
FileObjectClassTestCase
):
...
...
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