Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Draft
rruuaanng wants to merge48 commits intopython:main
base:main
Choose a base branch
Loading
fromrruuaanng:gh88427
Draft
Show file tree
Hide file tree
Changes from39 commits
Commits
Show all changes
48 commits
Select commitHold shift + click to select a range
341a29e
deprecated SocketType
rruuaanngNov 1, 2024
a4ef847
_socket.socket change to _socket.SocketType
rruuaanngNov 1, 2024
5a57cb1
Remove return
rruuaanngNov 1, 2024
72f7c3d
Change docs
rruuaanngNov 1, 2024
58b305d
Change NEWS
rruuaanngNov 1, 2024
73b14ea
Change docs
rruuaanngNov 1, 2024
2c2e8e3
Change NEWS
rruuaanngNov 1, 2024
3ea9169
Move import
rruuaanngNov 1, 2024
3b7d187
Add return
rruuaanngNov 1, 2024
188a924
socket rename to SocketType
rruuaanngNov 2, 2024
ce4bfa6
Remove defined
rruuaanngNov 2, 2024
362dbab
Return _socket.socket
rruuaanngNov 2, 2024
5042f2f
Add AttributeError
rruuaanngNov 2, 2024
4676d96
Add pending3.16
rruuaanngNov 2, 2024
3e85bc7
warn change to _deprecated
rruuaanngNov 2, 2024
da2aabe
Change info
rruuaanngNov 2, 2024
0afac16
Remove ~
rruuaanngNov 3, 2024
f2736c2
Change NEWS
rruuaanngNov 3, 2024
2fdba78
Change pending
rruuaanngNov 3, 2024
7f841cf
Change NEWS
rruuaanngNov 7, 2024
36598e1
Change docs
rruuaanngNov 7, 2024
931ce2b
Change removal
rruuaanngNov 7, 2024
28e78d0
Add some space
rruuaanngNov 7, 2024
aa3ab5b
Add :
rruuaanngNov 8, 2024
45a4f34
Remove ‘in type annotations’
rruuaanngNov 8, 2024
261d87f
Add newline(boom)
rruuaanngNov 8, 2024
de41cb5
Add module __getattr__
rruuaanngNov 16, 2024
e4302d0
Remove redundant test method
rruuaanngNov 16, 2024
705492b
Restore SocketType
rruuaanngNov 16, 2024
4752f84
Change cmod | remove getattr in socket.py
rruuaanngNov 16, 2024
44c5ed9
Restore getattr in socket.py
rruuaanngNov 16, 2024
f05ae78
Remove getattr in socket.py
rruuaanngNov 17, 2024
b30dcb9
Add free
rruuaanngNov 17, 2024
eead93e
Merge branch 'gh88427' of https://github.com/rruuaanng/cpython into g…
rruuaanngNov 17, 2024
02a45bd
Recover __getattr__ in socket.py
rruuaanngNov 18, 2024
936f05f
Change warn desc
rruuaanngNov 19, 2024
377b414
Recover email
rruuaanngNov 19, 2024
538acd0
Change warn desc
rruuaanngNov 19, 2024
d584e6d
Change warn desc
rruuaanngNov 19, 2024
4d71bce
Remove SocketType original definition
rruuaanngNov 19, 2024
347c8e3
_socket.socket change to _socket.SocketType
rruuaanngNov 19, 2024
e625c64
strcmp change to PyUnicode_EqualToUTF8
rruuaanngNov 20, 2024
a909333
Merge branch 'gh88427' of https://github.com/rruuaanng/cpython into g…
rruuaanngNov 20, 2024
0d836c4
Use a better implementation
rruuaanngDec 8, 2024
38efc89
Clear CI error
rruuaanngDec 8, 2024
e07a953
Add cast
rruuaanngDec 8, 2024
fae620a
use _socket.SocketType
rruuaanngDec 9, 2024
f029878
Merge branch 'main' into gh88427
rruuaanngDec 9, 2024
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
4 changes: 4 additions & 0 deletionsDoc/deprecations/pending-removal-in-3.16.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,10 @@ Pending Removal in Python 3.16
* :mod:`builtins`:
``~bool``, bitwise inversion on bool.

* :mod:`socket`:
:class:`socket.SocketType`: use :class:`socket.socket` type instead.
(Contributed by James Roy in :gh:`88427`.)

* :mod:`symtable`:
Deprecate :meth:`symtable.Class.get_methods` due to the lack of interest.
(Contributed by Bénédikt Tran in :gh:`119698`.)
Expand Down
3 changes: 3 additions & 0 deletionsDoc/library/socket.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -909,6 +909,9 @@ The following functions all create :ref:`socket objects <socket-objects>`.
This is a Python type object that represents the socket object type. It is the
same as ``type(socket(...))``.

.. deprecated:: next
Use :class:`socket.socket` type instead.


Other functions
'''''''''''''''
Expand Down
5 changes: 5 additions & 0 deletionsLib/socket.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

# 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
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff 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.
24 changes: 24 additions & 0 deletionsModules/socketmodule.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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);
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")) {
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(). */
Expand DownExpand Up@@ -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},
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp