Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
b833fa88
Commit
b833fa88
authored
Aug 12, 2010
by
Ezio Melotti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#9543: Fix regression introduced in r83624.
parent
13bc24b4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
1 deletion
+26
-1
Lib/socket.py
Lib/socket.py
+1
-1
Lib/test/test_socket.py
Lib/test/test_socket.py
+25
-0
No files found.
Lib/socket.py
View file @
b833fa88
...
...
@@ -299,7 +299,7 @@ class _fileobject(object):
finally
:
if
write_offset
<
data_size
:
remainder
=
data
[
write_offset
:]
del
view
,
data
# explicit free
del
data
# explicit free
self
.
_wbuf
.
append
(
remainder
)
self
.
_wbuf_len
=
len
(
remainder
)
...
...
Lib/test/test_socket.py
View file @
b833fa88
...
...
@@ -1044,6 +1044,30 @@ class NetworkConnectionBehaviourTest(SocketTCPTest, ThreadableTest):
self
.
cli
=
sock
=
socket
.
create_connection
((
HOST
,
self
.
port
),
timeout
=
1
)
self
.
failUnlessRaises
(
socket
.
timeout
,
lambda
:
sock
.
recv
(
5
))
class
TestIssue9543
(
SocketTCPTest
,
NetworkConnectionTest
):
"""
This test exercises the code in the _fileobject.flush() method when the
whole write buffer hasn't been flushed.
See http://bugs.python.org/issue9543
"""
# XXX: this is just a sanity check, proper tests for flush() should still
# be added
def
setUp
(
self
):
SocketTCPTest
.
setUp
(
self
)
NetworkConnectionTest
.
clientSetUp
(
self
)
def
test_issue9543
(
self
):
self
.
cli
.
close
()
file_a
=
self
.
serv
.
makefile
(
'w'
)
file_a
.
write
(
'x'
)
# flush() will try to send data to self.cli and raise an error because
# it's closed
self
.
assertRaises
(
socket
.
error
,
file_a
.
flush
)
# close() will raise an error too, because it calls flush() before
# closing the file
self
.
assertRaises
(
socket
.
error
,
file_a
.
close
)
self
.
assertTrue
(
file_a
.
closed
)
class
Urllib2FileobjectTest
(
unittest
.
TestCase
):
...
...
@@ -1311,6 +1335,7 @@ def test_main():
NetworkConnectionNoServer
,
NetworkConnectionAttributesTest
,
NetworkConnectionBehaviourTest
,
TestIssue9543
,
])
if
hasattr
(
socket
,
"socketpair"
):
tests
.
append
(
BasicSocketPairTest
)
...
...
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