Coverage for aiocoap/util/socknumbers.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-09-14 09:39 +0000

1# SPDX-FileCopyrightText: Christian Amsüss and the aiocoap contributors 

2# 

3# SPDX-License-Identifier: MIT 

4 

5"""This module contains numeric constants that would be expected in the socket 

6module, but are not exposed there yet. 

7 

8This module will be removed in favor of directly accessing `socket` constants 

9once Python 3.13 support is dropped (see 

10[issue 352](https://github.com/chrysn/aiocoap/issues/352)), with any remnants 

11(decision on whether the RECVERR mechanism *can* be used) moved into the 

12defaults module. 

13""" 

14 

15import sys 

16 

17try: 

18 from socket import IPV6_RECVERR, IP_RECVERR, MSG_ERRQUEUE # type: ignore 

19except ImportError: 

20 if sys.version_info < (3, 14): 

21 if sys.platform == "linux": 

22 IPV6_RECVERR = 25 # type: ignore 

23 IP_RECVERR = 11 # type: ignore 

24 MSG_ERRQUEUE = 8192 # type: ignore 

25 # This is not available on other platforms. 

26 

27HAS_RECVERR = "IP_RECVERR" in locals() and "MSG_ERRQUEUE" in locals() 

28"""Indicates whether the discovered constants indicate that the Linux 

29`setsockopt(IPV6, RECVERR)` / `recvmsg(..., MSG_ERRQUEUE)` mechanism is 

30available"""