Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.3k
gh-88427: Deprecatesocket.SocketType
#126272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes from39 commits
341a29e
a4ef847
5a57cb1
72f7c3d
58b305d
73b14ea
2c2e8e3
3ea9169
3b7d187
188a924
ce4bfa6
362dbab
5042f2f
4676d96
3e85bc7
da2aabe
0afac16
f2736c2
2fdba78
7f841cf
36598e1
931ce2b
28e78d0
aa3ab5b
45a4f34
261d87f
de41cb5
e4302d0
705492b
4752f84
44c5ed9
f05ae78
b30dcb9
eead93e
02a45bd
936f05f
377b414
538acd0
d584e6d
4d71bce
347c8e3
e625c64
a909333
0d836c4
38efc89
e07a953
fae620a
f029878
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -67,6 +67,11 @@ | ||
"has_dualstack_ipv6", "AddressFamily", "SocketKind"] | ||
__all__.extend(os._get_exports_list(_socket)) | ||
def __getattr__(name): | ||
if name == "SocketType": | ||
return _socket.socket | ||
rruuaanng marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
raise AttributeError(f"module {__name__!r} has no attribute {name!r}") | ||
rruuaanng marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
rruuaanng marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page.
ZeroIntensity marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
# Set up the socket.AF_* socket.SOCK_* constants as members of IntEnums for | ||
# nicer string representations. | ||
# Note that _socket only knows about the integer values. The public interface | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
:attr:`!socket.SocketType` is now deprecated and planned to be removed in Python 3.16. Use :class:`socket.socket` instead. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -5574,6 +5574,29 @@ static PyType_Spec sock_spec = { | ||
.slots = sock_slots, | ||
}; | ||
static PyObject * | ||
socket_getattr(PyObject *self, PyObject *name) | ||
{ | ||
PyObject *sock_type = PyType_FromSpec(&sock_spec); | ||
rruuaanng marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
if (sock_type == NULL) { | ||
return NULL; | ||
} | ||
const char *attrname = PyUnicode_AsUTF8(name); | ||
if (attrname == NULL) { | ||
Py_DECREF(sock_type); | ||
return NULL; | ||
} | ||
if (!strcmp(attrname, "SocketType")) { | ||
rruuaanng marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page.
rruuaanng marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
PyErr_Warn(PyExc_DeprecationWarning, "_socket.SocketType is deprecated and will be removed in Python 3.16. " | ||
"Use socket.socket instead"); | ||
return sock_type; | ||
} | ||
PyErr_Format(PyExc_AttributeError, "module _socket has no attribute '%s'", attrname); | ||
Py_DECREF(sock_type); | ||
return NULL; | ||
} | ||
#ifdef HAVE_GETHOSTNAME | ||
/* Python interface to gethostname(). */ | ||
@@ -7179,6 +7202,7 @@ range of values."); | ||
/* List of functions exported by this module. */ | ||
static PyMethodDef socket_methods[] = { | ||
{"__getattr__", socket_getattr, METH_O, "Module __getattr__"}, | ||
#ifdef HAVE_GETADDRINFO | ||
{"gethostbyname", socket_gethostbyname, | ||
METH_VARARGS, gethostbyname_doc}, | ||
Uh oh!
There was an error while loading.Please reload this page.