Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Lib/_compat_pickle.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -199,7 +199,6 @@
('__builtin__', 'basestring'): ('builtins', 'str'),
('exceptions', 'StandardError'): ('builtins', 'Exception'),
('UserDict', 'UserDict'): ('collections', 'UserDict'),
('socket', '_socketobject'): ('socket', 'SocketType'),
})

REVERSE_NAME_MAPPING.update({
Expand All@@ -221,7 +220,6 @@
('SimpleHTTPServer', 'SimpleHTTPRequestHandler'),
('http.server', 'CGIHTTPRequestHandler'):
('CGIHTTPServer', 'CGIHTTPRequestHandler'),
('_socket', 'socket'): ('socket', '_socketobject'),
})

PYTHON3_OSERROR_EXCEPTIONS = (
Expand Down
3 changes: 2 additions & 1 deletion Lib/socket.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -61,7 +61,7 @@
EWOULDBLOCK = getattr(errno, 'EWOULDBLOCK', 11)

__all__ = ["fromfd", "getfqdn", "create_connection", "create_server",
"has_dualstack_ipv6", "AddressFamily", "SocketKind"]
"has_dualstack_ipv6", "AddressFamily", "SocketKind", "SocketType"]
__all__.extend(os._get_exports_list(_socket))

# Set up the socket.AF_* socket.SOCK_* constants as members of IntEnums for
Expand DownExpand Up@@ -541,6 +541,7 @@ def socketpair(family=AF_INET, type=SOCK_STREAM, proto=0):
if defined on the platform; otherwise, the default is AF_INET.
"""

SocketType = socket
_blocking_errnos = { EAGAIN, EWOULDBLOCK }

class SocketIO(io.RawIOBase):
Expand Down
3 changes: 1 addition & 2 deletions Lib/test/test_socket.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -801,8 +801,7 @@ def requireSocket(*args):
class GeneralModuleTests(unittest.TestCase):

def test_SocketType_is_socketobject(self):
import _socket
self.assertTrue(socket.SocketType is _socket.socket)
self.assertTrue(socket.SocketType is socket.socket)
s = socket.socket()
self.assertIsInstance(s, socket.SocketType)
s.close()
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
Update SocketType to keep back compatible
4 changes: 0 additions & 4 deletions Modules/socketmodule.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -7088,10 +7088,6 @@ PyInit__socket(void)
Py_INCREF(socket_timeout);
PyModule_AddObject(m, "timeout", socket_timeout);
Py_INCREF((PyObject *)&sock_type);
if (PyModule_AddObject(m, "SocketType",
(PyObject *)&sock_type) != 0)
return NULL;
Py_INCREF((PyObject *)&sock_type);
if (PyModule_AddObject(m, "socket",
(PyObject *)&sock_type) != 0)
return NULL;
Expand Down