195b77f2eSStella Laurenzo //===- PybindUtils.cpp - Utilities for interop with pybind11 --------------===//
295b77f2eSStella Laurenzo //
395b77f2eSStella Laurenzo // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
495b77f2eSStella Laurenzo // See https://llvm.org/LICENSE.txt for license information.
595b77f2eSStella Laurenzo // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
695b77f2eSStella Laurenzo //
795b77f2eSStella Laurenzo //===----------------------------------------------------------------------===//
895b77f2eSStella Laurenzo 
995b77f2eSStella Laurenzo #include "PybindUtils.h"
1095b77f2eSStella Laurenzo 
11*3137c299SStella Laurenzo pybind11::error_already_set
SetPyError(PyObject * excClass,const llvm::Twine & message)12*3137c299SStella Laurenzo mlir::python::SetPyError(PyObject *excClass, const llvm::Twine &message) {
1395b77f2eSStella Laurenzo   auto messageStr = message.str();
1495b77f2eSStella Laurenzo   PyErr_SetString(excClass, messageStr.c_str());
1595b77f2eSStella Laurenzo   return pybind11::error_already_set();
1695b77f2eSStella Laurenzo }
17