| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| 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 |
|---|---|---|
| Expand Up | @@ -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; | ||
|
Comment thread
Copy link
Copy Markdown
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityShould sock_type get INCREF'd? I'm assuming its a static type and therefore immortal, but we should add a comment clarifying that.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI tried to search for situations where sock_type is used in socketmodule.c. In the scenario where Py_DECREF is used, only socket_clear uses Py_DECREF. And sock_type does not use Py_INCREF. And in other parts, it seems that there is no special comment.
Sorry, something went wrong.
All reactions
|
||
| } | ||
|
|
||
| PyErr_Format(PyExc_AttributeError, "module _socket has no attribute '%U'", name); | ||
| return NULL; | ||
| } | ||
|
|
||
| #ifdef HAVE_GETHOSTNAME | ||
| /* Python interface to gethostname(). */ | ||
| Expand Down Expand Up | @@ -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}, | ||
| Expand Down Expand Up | @@ -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; | ||
| } | ||
|
Comment thread
rruuaanng marked this conversation as resolved.
Comment thread
rruuaanng marked this conversation as resolved.
|
||
| if (PyModule_AddType(m, state->sock_type) < 0) { | ||
| goto error; | ||
| } | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.