{"record":{"id":"4ce5d4bd880fb85b","repo":"pola-rs/polars","slug":"dlpack","errorCode":null,"errorMessage":"__dlpack__","messagePattern":"__dlpack__","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/interchange/buffer.py","lineNumber":67,"sourceCode":"            n_bytes, rest = divmod(n_bits, 8)\n            # Round up to the nearest byte\n            if rest == 0:\n                return n_bytes\n            else:\n                return n_bytes + 1\n\n        return self._data.len() * (dtype[1] // 8)\n\n    @property\n    def ptr(self) -> int:\n        \"\"\"Pointer to start of the buffer as an integer.\"\"\"\n        pointer, _, _ = self._data._get_buffer_info()\n        return pointer\n\n    def __dlpack__(self) -> NoReturn:\n        \"\"\"Represent this structure as DLPack interface.\"\"\"\n        msg = \"__dlpack__\"\n        raise NotImplementedError(msg)\n\n    def __dlpack_device__(self) -> tuple[DlpackDeviceType, None]:\n        \"\"\"Device type and device ID for where the data in the buffer resides.\"\"\"\n        return (DlpackDeviceType.CPU, None)\n\n    def __repr__(self) -> str:\n        bufsize = self.bufsize\n        ptr = self.ptr\n        device = self.__dlpack_device__()[0].name\n        return f\"PolarsBuffer(bufsize={bufsize}, ptr={ptr}, device={device!r})\"\n","sourceCodeStart":49,"sourceCodeEnd":78,"githubUrl":"https://github.com/pola-rs/polars/blob/9b5d73fd00236295624374b075d16b1fe6ec6df9/py-polars/src/polars/interchange/buffer.py#L49-L78","documentation":"Sentinel NotImplementedError raised by PolarsBuffer.__dlpack__ in the interchange protocol. The DLPack export interface is deliberately not implemented for Polars buffers, so any consumer calling __dlpack__ on them hits this immediately regardless of input. Export via to_numpy/to_arrow instead.","triggerScenarios":"Thrown at py-polars/src/polars/interchange/buffer.py:67 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the underlying object exposes a __dlpack__ method; if the buffer does not support DLPack, convert the data (e.g. via rechunk/cast) before exporting."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9b5d73fd00236295624374b075d16b1fe6ec6df9","analyzedAt":"2026-08-19T12:15:06.350Z","contentChangedAt":"2026-08-19T12:15:06.350Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}