コード例 #1
0
ファイル: exceptions.go プロジェクト: sbinet/go-python
// 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
ファイル: python.go プロジェクト: tsavola/go-python
// 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
ファイル: exceptions.go プロジェクト: jBugman/go-python
// 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
}