From 341a29e145cb110262009ffaf0e4c7b57e3894a1 Mon Sep 17 00:00:00 2001 From: RUANG Date: Fri, 1 Nov 2024 22:51:08 +0800 Subject: [PATCH 01/45] deprecated SocketType --- Doc/library/socket.rst | 3 +++ Lib/socket.py | 6 ++++++ .../Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst | 1 + 3 files changed, 10 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst index a81e11549d5c54..6576787e44b6d5 100644 --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -909,6 +909,9 @@ The following functions all create :ref:`socket objects `. This is a Python type object that represents the socket object type. It is the same as ``type(socket(...))``. + .. deprecated:: 3.14 + If type annotation is required, use :class:`~socket.socket`. + Other functions ''''''''''''''' diff --git a/Lib/socket.py b/Lib/socket.py index 9207101dcf9d58..919ad2caa64242 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -67,6 +67,12 @@ "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) + return _socket.socket + # 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 diff --git a/Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst b/Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst new file mode 100644 index 00000000000000..1754534e4bfb4d --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst @@ -0,0 +1 @@ +Deprecated :attr:`!socket.SocketType` from the :mod:`socket`. From a4ef847392e221f4c111fb0d79629b7a45cec996 Mon Sep 17 00:00:00 2001 From: RUANG Date: Fri, 1 Nov 2024 23:09:29 +0800 Subject: [PATCH 02/45] _socket.socket change to _socket.SocketType --- Lib/socket.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/socket.py b/Lib/socket.py index 919ad2caa64242..5d428fe4f381e0 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -71,7 +71,7 @@ def __getattr__(name): import warnings if name == "SocketType": warnings.warn(f"{name} is deprecated", DeprecationWarning) - return _socket.socket + return _socket.SocketType # Set up the socket.AF_* socket.SOCK_* constants as members of IntEnums for # nicer string representations. From 5a57cb156b48bbbde9ae8540eb9c54f6222a03f6 Mon Sep 17 00:00:00 2001 From: RUANG Date: Fri, 1 Nov 2024 23:13:15 +0800 Subject: [PATCH 03/45] Remove return --- Lib/socket.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/socket.py b/Lib/socket.py index 5d428fe4f381e0..4446abe60532be 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -71,7 +71,6 @@ def __getattr__(name): import warnings if name == "SocketType": warnings.warn(f"{name} is deprecated", DeprecationWarning) - return _socket.SocketType # Set up the socket.AF_* socket.SOCK_* constants as members of IntEnums for # nicer string representations. From 72f7c3d3f1399c321fc54ad8d9b82d163a184526 Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Fri, 1 Nov 2024 23:19:42 +0800 Subject: [PATCH 04/45] Change docs --- Doc/library/socket.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst index 6576787e44b6d5..7ce5242acbedf4 100644 --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -909,7 +909,7 @@ The following functions all create :ref:`socket objects `. This is a Python type object that represents the socket object type. It is the same as ``type(socket(...))``. - .. deprecated:: 3.14 + .. deprecated:: next If type annotation is required, use :class:`~socket.socket`. From 58b305d0a918bf06b086aec0f4d33ee75f193556 Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Fri, 1 Nov 2024 23:19:59 +0800 Subject: [PATCH 05/45] Change NEWS --- .../next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst b/Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst index 1754534e4bfb4d..c3184e6870bdfd 100644 --- a/Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst +++ b/Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst @@ -1 +1 @@ -Deprecated :attr:`!socket.SocketType` from the :mod:`socket`. +Deprecated :attr:`!socket.SocketType`. From 73b14eaca1551ee7ac4b5cff1515d83a13bac9ed Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Fri, 1 Nov 2024 23:25:39 +0800 Subject: [PATCH 06/45] Change docs --- Doc/library/socket.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst index 7ce5242acbedf4..89de135f247908 100644 --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -910,7 +910,7 @@ The following functions all create :ref:`socket objects `. same as ``type(socket(...))``. .. deprecated:: next - If type annotation is required, use :class:`~socket.socket`. + If type annotations are required, use :class:`~socket.socket` instead. Other functions From 2c2e8e33ce305f026874a3d80802f93dbe4434d3 Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Fri, 1 Nov 2024 23:26:16 +0800 Subject: [PATCH 07/45] Change NEWS --- .../next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst b/Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst index c3184e6870bdfd..1647868a79ab39 100644 --- a/Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst +++ b/Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst @@ -1 +1 @@ -Deprecated :attr:`!socket.SocketType`. +:attr:`!socket.SocketType` is deprecated. Use :class:`socket.socket` in type annotations instead. From 3ea9169a25947c137cc49551d56eb418435e332b Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Fri, 1 Nov 2024 23:28:43 +0800 Subject: [PATCH 08/45] Move import --- Lib/socket.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/socket.py b/Lib/socket.py index 4446abe60532be..d0688efafe3d8a 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -68,8 +68,8 @@ __all__.extend(os._get_exports_list(_socket)) def __getattr__(name): - import warnings if name == "SocketType": + import warnings warnings.warn(f"{name} is deprecated", DeprecationWarning) # Set up the socket.AF_* socket.SOCK_* constants as members of IntEnums for From 3b7d187e8fe0559dcaa04becc1cca3e3fd7eef2e Mon Sep 17 00:00:00 2001 From: RUANG Date: Fri, 1 Nov 2024 23:45:15 +0800 Subject: [PATCH 09/45] Add return --- Lib/socket.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/socket.py b/Lib/socket.py index d0688efafe3d8a..fe4cfffeb73715 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -71,6 +71,7 @@ def __getattr__(name): if name == "SocketType": import warnings warnings.warn(f"{name} is deprecated", DeprecationWarning) + return _socket.socket # Set up the socket.AF_* socket.SOCK_* constants as members of IntEnums for # nicer string representations. From 188a92418ee068bfb3dca05ae70fc2d6c65f39fe Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Sat, 2 Nov 2024 08:19:07 +0800 Subject: [PATCH 10/45] socket rename to SocketType --- Lib/socket.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/socket.py b/Lib/socket.py index fe4cfffeb73715..c82c9ed89b6f05 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -71,7 +71,7 @@ def __getattr__(name): if name == "SocketType": import warnings warnings.warn(f"{name} is deprecated", DeprecationWarning) - return _socket.socket + return _socket.SockType # Set up the socket.AF_* socket.SOCK_* constants as members of IntEnums for # nicer string representations. From ce4bfa6bd593df1a3ab9216e0ea08cc0d7377357 Mon Sep 17 00:00:00 2001 From: RUANG Date: Sat, 2 Nov 2024 08:52:37 +0800 Subject: [PATCH 11/45] Remove defined --- Modules/socketmodule.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 3ffdaa45f16ac7..4d67bad9dfddf2 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -7431,9 +7431,6 @@ socket_exec(PyObject *m) goto error; } state->sock_type = (PyTypeObject *)sock_type; - if (PyModule_AddObjectRef(m, "SocketType", sock_type) < 0) { - goto error; - } if (PyModule_AddType(m, state->sock_type) < 0) { goto error; } From 362dbabdedd1f6e17cbcb47610b4f643338f3005 Mon Sep 17 00:00:00 2001 From: RUANG Date: Sat, 2 Nov 2024 08:53:08 +0800 Subject: [PATCH 12/45] Return _socket.socket --- Lib/socket.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/socket.py b/Lib/socket.py index c82c9ed89b6f05..fe4cfffeb73715 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -71,7 +71,7 @@ def __getattr__(name): if name == "SocketType": import warnings warnings.warn(f"{name} is deprecated", DeprecationWarning) - return _socket.SockType + return _socket.socket # Set up the socket.AF_* socket.SOCK_* constants as members of IntEnums for # nicer string representations. From 5042f2f6ec5b25bce314cdb9eae4f1c282c3fae3 Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Sat, 2 Nov 2024 09:26:39 +0800 Subject: [PATCH 13/45] Add AttributeError --- Lib/socket.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/socket.py b/Lib/socket.py index fe4cfffeb73715..ee8bae9ddfa24d 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -72,7 +72,7 @@ def __getattr__(name): import warnings warnings.warn(f"{name} is deprecated", DeprecationWarning) 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 From 4676d966d22cfc84f1ed7b6df8608988f917e255 Mon Sep 17 00:00:00 2001 From: RUANG Date: Sat, 2 Nov 2024 11:21:52 +0800 Subject: [PATCH 14/45] Add pending3.16 --- Doc/deprecations/pending-removal-in-3.16.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doc/deprecations/pending-removal-in-3.16.rst b/Doc/deprecations/pending-removal-in-3.16.rst index e50e3fc1b37cbe..11ab350fa1cb0b 100644 --- a/Doc/deprecations/pending-removal-in-3.16.rst +++ b/Doc/deprecations/pending-removal-in-3.16.rst @@ -8,6 +8,10 @@ Pending Removal in Python 3.16 * :mod:`builtins`: ``~bool``, bitwise inversion on bool. +* :mod:`socket`: + If type annotations are required, use :class:`~socket.socket` 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`.) From 3e85bc7905511e69f739d65413688cc0e9a0b41e Mon Sep 17 00:00:00 2001 From: RUANG Date: Sat, 2 Nov 2024 11:25:04 +0800 Subject: [PATCH 15/45] warn change to _deprecated --- Lib/socket.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/socket.py b/Lib/socket.py index ee8bae9ddfa24d..c2c7eeb474ff85 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -70,7 +70,7 @@ def __getattr__(name): if name == "SocketType": import warnings - warnings.warn(f"{name} is deprecated", DeprecationWarning) + warnings._deprecated(f"{name} is deprecated", remove=(3, 16)) 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 From da2aabe01239cfc9dad81d3c6176ee4acb634fb8 Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Sat, 2 Nov 2024 11:26:32 +0800 Subject: [PATCH 16/45] Change info --- Lib/socket.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/socket.py b/Lib/socket.py index c2c7eeb474ff85..c03e5b4af9c22d 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -70,7 +70,7 @@ def __getattr__(name): if name == "SocketType": import warnings - warnings._deprecated(f"{name} is deprecated", remove=(3, 16)) + warnings._deprecated(name, remove=(3, 16)) 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 From 0afac16d8a3be53b9b6f8240f1fd6c3f714f14d9 Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Sun, 3 Nov 2024 11:42:41 +0800 Subject: [PATCH 17/45] Remove ~ --- Doc/library/socket.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst index 89de135f247908..06423c47c381fd 100644 --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -910,7 +910,7 @@ The following functions all create :ref:`socket objects `. same as ``type(socket(...))``. .. deprecated:: next - If type annotations are required, use :class:`~socket.socket` instead. + If type annotations are required, use :class:`socket.socket` instead. Other functions From f2736c2904ffa1647827e086e3f981882693f57e Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Sun, 3 Nov 2024 11:43:17 +0800 Subject: [PATCH 18/45] Change NEWS --- .../next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst b/Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst index 1647868a79ab39..91741a06a22fab 100644 --- a/Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst +++ b/Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst @@ -1 +1 @@ -:attr:`!socket.SocketType` is deprecated. Use :class:`socket.socket` in type annotations instead. +:attr:`!socket.SocketType` is deprecated and is planned to be removed in 3.16. Use :class:`socket.socket` in type annotations instead. From 2fdba7840e82c2d527cbbef850aedf066f40f48d Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Sun, 3 Nov 2024 11:47:02 +0800 Subject: [PATCH 19/45] Change pending --- Doc/deprecations/pending-removal-in-3.16.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/deprecations/pending-removal-in-3.16.rst b/Doc/deprecations/pending-removal-in-3.16.rst index 11ab350fa1cb0b..f534b6b0d7c2d3 100644 --- a/Doc/deprecations/pending-removal-in-3.16.rst +++ b/Doc/deprecations/pending-removal-in-3.16.rst @@ -9,7 +9,8 @@ Pending Removal in Python 3.16 ``~bool``, bitwise inversion on bool. * :mod:`socket`: - If type annotations are required, use :class:`~socket.socket` instead. + No longer use :class:`socket.SocketType` as a type annotation, If type + annotations are required, use :class:`socket.socket` instead. (Contributed by James Roy in :gh:`88427`.) * :mod:`symtable`: From 7f841cf55339d63238b74204a36a56603d31010d Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Fri, 8 Nov 2024 07:15:59 +0800 Subject: [PATCH 20/45] Change NEWS --- .../next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst b/Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst index 91741a06a22fab..b316fc73581c50 100644 --- a/Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst +++ b/Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst @@ -1 +1 @@ -:attr:`!socket.SocketType` is deprecated and is planned to be removed in 3.16. Use :class:`socket.socket` in type annotations instead. +:attr:`!socket.SocketType` is now deprecated and planned to be removed in Python 3.16. Use :class:`socket.socket` in type annotations instead. From 36598e1bf8821399c70f2aae70d0f1cfcc512002 Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Fri, 8 Nov 2024 07:18:57 +0800 Subject: [PATCH 21/45] Change docs --- Doc/library/socket.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst index 06423c47c381fd..3e0d7fd27b9d1e 100644 --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -910,7 +910,7 @@ The following functions all create :ref:`socket objects `. same as ``type(socket(...))``. .. deprecated:: next - If type annotations are required, use :class:`socket.socket` instead. + Use :class:`socket.socket` type instead. Other functions From 931ce2bbab53e08385501ebbd97efcd2a271107d Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Fri, 8 Nov 2024 07:23:04 +0800 Subject: [PATCH 22/45] Change removal --- Doc/deprecations/pending-removal-in-3.16.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Doc/deprecations/pending-removal-in-3.16.rst b/Doc/deprecations/pending-removal-in-3.16.rst index f534b6b0d7c2d3..875761ad473020 100644 --- a/Doc/deprecations/pending-removal-in-3.16.rst +++ b/Doc/deprecations/pending-removal-in-3.16.rst @@ -9,8 +9,7 @@ Pending Removal in Python 3.16 ``~bool``, bitwise inversion on bool. * :mod:`socket`: - No longer use :class:`socket.SocketType` as a type annotation, If type - annotations are required, use :class:`socket.socket` instead. + :class:`socket.SocketType` use :class:`socket.socket` type instead. (Contributed by James Roy in :gh:`88427`.) * :mod:`symtable`: From 28e78d09c6ea89f3ce40394ffc2ed984e75c5e28 Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Fri, 8 Nov 2024 07:24:57 +0800 Subject: [PATCH 23/45] Add some space --- Lib/socket.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lib/socket.py b/Lib/socket.py index c03e5b4af9c22d..b04b0f4ea9d1ca 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -73,6 +73,8 @@ def __getattr__(name): warnings._deprecated(name, remove=(3, 16)) 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 From aa3ab5b53addf658cc37ecdaa7ac3195370dc94c Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Fri, 8 Nov 2024 17:32:09 +0800 Subject: [PATCH 24/45] Add : --- Doc/deprecations/pending-removal-in-3.16.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/deprecations/pending-removal-in-3.16.rst b/Doc/deprecations/pending-removal-in-3.16.rst index 875761ad473020..d95a0243089b07 100644 --- a/Doc/deprecations/pending-removal-in-3.16.rst +++ b/Doc/deprecations/pending-removal-in-3.16.rst @@ -9,7 +9,7 @@ Pending Removal in Python 3.16 ``~bool``, bitwise inversion on bool. * :mod:`socket`: - :class:`socket.SocketType` use :class:`socket.socket` type instead. + :class:`socket.SocketType`: use :class:`socket.socket` type instead. (Contributed by James Roy in :gh:`88427`.) * :mod:`symtable`: From 45a4f34f16027e31109e8bf19d4765ea76f49b5d Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Fri, 8 Nov 2024 17:35:09 +0800 Subject: [PATCH 25/45] =?UTF-8?q?Remove=20=E2=80=98in=20type=20annotations?= =?UTF-8?q?=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst b/Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst index b316fc73581c50..80d65400aae9ef 100644 --- a/Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst +++ b/Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst @@ -1 +1 @@ -:attr:`!socket.SocketType` is now deprecated and planned to be removed in Python 3.16. Use :class:`socket.socket` in type annotations instead. +:attr:`!socket.SocketType` is now deprecated and planned to be removed in Python 3.16. Use :class:`socket.socket` instead. \ No newline at end of file From 261d87f0826bfd3c9c8445da0d04a395144c8000 Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Fri, 8 Nov 2024 17:46:12 +0800 Subject: [PATCH 26/45] Add newline(boom) --- .../next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst b/Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst index 80d65400aae9ef..92564c590726b5 100644 --- a/Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst +++ b/Misc/NEWS.d/next/Library/2024-11-01-20-09-53.gh-issue-88427.chYNT6.rst @@ -1 +1 @@ -:attr:`!socket.SocketType` is now deprecated and planned to be removed in Python 3.16. Use :class:`socket.socket` instead. \ No newline at end of file +:attr:`!socket.SocketType` is now deprecated and planned to be removed in Python 3.16. Use :class:`socket.socket` instead. From de41cb5e50295fa731d946fc5b1fbd07e651d6eb Mon Sep 17 00:00:00 2001 From: RUANG Date: Sat, 16 Nov 2024 22:40:07 +0800 Subject: [PATCH 27/45] Add module __getattr__ --- Modules/socketmodule.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 4d67bad9dfddf2..7833f35a2a01c6 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -5574,6 +5574,23 @@ static PyType_Spec sock_spec = { .slots = sock_slots, }; +static PyObject * +socket_getattr(PyObject *self, PyObject *name) +{ + const char *attrname = PyUnicode_AsUTF8(name); + PyObject *sock_type = PyType_FromSpec(&sock_spec); + if (sock_type == NULL) { + return NULL; + } + + if (!strcmp(attrname, "SocketType")) { + PyErr_Warn(PyExc_DeprecationWarning, "Use socket.socket type instead"); + return sock_type; + } + + PyErr_Format(PyExc_AttributeError, "module _socket has no attribute %s", attrname); + return NULL; +} #ifdef HAVE_GETHOSTNAME /* Python interface to gethostname(). */ @@ -6959,6 +6976,18 @@ Set the default timeout in seconds (float) for new socket objects.\n\ A value of None indicates that new socket objects have no timeout.\n\ When the socket module is first imported, the default is None."); +static PyObject * +socket_getattr(PyObject *self, PyObject *name) +{ + const char *attrname = PyUnicode_AsUTF8(name); + if (strcmp(attrname, "asd") == 0) { + return PyLong_FromLong(42); + } + + PyErr_Format(PyExc_AttributeError, "Module has no attribute '%s'", attrname); + return NULL; +} + #if defined(HAVE_IF_NAMEINDEX) || defined(MS_WINDOWS) /* Python API for getting interface indices and names */ @@ -7179,6 +7208,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}, From e4302d03baa32ef3584af5c7dc044cc184815a34 Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Sat, 16 Nov 2024 22:42:20 +0800 Subject: [PATCH 28/45] Remove redundant test method --- Modules/socketmodule.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 7833f35a2a01c6..c1000550cabedd 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -6976,18 +6976,6 @@ Set the default timeout in seconds (float) for new socket objects.\n\ A value of None indicates that new socket objects have no timeout.\n\ When the socket module is first imported, the default is None."); -static PyObject * -socket_getattr(PyObject *self, PyObject *name) -{ - const char *attrname = PyUnicode_AsUTF8(name); - if (strcmp(attrname, "asd") == 0) { - return PyLong_FromLong(42); - } - - PyErr_Format(PyExc_AttributeError, "Module has no attribute '%s'", attrname); - return NULL; -} - #if defined(HAVE_IF_NAMEINDEX) || defined(MS_WINDOWS) /* Python API for getting interface indices and names */ From 705492b7e0e8b394178f36076d57c29bc64e127f Mon Sep 17 00:00:00 2001 From: RUANG Date: Sat, 16 Nov 2024 22:47:37 +0800 Subject: [PATCH 29/45] Restore SocketType --- Modules/socketmodule.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index c1000550cabedd..98a4acdba41460 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -7449,6 +7449,9 @@ socket_exec(PyObject *m) goto error; } state->sock_type = (PyTypeObject *)sock_type; + if (PyModule_AddObjectRef(m, "SocketType", sock_type) < 0) { + goto error; + } if (PyModule_AddType(m, state->sock_type) < 0) { goto error; } From 4752f84b687aca0edcfae8101bc9842aff0d986c Mon Sep 17 00:00:00 2001 From: RUANG Date: Sat, 16 Nov 2024 23:11:07 +0800 Subject: [PATCH 30/45] Change cmod | remove getattr in socket.py --- Lib/socket.py | 7 ------- Modules/socketmodule.c | 7 ++++--- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/Lib/socket.py b/Lib/socket.py index b04b0f4ea9d1ca..b3c51e655d28ce 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -67,13 +67,6 @@ "has_dualstack_ipv6", "AddressFamily", "SocketKind"] __all__.extend(os._get_exports_list(_socket)) -def __getattr__(name): - if name == "SocketType": - import warnings - warnings._deprecated(name, remove=(3, 16)) - 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. diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 98a4acdba41460..d22534c35c9491 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -5579,16 +5579,17 @@ socket_getattr(PyObject *self, PyObject *name) { const char *attrname = PyUnicode_AsUTF8(name); PyObject *sock_type = PyType_FromSpec(&sock_spec); - if (sock_type == NULL) { + if (attrname == NULL || sock_type == NULL) { return NULL; } if (!strcmp(attrname, "SocketType")) { - PyErr_Warn(PyExc_DeprecationWarning, "Use socket.socket type instead"); + PyErr_Warn(PyExc_DeprecationWarning, "It will be removed in 3.16. " + "Use socket.socket type instead"); return sock_type; } - PyErr_Format(PyExc_AttributeError, "module _socket has no attribute %s", attrname); + PyErr_Format(PyExc_AttributeError, "module _socket has no attribute '%s'", attrname); return NULL; } From 44c5ed9cfb05a1a1e3bc1573dba2aacf526e20fc Mon Sep 17 00:00:00 2001 From: RUANG Date: Sat, 16 Nov 2024 23:29:57 +0800 Subject: [PATCH 31/45] Restore getattr in socket.py --- Lib/socket.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Lib/socket.py b/Lib/socket.py index b3c51e655d28ce..ef089aea2ef4bb 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -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. From f05ae7857e0fbb88de8df244fea0d3c7e4173844 Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Sun, 17 Nov 2024 19:09:37 +0800 Subject: [PATCH 32/45] Remove getattr in socket.py --- Lib/socket.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Lib/socket.py b/Lib/socket.py index ef089aea2ef4bb..9207101dcf9d58 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -67,12 +67,6 @@ "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 From b30dcb9df656572e7ef570c0aa6a467e832779df Mon Sep 17 00:00:00 2001 From: RUANG Date: Sun, 17 Nov 2024 20:02:17 +0800 Subject: [PATCH 33/45] Add free --- Modules/socketmodule.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index d22534c35c9491..b205a9d06ffa62 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -5577,9 +5577,13 @@ static PyType_Spec sock_spec = { static PyObject * socket_getattr(PyObject *self, PyObject *name) { - const char *attrname = PyUnicode_AsUTF8(name); PyObject *sock_type = PyType_FromSpec(&sock_spec); - if (attrname == NULL || sock_type == NULL) { + if (sock_type == NULL) { + return NULL; + } + const char *attrname = PyUnicode_AsUTF8(name); + if (attrname == NULL) { + Py_DECREF(sock_type); return NULL; } @@ -5590,6 +5594,7 @@ socket_getattr(PyObject *self, PyObject *name) } PyErr_Format(PyExc_AttributeError, "module _socket has no attribute '%s'", attrname); + Py_DECREF(sock_type); return NULL; } From 02a45bd6e6b34b8371f0d31adfbdf14ef7db67bb Mon Sep 17 00:00:00 2001 From: RUANG Date: Mon, 18 Nov 2024 20:46:34 +0800 Subject: [PATCH 34/45] Recover __getattr__ in socket.py --- Lib/socket.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Lib/socket.py b/Lib/socket.py index 9207101dcf9d58..a82ff39c024fd9 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -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 From 936f05f062f47e5e53383deebe370c4e04fc6cdc Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Tue, 19 Nov 2024 20:50:43 +0800 Subject: [PATCH 35/45] Change warn desc --- Modules/socketmodule.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index b205a9d06ffa62..02aeeac9da8676 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -5588,8 +5588,8 @@ socket_getattr(PyObject *self, PyObject *name) } if (!strcmp(attrname, "SocketType")) { - PyErr_Warn(PyExc_DeprecationWarning, "It will be removed in 3.16. " - "Use socket.socket type instead"); + PyErr_Warn(PyExc_DeprecationWarning, "_socket.SocketType is deprecated and will be removed in 3.16. " + "Use socket.socket instead"); return sock_type; } From 377b4144723c4bcaad5641a2fe58e44ede860979 Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Tue, 19 Nov 2024 20:51:59 +0800 Subject: [PATCH 36/45] Recover email --- Modules/socketmodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 02aeeac9da8676..957a54c7d4b76c 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -5589,7 +5589,7 @@ socket_getattr(PyObject *self, PyObject *name) if (!strcmp(attrname, "SocketType")) { PyErr_Warn(PyExc_DeprecationWarning, "_socket.SocketType is deprecated and will be removed in 3.16. " - "Use socket.socket instead"); + "Use socket.socket type instead"); return sock_type; } From 538acd0f3fcb94fb353a19a3e8cdda11b427fde4 Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Tue, 19 Nov 2024 20:58:23 +0800 Subject: [PATCH 37/45] Change warn desc --- Modules/socketmodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 957a54c7d4b76c..02aeeac9da8676 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -5589,7 +5589,7 @@ socket_getattr(PyObject *self, PyObject *name) if (!strcmp(attrname, "SocketType")) { PyErr_Warn(PyExc_DeprecationWarning, "_socket.SocketType is deprecated and will be removed in 3.16. " - "Use socket.socket type instead"); + "Use socket.socket instead"); return sock_type; } From d584e6ddb585d17d6bb3efbee11e605a4be4fe0d Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Tue, 19 Nov 2024 21:00:29 +0800 Subject: [PATCH 38/45] Change warn desc --- Modules/socketmodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 02aeeac9da8676..cd4efe1ca07a76 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -5588,7 +5588,7 @@ socket_getattr(PyObject *self, PyObject *name) } if (!strcmp(attrname, "SocketType")) { - PyErr_Warn(PyExc_DeprecationWarning, "_socket.SocketType is deprecated and will be removed in 3.16. " + PyErr_Warn(PyExc_DeprecationWarning, "_socket.SocketType is deprecated and will be removed in Python 3.16. " "Use socket.socket instead"); return sock_type; } From 4d71bce57ef17ce54b6fe52e901613aa478da37e Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Tue, 19 Nov 2024 21:51:59 +0800 Subject: [PATCH 39/45] Remove SocketType original definition --- Modules/socketmodule.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index cd4efe1ca07a76..9ce7fa4ed8a82f 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -7455,9 +7455,6 @@ socket_exec(PyObject *m) goto error; } state->sock_type = (PyTypeObject *)sock_type; - if (PyModule_AddObjectRef(m, "SocketType", sock_type) < 0) { - goto error; - } if (PyModule_AddType(m, state->sock_type) < 0) { goto error; } From 347c8e359a79ba861e49ce2695804c5529eda94f Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Tue, 19 Nov 2024 22:09:17 +0800 Subject: [PATCH 40/45] _socket.socket change to _socket.SocketType --- Lib/socket.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/socket.py b/Lib/socket.py index a82ff39c024fd9..0df186478f9026 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -69,7 +69,7 @@ def __getattr__(name): if name == "SocketType": - return _socket.socket + return _socket.SocketType raise AttributeError(f"module {__name__!r} has no attribute {name!r}") # Set up the socket.AF_* socket.SOCK_* constants as members of IntEnums for From e625c642ce6ad874bb9642e0289ce68043525cad Mon Sep 17 00:00:00 2001 From: RUANG Date: Wed, 20 Nov 2024 10:58:31 +0800 Subject: [PATCH 41/45] strcmp change to PyUnicode_EqualToUTF8 --- Modules/socketmodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 9ce7fa4ed8a82f..2e08334738000f 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -5587,7 +5587,7 @@ socket_getattr(PyObject *self, PyObject *name) return NULL; } - if (!strcmp(attrname, "SocketType")) { + if (!PyUnicode_EqualToUTF8(name, "SocketType")) { PyErr_Warn(PyExc_DeprecationWarning, "_socket.SocketType is deprecated and will be removed in Python 3.16. " "Use socket.socket instead"); return sock_type; From 0d836c4572ec7cdeb709fa20a83b8e2572bd3123 Mon Sep 17 00:00:00 2001 From: RUANG Date: Sun, 8 Dec 2024 20:03:09 +0800 Subject: [PATCH 42/45] Use a better implementation --- Lib/socket.py | 2 +- Modules/socketmodule.c | 24 ++++++++---------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/Lib/socket.py b/Lib/socket.py index 0df186478f9026..a82ff39c024fd9 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -69,7 +69,7 @@ def __getattr__(name): if name == "SocketType": - return _socket.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 diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 2e08334738000f..ef7eedac6f8a46 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -5574,27 +5574,19 @@ static PyType_Spec sock_spec = { .slots = sock_slots, }; -static PyObject * -socket_getattr(PyObject *self, PyObject *name) +static PyObject* +socket_getattr(PyObject *mod, 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; - } + socket_state *state = get_module_state(mod); - if (!PyUnicode_EqualToUTF8(name, "SocketType")) { - PyErr_Warn(PyExc_DeprecationWarning, "_socket.SocketType is deprecated and will be removed in Python 3.16. " + if (PyUnicode_EqualToUTF8(name, "SocketType") && state != NULL) { + PyErr_Warn(PyExc_DeprecationWarning, "_socket.SocketType is deprecated and " + "will be removed in Python 3.16. " "Use socket.socket instead"); - return sock_type; + return state->sock_type; } - PyErr_Format(PyExc_AttributeError, "module _socket has no attribute '%s'", attrname); - Py_DECREF(sock_type); + PyErr_Format(PyExc_AttributeError, "module _socket has no attribute '%U'", name); return NULL; } From 38efc89e0aaca40910614d13f6b8cc5175ebd724 Mon Sep 17 00:00:00 2001 From: RUANG Date: Sun, 8 Dec 2024 20:12:52 +0800 Subject: [PATCH 43/45] Clear CI error --- Modules/socketmodule.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index ef7eedac6f8a46..3bad62a00f0c19 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -5575,15 +5575,14 @@ static PyType_Spec sock_spec = { }; static PyObject* -socket_getattr(PyObject *mod, PyObject *name) +socket_getattr(PyObject *self, PyObject *name) { - socket_state *state = get_module_state(mod); - - if (PyUnicode_EqualToUTF8(name, "SocketType") && state != NULL) { + 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->sock_type; + return state != NULL ? state->sock_type : NULL; } PyErr_Format(PyExc_AttributeError, "module _socket has no attribute '%U'", name); From e07a9532f20f1dda467010948ea3c0a145b0a892 Mon Sep 17 00:00:00 2001 From: RUANG Date: Sun, 8 Dec 2024 20:18:35 +0800 Subject: [PATCH 44/45] Add cast --- Modules/socketmodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 3bad62a00f0c19..82e61a7a90c1c4 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -5582,7 +5582,7 @@ socket_getattr(PyObject *self, PyObject *name) PyErr_Warn(PyExc_DeprecationWarning, "_socket.SocketType is deprecated and " "will be removed in Python 3.16. " "Use socket.socket instead"); - return state != NULL ? state->sock_type : NULL; + return state != NULL ? (PyObject *)state->sock_type : NULL; } PyErr_Format(PyExc_AttributeError, "module _socket has no attribute '%U'", name); From fae620ab379f5d371dfa7f377008f980060eb7dc Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Mon, 9 Dec 2024 19:08:37 +0800 Subject: [PATCH 45/45] use _socket.SocketType --- Lib/socket.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/socket.py b/Lib/socket.py index a82ff39c024fd9..0df186478f9026 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -69,7 +69,7 @@ def __getattr__(name): if name == "SocketType": - return _socket.socket + return _socket.SocketType raise AttributeError(f"module {__name__!r} has no attribute {name!r}") # Set up the socket.AF_* socket.SOCK_* constants as members of IntEnums for