[Python-checkins] r87730 - in python/branches/py3k: Lib/socket.py Lib/test/test_socket.py Misc/NEWS
victor.stinner
python-checkins at python.org
Tue Jan 4 12:00:45 CET 2011
Author: victor.stinner
Date: Tue Jan 4 12:00:45 2011
New Revision: 87730
Log:
Issue #10819: SocketIO.name property returns -1 when its closed, instead of
raising a ValueError, to fix repr().
Modified:
python/branches/py3k/Lib/socket.py
python/branches/py3k/Lib/test/test_socket.py
python/branches/py3k/Misc/NEWS
Modified: python/branches/py3k/Lib/socket.py
==============================================================================
--- python/branches/py3k/Lib/socket.py (original)
+++ python/branches/py3k/Lib/socket.py Tue Jan 4 12:00:45 2011
@@ -307,7 +307,10 @@
@property
def name(self):
- return self.fileno()
+ if not self.closed:
+ return self.fileno()
+ else:
+ return -1
@property
def mode(self):
Modified: python/branches/py3k/Lib/test/test_socket.py
==============================================================================
--- python/branches/py3k/Lib/test/test_socket.py (original)
+++ python/branches/py3k/Lib/test/test_socket.py Tue Jan 4 12:00:45 2011
@@ -738,6 +738,12 @@
f = None
support.gc_collect()
+ def test_name_closed_socketio(self):
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
+ fp = sock.makefile("rb")
+ fp.close()
+ self.assertEqual(repr(fp), "<_io.BufferedReader name=-1>")
+
@unittest.skipUnless(thread, 'Threading required for this test.')
class BasicTCPTest(SocketConnectedTest):
Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Tue Jan 4 12:00:45 2011
@@ -30,6 +30,9 @@
Library
-------
+- Issue #10819: SocketIO.name property returns -1 when its closed, instead of
+ raising a ValueError, to fix repr().
+
- Issue #8650: zlib.compress() and zlib.decompress() raise an OverflowError if
the input buffer length doesn't fit into an unsigned int (length bigger than
2^32-1 bytes).
More information about the Python-checkins
mailing list