{"record":{"id":"5bdd9d836b8ecb5c","repo":"python/cpython","slug":"get-buffer-returned-an-empty-buffer","errorCode":null,"errorMessage":"get_buffer() returned an empty buffer","messagePattern":"get_buffer\\(\\) returned an empty buffer","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"Lib/asyncio/protocols.py","lineNumber":207,"sourceCode":"    def pipe_connection_lost(self, fd, exc):\n        \"\"\"Called when a file descriptor associated with the child process is\n        closed.\n\n        fd is the int file descriptor that was closed.\n        \"\"\"\n\n    def process_exited(self):\n        \"\"\"Called when subprocess has exited.\"\"\"\n\n\ndef _feed_data_to_buffered_proto(proto, data):\n    data_len = len(data)\n    start = 0\n    while data_len:\n        buf = proto.get_buffer(data_len)\n        buf_len = len(buf)\n        if not buf_len:\n            raise RuntimeError('get_buffer() returned an empty buffer')\n\n        if buf_len >= data_len:\n            buf[:data_len] = data[start:] if start else data\n            proto.buffer_updated(data_len)\n            return\n        else:\n            buf[:buf_len] = data[start:start + buf_len]\n            proto.buffer_updated(buf_len)\n            start += buf_len\n            data_len -= buf_len\n","sourceCodeStart":189,"sourceCodeEnd":218,"githubUrl":"https://github.com/python/cpython/blob/bc6749cc3b5ae4a5e88a6cc2d5b3bebbe354eae6/Lib/asyncio/protocols.py#L189-L218","documentation":"Error \"get_buffer() returned an empty buffer\" thrown in python/cpython.","triggerScenarios":"Raised in BufferedProtocol when get_buffer() returns an empty buffer.","commonSituations":"See trigger scenarios.","solutions":["Implement get_buffer() in your protocol's buffer protocol to return a non-empty buffer, or return -1 to indicate no buffer is available.","Ensure the buffer object remains alive for the duration of the write."],"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"}