-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
gh-88427: Deprecate socket.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 our terms of service and privacy 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?
Changes from all 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
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 |
|---|---|---|
|
|
@@ -5611,6 +5611,20 @@ static PyType_Spec sock_spec = { | |
| .slots = sock_slots, | ||
| }; | ||
|
|
||
| static PyObject* | ||
| socket_getattr(PyObject *self, PyObject *name) | ||
| { | ||
| if (PyUnicode_EqualToUTF8(name, "SocketType")) { | ||
| socket_state *state = get_module_state(self); | ||
| PyErr_Warn(PyExc_DeprecationWarning, "_socket.SocketType is deprecated and " | ||
| "will be removed in Python 3.16. " | ||
| "Use socket.socket instead"); | ||
| return state != NULL ? (PyObject *)state->sock_type : NULL; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to search for situations where |
||
| } | ||
|
|
||
| PyErr_Format(PyExc_AttributeError, "module _socket has no attribute '%U'", name); | ||
| return NULL; | ||
| } | ||
|
|
||
| #ifdef HAVE_GETHOSTNAME | ||
| /* Python interface to gethostname(). */ | ||
|
|
@@ -7216,6 +7230,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}, | ||
|
|
@@ -7468,9 +7483,6 @@ socket_exec(PyObject *m) | |
| goto error; | ||
| } | ||
| state->sock_type = (PyTypeObject *)sock_type; | ||
| if (PyModule_AddObjectRef(m, "SocketType", sock_type) < 0) { | ||
| goto error; | ||
| } | ||
rruuaanng marked this conversation as resolved.
Show resolved
Hide resolved
rruuaanng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (PyModule_AddType(m, state->sock_type) < 0) { | ||
| goto error; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.