|
| 1 | +package python3 |
| 2 | + |
| 3 | +/* |
| 4 | +#include "Python.h" |
| 5 | +*/ |
| 6 | +import "C" |
| 7 | + |
| 8 | +import ( |
| 9 | +"unsafe" |
| 10 | +) |
| 11 | + |
| 12 | +//PyErr_Clear : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_Clear |
| 13 | +func PyErr_Clear() { |
| 14 | +C.PyErr_Clear() |
| 15 | +} |
| 16 | + |
| 17 | +//PyErr_PrintEx : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_PrintEx |
| 18 | +func PyErr_PrintEx(setSysLastVars bool) { |
| 19 | +if setSysLastVars { |
| 20 | +C.PyErr_PrintEx(1) |
| 21 | +} else { |
| 22 | +C.PyErr_PrintEx(0) |
| 23 | +} |
| 24 | +} |
| 25 | + |
| 26 | +//PyErr_Print : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_Print |
| 27 | +func PyErr_Print() { |
| 28 | +C.PyErr_PrintEx(1) |
| 29 | +} |
| 30 | + |
| 31 | +//PyErr_WriteUnraisable : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_WriteUnraisable |
| 32 | +func PyErr_WriteUnraisable(obj *PyObject) { |
| 33 | +C.PyErr_WriteUnraisable(toc(obj)) |
| 34 | +} |
| 35 | + |
| 36 | +//PyErr_SetString : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_SetString |
| 37 | +func PyErr_SetString(pyType *PyObject, message string) { |
| 38 | +cmessage := C.CString(message) |
| 39 | +defer C.free(unsafe.Pointer(cmessage)) |
| 40 | + |
| 41 | +C.PyErr_SetString(toc(pyType), cmessage) |
| 42 | + |
| 43 | +} |
| 44 | + |
| 45 | +//PyErr_SetObject : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_SetObject |
| 46 | +func PyErr_SetObject(pyType, value *PyObject) { |
| 47 | +C.PyErr_SetObject(toc(pyType), toc(value)) |
| 48 | +} |
| 49 | + |
| 50 | +//PyErr_SetNone : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_SetNone |
| 51 | +func PyErr_SetNone(pyType *PyObject) { |
| 52 | +C.PyErr_SetNone(toc(pyType)) |
| 53 | +} |
| 54 | + |
| 55 | +//PyErr_BadArgument : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_BadArgument |
| 56 | +func PyErr_BadArgument() { |
| 57 | +C.PyErr_BadArgument() |
| 58 | +} |
| 59 | + |
| 60 | +//PyErr_NoMemory : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_NoMemory |
| 61 | +func PyErr_NoMemory() *PyObject { |
| 62 | +return togo(C.PyErr_NoMemory()) |
| 63 | +} |
| 64 | + |
| 65 | +//PyErr_SetImportErrorSubclass : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_SetImportErrorSubclass |
| 66 | +func PyErr_SetImportErrorSubclass(msg, name, path, subclass *PyObject) *PyObject { |
| 67 | +return togo(C.PyErr_SetImportErrorSubclass(toc(msg), toc(name), toc(path), toc(subclass))) |
| 68 | +} |
| 69 | + |
| 70 | +//PyErr_SetImportError : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_SetImportError |
| 71 | +func PyErr_SetImportError(msg, name, path *PyObject) *PyObject { |
| 72 | +return togo(C.PyErr_SetImportError(toc(msg), toc(name), toc(path))) |
| 73 | +} |
| 74 | + |
| 75 | +//PyErr_SyntaxLocationObject : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_SyntaxLocationObject |
| 76 | +func PyErr_SyntaxLocationObject(filename *PyObject, lineno, col_offset int) { |
| 77 | +C.PyErr_SyntaxLocationObject(toc(filename), C.int(lineno), C.int(col_offset)) |
| 78 | +} |
| 79 | + |
| 80 | +//PyErr_SyntaxLocationEx : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_SyntaxLocationEx |
| 81 | +func PyErr_SyntaxLocationEx(filename string, lineno, col_offset int) { |
| 82 | +cfilename := C.CString(filename) |
| 83 | +defer C.free(unsafe.Pointer(cfilename)) |
| 84 | + |
| 85 | +C.PyErr_SyntaxLocationEx(cfilename, C.int(lineno), C.int(col_offset)) |
| 86 | +} |
| 87 | + |
| 88 | +//PyErr_SyntaxLocation : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_SyntaxLocation |
| 89 | +func PyErr_SyntaxLocation(filename string, lineno int) { |
| 90 | +cfilename := C.CString(filename) |
| 91 | +defer C.free(unsafe.Pointer(cfilename)) |
| 92 | + |
| 93 | +C.PyErr_SyntaxLocation(cfilename, C.int(lineno)) |
| 94 | + |
| 95 | +} |
| 96 | + |
| 97 | +//PyErr_BadInternalCall : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_BadInternalCall |
| 98 | +func PyErr_BadInternalCall() { |
| 99 | +C.PyErr_BadInternalCall() |
| 100 | +} |
| 101 | + |
| 102 | +//PyErr_Occurred : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_Occurred |
| 103 | +func PyErr_Occurred() *PyObject { |
| 104 | +return togo(C.PyErr_Occurred()) |
| 105 | +} |
| 106 | + |
| 107 | +//PyErr_GivenExceptionMatches : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_GivenExceptionMatches |
| 108 | +func PyErr_GivenExceptionMatches(given, exc *PyObject) bool { |
| 109 | +ret := C.PyErr_GivenExceptionMatches(toc(given), toc(exc)) |
| 110 | +return ret == 1 |
| 111 | +} |
| 112 | + |
| 113 | +//PyErr_ExceptionMatches : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_ExceptionMatches |
| 114 | +func PyErr_ExceptionMatches(exc *PyObject) bool { |
| 115 | +ret := C.PyErr_ExceptionMatches(toc(exc)) |
| 116 | +return ret == 1 |
| 117 | +} |
| 118 | + |
| 119 | +//PyErr_Fetch : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_Fetch |
| 120 | +func PyErr_Fetch() (*PyObject, *PyObject, *PyObject) { |
| 121 | +var pyType, value, traceback *C.PyObject |
| 122 | +C.PyErr_Fetch(&pyType, &value, &traceback) |
| 123 | +return togo(pyType), togo(value), togo(traceback) |
| 124 | +} |
| 125 | + |
| 126 | +//PyErr_Restore : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_Restore |
| 127 | +func PyErr_Restore(pyType *PyObject, value *PyObject, traceback *PyObject) { |
| 128 | +C.PyErr_Restore(toc(pyType), toc(value), toc(traceback)) |
| 129 | +} |
| 130 | + |
| 131 | +//PyErr_NormalizeException : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_NormalizeException |
| 132 | +func PyErr_NormalizeException(exc, val, tb *PyObject) (*PyObject, *PyObject, *PyObject) { |
| 133 | +cexc := toc(exc) |
| 134 | +cval := toc(val) |
| 135 | +ctb := toc(tb) |
| 136 | +C.PyErr_NormalizeException(&cexc, &cval, &ctb) |
| 137 | +return togo(cexc), togo(cval), togo(ctb) |
| 138 | +} |
| 139 | + |
| 140 | +//PyErr_GetExcInfo : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_GetExcInfo |
| 141 | +func PyErr_GetExcInfo() (*PyObject, *PyObject, *PyObject) { |
| 142 | +var pyType, value, traceback *C.PyObject |
| 143 | +C.PyErr_GetExcInfo(&pyType, &value, &traceback) |
| 144 | +return togo(pyType), togo(value), togo(traceback) |
| 145 | +} |
| 146 | + |
| 147 | +//PyErr_SetExcInfo : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_SetExcInfo |
| 148 | +func PyErr_SetExcInfo(pyType *PyObject, value *PyObject, traceback *PyObject) { |
| 149 | +C.PyErr_SetExcInfo(toc(pyType), toc(value), toc(traceback)) |
| 150 | +} |
| 151 | + |
| 152 | +//PyErr_CheckSignals : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_CheckSignals |
| 153 | +func PyErr_CheckSignals() int { |
| 154 | +return int(C.PyErr_CheckSignals()) |
| 155 | +} |
| 156 | + |
| 157 | +//PyErr_SetInterrupt : https://docs.python.org/3/c-api/exceptions.html#c.PyErr_SetInterrupt |
| 158 | +func PyErr_SetInterrupt() { |
| 159 | +C.PyErr_SetInterrupt() |
| 160 | +} |
| 161 | + |
| 162 | +//PySignal_SetWakeupFd : https://docs.python.org/3/c-api/exceptions.html#c.PySignal_SetWakeupFd |
| 163 | +func PySignal_SetWakeupFd(fd uintptr) uintptr { |
| 164 | +return uintptr(C.PySignal_SetWakeupFd(C.int(fd))) |
| 165 | +} |
0 commit comments