Skip to content
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

gh-88427: Deprecated socket.SocketType #126272

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
3 changes: 3 additions & 0 deletions Doc/library/socket.rst
Original file line number Diff line number Diff 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:: 3.14
rruuaanng marked this conversation as resolved.
Show resolved Hide resolved
If type annotation is required, use :class:`~socket.socket`.
rruuaanng marked this conversation as resolved.
Show resolved Hide resolved


Other functions
'''''''''''''''
Expand Down
5 changes: 5 additions & 0 deletions Lib/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
"has_dualstack_ipv6", "AddressFamily", "SocketKind"]
__all__.extend(os._get_exports_list(_socket))

def __getattr__(name):
import warnings
if name == "SocketType":
warnings.warn(f"{name} is deprecated", DeprecationWarning)
rruuaanng marked this conversation as resolved.
Show resolved Hide resolved

rruuaanng marked this conversation as resolved.
Show resolved Hide resolved
# 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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deprecated :attr:`!socket.SocketType` from the :mod:`socket`.
rruuaanng marked this conversation as resolved.
Show resolved Hide resolved
Loading