示例#1
0
// void PyErr_Fetch(PyObject **ptype, PyObject **pvalue, PyObject **ptraceback)
// Retrieve the error indicator into three variables whose addresses are passed. If the error indicator is not set, set all three variables to NULL. If it is set, it will be cleared and you own a reference to each object retrieved. The value and traceback object may be NULL even when the type object is not.
//
// Note This function is normally only used by code that needs to handle exceptions or by code that needs to save and restore the error indicator temporarily.
func PyErr_Fetch() (exc, val, tb *PyObject) {
	exc = &PyObject{}
	val = &PyObject{}
	tb = &PyObject{}

	C.PyErr_Fetch(&exc.ptr, &val.ptr, &tb.ptr)
	return
}
示例#2
0
文件: error.go 项目: MogeiWang/py
func exception() error {
	if C.PyErr_Occurred() == nil {
		return syscall.EFAULT
	}

	var t, v, tb *C.PyObject
	C.PyErr_Fetch(&t, &v, &tb)

	return newError(newObject(t), newObject(v), tb)
}
示例#3
0
文件: err.go 项目: gbbr/textmate
func exception() error {
	if C.PyErr_Occurred() == nil {
		return nil
	}

	var t, v, tb *C.PyObject

	defer C.xdecref(v)

	C.PyErr_Fetch(&t, &v, &tb)

	return &Error{newObject(t), newObject(v), tb}
}
示例#4
0
// getError translates the current Python exception to a Go error, and clears
// the Python exception state.
func getError() error {
	var (
		pyType  *C.PyObject
		pyValue *C.PyObject
		pyTrace *C.PyObject
	)

	C.PyErr_Fetch(&pyType, &pyValue, &pyTrace)

	defer C.DECREF(pyType)
	defer C.DECREF(pyValue)
	defer xDECREF(pyTrace)

	C.PyErr_Clear()

	return fmt.Errorf("Python: %s", stringify(pyValue))
}
示例#5
0
// void PyErr_Fetch(PyObject **ptype, PyObject **pvalue, PyObject **ptraceback)
// Retrieve the error indicator into three variables whose addresses are passed. If the error indicator is not set, set all three variables to NULL. If it is set, it will be cleared and you own a reference to each object retrieved. The value and traceback object may be NULL even when the type object is not.
//
// Note This function is normally only used by code that needs to handle exceptions or by code that needs to save and restore the error indicator temporarily.
func PyErr_Fetch() (exc, val, tb *PyObject) {
	C.PyErr_Fetch(&exc.ptr, &val.ptr, &tb.ptr)
	return
}