[New-bugs-announce] [issue10473] Strange behavior for socket.timeout

Roy Smith report at bugs.python.org
Sat Nov 20 21:54:16 CET 2010


New submission from Roy Smith <roy at panix.com>:

While investigating issue7322, I wrote a test case to demonstrate the issue.  I made a mistake and called settimeout() on the wrong socket, but the result appears to demonstrate a different bug.  When I run the attached test-issue7322.py on my OSX-10.6.5 machine, using...

Python 3.2a4+ (py3k:86538, Nov 19 2010, 20:52:31) 
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin

I get the output below.  The bug is that readline() is returning, even though I never wrote a newline on the other side of the connection.  If I comment out the settimeout() call, it hangs in the readline() call, as expected.

While I admit it makes no sense to call settimeout() on the listening socket, doing so certainly should not cause this behavior.

Note: I also tried this on Ubuntu linux (with python built from the same 3.2a4+ sources).  I cannot reproduce the problem there.


issue7322$ ./test-issue7322.py 
F/Users/roy/python/py3k/Lib/unittest/case.py:382: ResourceWarning: unclosed <socket.socket object, fd=3, family=2, type=1, proto=0>
  result.addFailure(self, sys.exc_info())
/Users/roy/python/py3k/Lib/unittest/case.py:382: ResourceWarning: unclosed <socket.socket object, fd=4, family=2, type=1, proto=0>
  result.addFailure(self, sys.exc_info())
/Users/roy/python/py3k/Lib/socket.py:324: ResourceWarning: unclosed <socket.socket object, fd=5, family=2, type=1, proto=0>
  self._sock = None

======================================================================
FAIL: test_foo (__main__.Test_Issue7322)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./test-issue7322.py", line 22, in test_foo
    self.fail("readline() returned '%s'" % line)
AssertionError: readline() returned 'hello'

----------------------------------------------------------------------
Ran 1 test in 0.026s

FAILED (failures=1)
[49547 refs]

----------
components: Library (Lib)
files: test-issue7322.py
messages: 121769
nosy: roysmith
priority: normal
severity: normal
status: open
title: Strange behavior for socket.timeout
type: behavior
versions: Python 3.2
Added file: http://bugs.python.org/file19710/test-issue7322.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10473>
_______________________________________


More information about the New-bugs-announce mailing list