{"record":{"id":"0cbe98355e28d4a8","repo":"python/cpython","slug":"invalid-address-must-be-none-or-self-address","errorCode":null,"errorMessage":"Invalid address: must be None or {self._address}","messagePattern":"Invalid address: must be None or (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"Lib/asyncio/proactor_events.py","lineNumber":489,"sourceCode":"        self._buffer = collections.deque()\n        self._loop.call_soon(self._loop_reading)\n\n    def _set_extra(self, sock):\n        _set_socket_extra(self, sock)\n\n    def get_write_buffer_size(self):\n        return self._buffer_size\n\n    def abort(self):\n        self._force_close(None)\n\n    def sendto(self, data, addr=None):\n        if not isinstance(data, (bytes, bytearray, memoryview)):\n            raise TypeError('data argument must be bytes-like object (%r)',\n                            type(data))\n\n        if self._address is not None and addr not in (None, self._address):\n            raise ValueError(\n                f'Invalid address: must be None or {self._address}')\n\n        if self._conn_lost and self._address:\n            if self._conn_lost >= constants.LOG_THRESHOLD_FOR_CONNLOST_WRITES:\n                logger.warning('socket.sendto() raised exception.')\n            self._conn_lost += 1\n            return\n\n        # Ensure that what we buffer is immutable.\n        self._buffer.append((bytes(data), addr))\n        self._buffer_size += len(data) + self._header_size\n\n        if self._write_fut is None:\n            # No current write operations are active, kick one off\n            self._loop_writing()\n        # else: A write operation is already kicked off\n\n        self._maybe_pause_protocol()","sourceCodeStart":471,"sourceCodeEnd":507,"githubUrl":"https://github.com/python/cpython/blob/bc6749cc3b5ae4a5e88a6cc2d5b3bebbe354eae6/Lib/asyncio/proactor_events.py#L471-L507","documentation":"Error \"Invalid address: must be None or {self._address}\" thrown in python/cpython.","triggerScenarios":"Raised when sendto() is given an address that is neither None nor the transport's bound address.","commonSituations":"See trigger scenarios.","solutions":["Pass None or the exact address the socket is connected to; use transport.get_extra_info('peername') to discover the valid address."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"bc6749cc3b5ae4a5e88a6cc2d5b3bebbe354eae6","analyzedAt":"2026-08-14T22:01:13.976Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}