Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
2 changes: 1 addition & 1 deletion Lib/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
IntEnum._convert_(
'AddressFamily',
__name__,
lambda C: C.isupper() and C.startswith('AF_'))
lambda C: C.startswith('AF_'))

IntEnum._convert_(
'SocketKind',
Expand Down
6 changes: 5 additions & 1 deletion Lib/test/test_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -2093,11 +2093,15 @@ def test_addressfamily_enum(self):
import _socket, enum
CheckedAddressFamily = enum._old_convert_(
enum.IntEnum, 'AddressFamily', 'socket',
lambda C: C.isupper() and C.startswith('AF_'),
lambda C: C.startswith('AF_'),
source=_socket,
)
enum._test_simple_enum(CheckedAddressFamily, socket.AddressFamily)

@unittest.skipUnless(hasattr(_socket, 'AF_DECnet'), 'AF_DECnet required.')
def test_addressfamily_enum_decnet(self):
assert hasattr(socket.AddressFamily, 'AF_DECnet')

def test_socketkind_enum(self):
import _socket, enum
CheckedSocketKind = enum._old_convert_(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Ensure that ```AF_DECnet``` is part of the :class:`!socket.AddressFamily`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why :class:`socket.AddressFamily` didn't work.

enum, when available.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Ensure that ```AF_DECnet``` is part of the :class:`!socket.AddressFamily`
enum, when available.
Ensure that ``AF_DECnet`` is part of the :class:`!socket.AddressFamily`
enum.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove "when available"? It's in an ifdef in socketmodule.c, so CPython already hedges that it might not be present on any given system.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a bit redundant, and when it's available, it'll appear in AddressFamily, otherwise it won't. If it isn't modified, it seems that it must be in AddressFamily, rather than changing with the os environment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the opposite of how I'd read it. "when available" at the end meaning "when it's available in the OS environment, ensure that it's part of AddressFamily". Without that, I'd think that "ensure that it's in AddressFamily" means that we always ensure it's in AddressFamily, whether or not it's available from the OS, or that we think it's universally available so not worth mentioning that part.

Loading