s[7:])
return s
+ def __getstate__(self):
+ raise TypeError("Cannot serialize socket object")
+
def dup(self):
"""dup() -> socket object
from weakref import proxy
import signal
import math
+import pickle
try:
import fcntl
except ImportError:
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):
- Issue #4391: Use proper gettext plural forms in optparse.
+- Issue #11127: Raise a TypeError when trying to pickle a socket object.
+
- Issue #11563: Connection:close header is sent by requests using URLOpener
class which helps in closing of sockets after connection is over. Patch
contributions by Jeff McNeil and Nadeem Vawda.