Issue #11127: Raise a TypeError when trying to pickle a socket object.

This commit is contained in:
Antoine Pitrou 2011-03-20 23:56:36 +01:00
parent b938bcd211
commit 6d58d64919
3 changed files with 12 additions and 0 deletions

View file

@ -18,6 +18,7 @@ import contextlib
from weakref import proxy
import signal
import math
import pickle
try:
import fcntl
except ImportError:
@ -764,6 +765,12 @@ class GeneralModuleTests(unittest.TestCase):
fp.close()
self.assertEqual(repr(fp), "<_io.BufferedReader name=-1>")
def test_pickle(self):
sock = socket.socket()
with sock:
for protocol in range(pickle.HIGHEST_PROTOCOL + 1):
self.assertRaises(TypeError, pickle.dumps, sock, protocol)
@unittest.skipUnless(thread, 'Threading required for this test.')
class BasicTCPTest(SocketConnectedTest):