python/cpython · warning · ValueError
AIX_BUILDDATE is not defined or invalid: {build_date!r}
Error message
AIX_BUILDDATE is not defined or invalid: {build_date!r} What it means
In debug mode, BaseSelectorEventLoop.sock_recv() verifies the socket is non-blocking before scheduling the read, because a blocking socket could freeze the loop while the coroutine thinks it is async. The check (self._debug and sock.gettimeout() != 0) raises ValueError so the misuse surfaces immediately rather than as a mysterious hang.
Source
Thrown at Lib/_aix_support.py:106
# type: () -> List[int]
gnu_type = sysconfig.get_config_var("BUILD_GNU_TYPE")
if not gnu_type:
raise ValueError("BUILD_GNU_TYPE is not defined")
return _aix_vrtl(vrmf=gnu_type)
def aix_buildtag():
# type: () -> str
"""
Return the platform_tag of the system Python was built on.
"""
# AIX_BUILDDATE is defined by configure with:
# lslpp -Lcq bos.rte | awk -F: '{ print $NF }'
build_date = sysconfig.get_config_var("AIX_BUILDDATE")
try:
build_date = int(build_date)
except (ValueError, TypeError):
raise ValueError(f"AIX_BUILDDATE is not defined or invalid: "
f"{build_date!r}")
return _aix_tag(_aix_bgt(), build_date)
View on GitHub (pinned to bc6749cc3b)
Solutions
- Set sock.setblocking(False) (or settimeout(0.0)) before any await loop.sock_recv on it
- Route blocking-configured sockets through regular thread-based I/O instead of loop sock_* APIs
- Standardize a helper that creates loop-ready sockets (socket + setblocking(False)) for all async paths
Example fix
# before sock = socket.create_connection((host, port)) # blocking await loop.sock_recv(sock, 4096) # debug: ValueError # after sock = socket.create_connection((host, port)) sock.setblocking(False) await loop.sock_recv(sock, 4096)
Defensive patterns
Strategy: validation
Validate before calling
def nb(sock):
if sock.gettimeout() != 0:
sock.setblocking(False)
return sock
data = await loop.sock_recv(nb(sock), 4096) Try / catch
try:
await loop.sock_recv(sock, n)
except ValueError as e:
if 'non-blocking' in str(e):
sock.setblocking(False)
return await loop.sock_recv(sock, n)
raise Prevention
- setblocking(False) on every socket passed to loop sock_* APIs
- Use asyncio.wait_for for timeouts instead of socket timeouts
- Centralize socket creation in an async-aware factory
- Assert gettimeout() == 0 in tests that exercise loop I/O
When it happens
Trigger: Enabling asyncio debug mode and calling await loop.sock_recv(sock, n) with a socket in blocking mode or with a positive timeout — the socket default (timeout None) triggers it as soon as debug is on. Sockets from socket.create_connection or third-party connection helpers usually arrive blocking.
Common situations: Turning on PYTHONASYNCIODEBUG or debug=True to diagnose a hang, and this earlier error appears; sockets created by libraries (paho, protobuf RPC layers) with settimeout(30) then passed to sock_*; tests that enable loop debug globally via fixtures.
Related errors
- Must run this script from the repo root
- write() argument must be str, not {type(s).__name__}
- write() argument must be bytes-like, not {type(b).__name__}
- write() argument must be str, not {type(s).__name__}
- write() argument must be bytes-like, not {type(b).__name__}
AI-assisted analysis of python/cpython@bc6749cc3b (2026-08-14).
Data as JSON: /api/errors/d8c3d54491a08d1d.
Report an issue: GitHub.