1*95b77f2eSStella Laurenzo //===- PybindUtils.cpp - Utilities for interop with pybind11 --------------===// 2*95b77f2eSStella Laurenzo // 3*95b77f2eSStella Laurenzo // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*95b77f2eSStella Laurenzo // See https://llvm.org/LICENSE.txt for license information. 5*95b77f2eSStella Laurenzo // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*95b77f2eSStella Laurenzo // 7*95b77f2eSStella Laurenzo //===----------------------------------------------------------------------===// 8*95b77f2eSStella Laurenzo 9*95b77f2eSStella Laurenzo #include "PybindUtils.h" 10*95b77f2eSStella Laurenzo 11*95b77f2eSStella Laurenzo namespace py = pybind11; 12*95b77f2eSStella Laurenzo 13*95b77f2eSStella Laurenzo pybind11::error_already_set mlir::python::SetPyError(PyObject *excClass, 14*95b77f2eSStella Laurenzo llvm::Twine message) { 15*95b77f2eSStella Laurenzo auto messageStr = message.str(); 16*95b77f2eSStella Laurenzo PyErr_SetString(excClass, messageStr.c_str()); 17*95b77f2eSStella Laurenzo return pybind11::error_already_set(); 18*95b77f2eSStella Laurenzo } 19