summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2016-04-11 00:38:12 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2016-04-11 00:38:12 (GMT)
commit50ab1a3694c43b9ab6798b98d9e5983c78cb17e2 (patch)
tree5ad077a9ff466bd0cab3074373f687b0e77367c1 /Lib
parentf01e408c1688a207eba18444da8c151c872fba59 (diff)
downloadcpython-50ab1a3694c43b9ab6798b98d9e5983c78cb17e2.zip
cpython-50ab1a3694c43b9ab6798b98d9e5983c78cb17e2.tar.gz
cpython-50ab1a3694c43b9ab6798b98d9e5983c78cb17e2.tar.bz2
Issue #26685: Raise OSError if closing a socket fails
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_pty.py1
-rw-r--r--Lib/test/test_socket.py11
2 files changed, 11 insertions, 1 deletions
diff --git a/Lib/test/test_pty.py b/Lib/test/test_pty.py
index ef5e99e..15f88e4 100644
--- a/Lib/test/test_pty.py
+++ b/Lib/test/test_pty.py
@@ -277,7 +277,6 @@ class SmallPtyTests(unittest.TestCase):
socketpair = self._socketpair()
masters = [s.fileno() for s in socketpair]
- os.close(masters[1])
socketpair[1].close()
os.close(write_to_stdin_fd)
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index 02bc0c0..982a976 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -1161,6 +1161,17 @@ class GeneralModuleTests(unittest.TestCase):
sock.close()
self.assertRaises(OSError, sock.send, b"spam")
+ def testCloseException(self):
+ sock = socket.socket()
+ socket.socket(fileno=sock.fileno()).close()
+ try:
+ sock.close()
+ except OSError as err:
+ # Winsock apparently raises ENOTSOCK
+ self.assertIn(err.errno, (errno.EBADF, errno.ENOTSOCK))
+ else:
+ self.fail("close() should raise EBADF/ENOTSOCK")
+
def testNewAttributes(self):
# testing .family, .type and .protocol