Skip to content
Merged
Changes from all 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
14 changes: 14 additions & 0 deletions stdlib/socket.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,20 @@ if sys.platform == "linux":
CAN_RAW_RECV_OWN_MSGS as CAN_RAW_RECV_OWN_MSGS,
CAN_RTR_FLAG as CAN_RTR_FLAG,
CAN_SFF_MASK as CAN_SFF_MASK,
NETLINK_ARPD as NETLINK_ARPD,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add NETLINK_CRYPTO?

For what it's worth these are the ones that exist on my Linux system:

In [30]: sorted(k for k in socket.__dict__ if k.startswith("NETLINK_"))
Out[30]: 
['NETLINK_CRYPTO',
 'NETLINK_DNRTMSG',
 'NETLINK_FIREWALL',
 'NETLINK_IP6_FW',
 'NETLINK_NFLOG',
 'NETLINK_ROUTE',
 'NETLINK_USERSOCK',
 'NETLINK_XFRM']

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

https://github.com/python/typeshed/runs/7899804531?check_suite_focus=true

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 262, in resolve_external_types
    mod_ast = mod_ast.Visit(visitors.LookupExternalTypes(
  File "/opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/site-packages/pytype/pytd/parse/node.py", line 99, in Visit
    return _Visit(self, visitor, *args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/site-packages/pytype/pytd/parse/node.py", line 117, in _Visit
    return _VisitNode(node, visitor, *args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/site-packages/pytype/pytd/parse/node.py", line 209, in _VisitNode
    new_child = _VisitNode(child, visitor, *args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/site-packages/pytype/pytd/parse/node.py", line 168, in _VisitNode
    new_child = _VisitNode(child, visitor, *args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/site-packages/pytype/pytd/parse/node.py", line 209, in _VisitNode
    new_child = _VisitNode(child, visitor, *args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/site-packages/pytype/pytd/parse/node.py", line 222, in _VisitNode
    new_node = visitor.Visit(new_node, *args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/site-packages/pytype/pytd/base_visitor.py", line 203, in Visit
    return self.visit_functions[node.__class__.__name__](
  File "/opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/site-packages/pytype/pytd/visitors.py", line 473, in VisitNamedType
    raise KeyError(f"No {name} in module {module_name}") from e
KeyError: 'No NETLINK_CRYPT in module _socket'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ohhhh I forgot the O.....

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What Linux OS? I believe these are imported from the C headers, so I expect this is going to be flavor-dependent in some cases, though I could be wrong about that

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ubuntu 18.04, kernel 5.4.0. Yes, I think it depends on the kernel version and who knows what else. We should include all constants that can appear in realistic systems so people don't get false positives; we can't hope to replicate the exact conditions that determine what constants are available in stubs.

NETLINK_CRYPTO as NETLINK_CRYPTO,
NETLINK_DNRTMSG as NETLINK_DNRTMSG,
NETLINK_FIREWALL as NETLINK_FIREWALL,
NETLINK_IP6_FW as NETLINK_IP6_FW,
NETLINK_NFLOG as NETLINK_NFLOG,
NETLINK_ROUTE as NETLINK_ROUTE,
NETLINK_ROUTE6 as NETLINK_ROUTE6,
NETLINK_SKIP as NETLINK_SKIP,
NETLINK_TAPBASE as NETLINK_TAPBASE,
NETLINK_TCPDIAG as NETLINK_TCPDIAG,
NETLINK_USERSOCK as NETLINK_USERSOCK,
NETLINK_W1 as NETLINK_W1,
NETLINK_XFRM as NETLINK_XFRM,
PACKET_BROADCAST as PACKET_BROADCAST,
PACKET_FASTROUTE as PACKET_FASTROUTE,
PACKET_HOST as PACKET_HOST,
Expand Down