Example #1
0
// Normalize adjusts e.Kind/e.Value in the case that the values aren't
// normalized to start with.  It's possible that an Error returned from Python
// might have e.Kind be a Class, with e.Value not being an instance of that
// class, Normalize will fix this.  The separate normalization is implemented in
// Python to improve performance.
func (e *Error) Normalize() {
	exc := e.Kind.c()
	val := e.Value.c()
	tb := e.tb
	C.PyErr_NormalizeException(&exc, &val, &tb)
	e.Kind = newObject(exc)
	e.Value = newObject(val)
	e.tb = tb
}
Example #2
0
File: err.go Project: gbbr/textmate
// Normalize adjusts e.Kind/e.Value in the case that the values aren't
// normalized to start with.  It's possible that an Error returned from Python
// might have e.Kind be a Class, with e.Value not being an instance of that
// class, Normalize will fix this.  The separate normalization is implemented in
// Python to improve performance.
func (e *Error) Normalize() {
	exc := c(e.Kind)
	val := c(e.Value)
	tb := e.tb
	C.PyErr_NormalizeException(&exc, &val, &tb)
	if exc != c(e.Kind) {
		e.Kind = newObject(exc)
	}
	if val != c(e.Value) {
		e.Value = newObject(val)
	}
	e.tb = tb
}
Example #3
0
// void PyErr_NormalizeException(PyObject**exc, PyObject**val, PyObject**tb)
// Under certain circumstances, the values returned by PyErr_Fetch() below can be “unnormalized”, meaning that *exc is a class object but *val is not an instance of the same class. This function can be used to instantiate the class in that case. If the values are already normalized, nothing happens. The delayed normalization is implemented to improve performance.
func PyErr_NormalizeException(exc, val, tb *PyObject) (*PyObject, *PyObject, *PyObject) {
	C.PyErr_NormalizeException(&exc.ptr, &val.ptr, &tb.ptr)
	return exc, val, tb
}