[pytango] 53/483: added PyTango.Except.throw_python_exception
Sandor Bodo-Merle
sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:14:23 UTC 2017
This is an automated email from the git hooks/post-receive script.
sbodomerle-guest pushed a commit to annotated tag bliss_8.10
in repository pytango.
commit adf337c6c64bc00a6cd166b22cbe04510eb7ba85
Author: tiagocoutinho <tiagocoutinho at 4e9c00fd-8f2e-0410-aa12-93ce3db5e235>
Date: Fri Nov 11 16:56:14 2011 +0000
added PyTango.Except.throw_python_exception
git-svn-id: http://svn.code.sf.net/p/tango-cs/code/bindings/PyTango/trunk@18359 4e9c00fd-8f2e-0410-aa12-93ce3db5e235
---
Makefile | 3 +++
PyTango/exception.py | 21 +++++++++++++++++++++
PyTango/ipython/ipython_00_10/ipython_00_10.py | 2 +-
src/exception.cpp | 14 ++++++++++----
src/exception.h | 3 ++-
5 files changed, 37 insertions(+), 6 deletions(-)
diff --git a/Makefile b/Makefile
index 97d5bb5..701f92a 100644
--- a/Makefile
+++ b/Makefile
@@ -62,6 +62,7 @@ CC = gcc
CCFLAGS = -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -fPIC $(INCLUDE_DIRS)
LN = g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions
+LN_STATIC = g++ -pthread -static -Wl,-O1 -Wl,-Bsymbolic-functions
LN_VER = -Wl,-h -Wl,--strip-all
LN_LIBS = -ltango -llog4tango -lpthread -lrt -ldl -lomniORB4 -lomniDynamic4 -lomnithread -lCOS4 -lboost_python
LN_DIRS = -L$(TANGO_ROOT)/lib
@@ -78,6 +79,7 @@ $(PY_INC) \
$(NUMPY_INC)
LIB_NAME = _PyTango.so
+LIB_NAME_STATIC = _PyTangoStatic.so
LIB_SYMB_NAME = $(LIB_NAME).dbg
OBJS = \
@@ -190,6 +192,7 @@ $(OBJS_DIR)/%.o: $(SRC_DIR)/server/%.cpp
$(LIB_NAME): $(OBJS)
$(LN) $(OBJS) $(LN_DIRS) $(LN_LIBS) -o $(OBJS_DIR)/$(LIB_NAME) $(LN_VER)
+# $(LN_STATIC) $(OBJS) $(LN_DIRS) $(LN_LIBS) -o $(OBJS_DIR)/$(LIB_NAME_STATIC) $(LN_VER)
# objcopy --only-keep-debug $(OBJS_DIR)/$(LIB_NAME) $(OBJS_DIR)/$(LIB_SYMB_NAME)
# objcopy --strip-debug --strip-unneeded $(OBJS_DIR)/$(LIB_NAME)
# objcopy --add-gnu-debuglink=$(OBJS_DIR)/$(LIB_SYMB_NAME) $(OBJS_DIR)/$(LIB_NAME)
diff --git a/PyTango/exception.py b/PyTango/exception.py
index b81d1c0..22b1522 100644
--- a/PyTango/exception.py
+++ b/PyTango/exception.py
@@ -95,6 +95,27 @@ def __doc_Except():
- ex : (PyTango.DevFailed) The :class:`~PyTango.DevFailed` exception
""" )
+ document_static_method("throw_python_exception", """
+ throw_python_exception(type, value, traceback) -> None
+
+ Generate and throw a TANGO DevFailed exception.
+ The exception is created with a single :class:`~PyTango.DevError`
+ object. A default value *PyTango.ErrSeverity.ERR* is defined for
+ the :class:`~PyTango.DevError` severity field.
+
+ The parameters are the same as the ones generates by a call to
+ :func:`sys.exc_info`.
+
+ Parameters :
+ - type : (class) the exception type of the exception being handled
+ - value : (object) exception parameter (its associated value or the
+ second argument to raise, which is always a class instance
+ if the exception type is a class object)
+ - traceback : (traceback) traceback object
+
+ Throws : DevFailed
+ """ )
+
def __doc_DevError():
DevError.__doc__ = """
Structure describing any error resulting from a command execution,
diff --git a/PyTango/ipython/ipython_00_10/ipython_00_10.py b/PyTango/ipython/ipython_00_10/ipython_00_10.py
index bc17d92..c9e2104 100644
--- a/PyTango/ipython/ipython_00_10/ipython_00_10.py
+++ b/PyTango/ipython/ipython_00_10/ipython_00_10.py
@@ -494,7 +494,7 @@ def __tango_exc_handler(ip, etype, value, tb):
if etype == PyTango.DevFailed:
if len(value.args):
v = value[0]
- print v.reason,":",v.desc
+ print "%s: %s" % (v.reason ,v.desc)
else:
print "Empty DevFailed"
print "For more detailed information type: tango_error"
diff --git a/src/exception.cpp b/src/exception.cpp
index 27e895d..ae6131b 100644
--- a/src/exception.cpp
+++ b/src/exception.cpp
@@ -151,11 +151,15 @@ void throw_python_dev_failed()
throw df;
}
-void throw_python_generic_exception()
+void throw_python_generic_exception(PyObject *type, PyObject *value,
+ PyObject *traceback)
{
- PyObject *type, *value, *traceback;
- PyErr_Fetch(&type, &value, &traceback);
-
+ if ((type == NULL) || (value == NULL) || (traceback == NULL))
+ {
+ PyObject *type, *value, *traceback;
+ PyErr_Fetch(&type, &value, &traceback);
+ }
+
//
// Send a default exception in case Python does not send us information
//
@@ -444,10 +448,12 @@ void export_exceptions()
.def("compare_exception",
(bool (*) (const Tango::DevFailed &, const Tango::DevFailed &))
compare_exception_)
+ .def("throw_python_exception", &throw_python_generic_exception)
.staticmethod("throw_exception")
.staticmethod("re_throw_exception")
.staticmethod("print_exception")
.staticmethod("print_error_stack")
+ .staticmethod("throw_python_exception")
;
convert_PyDevFailed_to_DevFailed pydevfailed_2_devfailed;
diff --git a/src/exception.h b/src/exception.h
index 7cb32ae..9c16761 100644
--- a/src/exception.h
+++ b/src/exception.h
@@ -51,7 +51,8 @@ void throw_python_dev_failed();
/**
* Throws the current python exception as a DevFailed exception.
*/
-void throw_python_generic_exception();
+void throw_python_generic_exception(PyObject *type=NULL, PyObject *value=NULL,
+ PyObject *traceback=NULL);
/**
* Handles the current python exception:
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/pytango.git
More information about the debian-science-commits
mailing list