2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2008-12-28 08:41:49 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup pythonintern
|
2011-02-27 20:10:08 +00:00
|
|
|
*/
|
|
|
|
|
|
2017-12-04 16:37:31 +11:00
|
|
|
#pragma once
|
2009-03-21 16:03:26 +00:00
|
|
|
|
2023-11-30 14:29:21 +01:00
|
|
|
#include <Python.h>
|
|
|
|
|
|
2024-01-09 22:23:41 +11:00
|
|
|
#if PY_VERSION_HEX < 0x030b0000
|
|
|
|
|
# error "Python 3.11 or greater is required, you'll need to update your Python."
|
2012-11-05 13:48:42 +00:00
|
|
|
#endif
|
|
|
|
|
|
2023-11-30 14:29:21 +01:00
|
|
|
struct bContext;
|
2009-04-19 13:37:59 +00:00
|
|
|
struct ReportList;
|
2009-03-20 10:51:58 +00:00
|
|
|
|
2023-11-30 14:15:11 +11:00
|
|
|
/**
|
|
|
|
|
* Error reporting: convert BKE_report (#ReportList) reports into python errors.
|
2023-10-13 11:29:59 +02:00
|
|
|
*
|
|
|
|
|
* \param clear: When `true`, #BKE_reports_free is called on the given `reports`, which should
|
2023-11-30 14:15:11 +11:00
|
|
|
* then be considered as 'freed' data and not used anymore.
|
|
|
|
|
*/
|
2022-01-07 11:38:08 +11:00
|
|
|
short BPy_reports_to_error(struct ReportList *reports, PyObject *exception, bool clear);
|
2021-12-02 17:24:04 +11:00
|
|
|
/**
|
|
|
|
|
* A version of #BKE_report_write_file_fp that uses Python's stdout.
|
|
|
|
|
*/
|
2019-03-27 14:01:25 +11:00
|
|
|
void BPy_reports_write_stdout(const struct ReportList *reports, const char *header);
|
2015-05-18 09:12:26 +10:00
|
|
|
bool BPy_errors_to_report_ex(struct ReportList *reports,
|
2020-07-27 13:46:58 +10:00
|
|
|
const char *error_prefix,
|
2022-01-07 11:38:08 +11:00
|
|
|
bool use_full,
|
|
|
|
|
bool use_location);
|
2022-04-06 16:15:11 +10:00
|
|
|
/**
|
2023-11-28 11:26:28 +11:00
|
|
|
* \param reports: Any errors will be added to the report list.
|
2022-04-06 16:15:11 +10:00
|
|
|
*
|
2023-11-28 11:26:28 +11:00
|
|
|
* \note The reports are never printed to the `stdout/stderr`,
|
|
|
|
|
* so you may wish to call either `BKE_reports_print(reports)` or `PyErr_Print()` afterwards.
|
|
|
|
|
* Typically `PyErr_Print()` is preferable as `sys.excepthook` is called.
|
2022-05-03 17:54:37 +10:00
|
|
|
*
|
|
|
|
|
* \note The caller is responsible for clearing the error (see #PyErr_Clear).
|
2022-04-06 16:15:11 +10:00
|
|
|
*/
|
2015-05-18 09:12:26 +10:00
|
|
|
bool BPy_errors_to_report(struct ReportList *reports);
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2025-01-07 11:26:06 +11:00
|
|
|
struct bContext *BPY_context_get();
|
2009-05-25 13:48:44 +00:00
|
|
|
|
2009-08-07 16:20:19 +00:00
|
|
|
extern void bpy_context_set(struct bContext *C, PyGILState_STATE *gilstate);
|
2021-12-10 21:40:53 +11:00
|
|
|
/**
|
|
|
|
|
* Context should be used but not now because it causes some bugs.
|
|
|
|
|
*/
|
2020-07-13 11:27:09 +02:00
|
|
|
extern void bpy_context_clear(struct bContext *C, const PyGILState_STATE *gilstate);
|