-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split test-py2cpp into multiple files
- Loading branch information
Showing
5 changed files
with
937 additions
and
904 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <Python.h> | ||
#include "test/helper.hpp" | ||
|
||
bool uncaught_exception() | ||
{ | ||
if (!! PyErr_Occurred()) | ||
{ | ||
PyErr_Print(); | ||
PyErr_Clear(); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
PyObject* get_py_dict() | ||
{ | ||
static PyObject* py_main { PyImport_AddModule("__main__") }; | ||
static PyObject* py_dict { PyModule_GetDict(py_main) }; | ||
return py_dict; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef __HELPER_HPP__ | ||
#define __HELPER_HPP__ | ||
|
||
#include <Python.h> | ||
|
||
// true if a Python error occurred and was not catch | ||
// Print the error and free error space | ||
bool uncaught_exception(); | ||
|
||
// PyObject corresponding to Python environment | ||
PyObject* get_py_dict(); | ||
|
||
#endif | ||
|
Oops, something went wrong.