Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.2k
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?
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
341a29ea4ef8475a57cb172f7c3d58b305d73b14ea2c2e8e33ea91693b7d187188a924ce4bfa6362dbab5042f2f4676d963e85bc7da2aabe0afac16f2736c22fdba787f841cf36598e1931ce2b28e78d0aa3ab5b45a4f34261d87fde41cb5e4302d0705492b4752f8444c5ed9f05ae78b30dcb9eead93e02a45bd936f05f377b414538acd0d584e6d4d71bce347c8e3e625c64a9093330d836c438efc89e07a953fae620af029878File 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 |
|---|---|---|
| @@ -69,6 +69,11 @@ | ||
| "has_dualstack_ipv6", "AddressFamily", "SocketKind"] | ||
| __all__.extend(os._get_exports_list(_socket)) | ||
| def __getattr__(name): | ||
| if name == "SocketType": | ||
| return _socket.SocketType | ||
| raise AttributeError(f"module {__name__!r} has no attribute {name!r}") | ||
rruuaanng marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. ZeroIntensity marked this conversation as resolved.
Uh 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 |
|---|---|---|
| @@ -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 ContributorAuthor 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.
Uh oh!There was an error while loading. Please reload this page. rruuaanng marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| if (PyModule_AddType(m, state->sock_type) < 0) { | ||
| goto error; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.