[pytango] 177/483: fixes #3576353
Sandor Bodo-Merle
sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:14:38 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 a7b50956945c189e1a1a442895a3c10281f033e9
Author: tiagocoutinho <tiagocoutinho at 4e9c00fd-8f2e-0410-aa12-93ce3db5e235>
Date: Mon Dec 17 14:16:08 2012 +0000
fixes #3576353
git-svn-id: http://svn.code.sf.net/p/tango-cs/code/bindings/PyTango/trunk@21733 4e9c00fd-8f2e-0410-aa12-93ce3db5e235
---
Makefile | 21 ++++++++++++++++++++-
PyTango/device_class.py | 19 +++++++++++--------
PyTango/device_server.py | 9 ++++-----
PyTango/globals.py | 21 +++++++++++++++++++--
doc/revision.rst | 1 +
src/server/device_class.cpp | 22 +++-------------------
src/server/device_impl.cpp | 1 -
7 files changed, 58 insertions(+), 36 deletions(-)
diff --git a/Makefile b/Makefile
index dde091b..28881c8 100644
--- a/Makefile
+++ b/Makefile
@@ -43,15 +43,29 @@
# - PY_VER: use a specific python version (default is empty) (ex: 3.2)
ifdef PY_VER
+
+ifdef PY_DEBUG
+PY_EXC=python$(PY_VER)-dbg
+else
PY_EXC=python$(PY_VER)
+endif # PY_DEBUG
+
PY_MAJOR=$(shell $(PY_EXC) -c "import sys; sys.stdout.write(str(sys.version_info[0]))")
PY_MINOR=$(shell $(PY_EXC) -c "import sys; sys.stdout.write(str(sys.version_info[1]))")
+
+else
+
+ifdef PY_DEBUG
+PY_EXC=python-dbg
else
PY_EXC=python
+endif # PY_DEBUG
+
+PY_EXC=python
PY_MAJOR=$(shell $(PY_EXC) -c "import sys; sys.stdout.write(str(sys.version_info[0]))")
PY_MINOR=$(shell $(PY_EXC) -c "import sys; sys.stdout.write(str(sys.version_info[1]))")
PY_VER=$(PY_MAJOR).$(PY_MINOR)
-endif
+endif # PY_VER
PY_VER_S=$(PY_MAJOR)$(PY_MINOR)
@@ -77,7 +91,12 @@ endif
CC = gcc
+ifdef PY_DEBUG
+PY_INC = $(shell python$(PY_VER)-dbg-config --includes)
+else
PY_INC = $(shell python$(PY_VER)-config --includes)
+endif
+
NUMPY_INC = -I$(NUMPY_ROOT)/include
TANGO_INC = -I$(TANGO_ROOT)/include
PRE_C_H = precompiled_header.hpp
diff --git a/PyTango/device_class.py b/PyTango/device_class.py
index db2e4e6..d45bdd9 100644
--- a/PyTango/device_class.py
+++ b/PyTango/device_class.py
@@ -42,7 +42,7 @@ from .utils import is_pure_str, is_non_str_seq, seqStr_2_obj, obj_2_str, \
from .utils import document_method as __document_method
from .globals import get_class, get_class_by_class, \
- get_constructed_class_by_class
+ get_constructed_class_by_class, delete_class
from .attr_data import AttrData
@@ -309,6 +309,9 @@ class DeviceClass(_DeviceClass):
def __repr__(self):
return '%s(%s)' % (self.__class__.__name__, self.get_name())
+ def __unregister_class(self):
+ delete_class(self)
+
def __throw_create_attribute_exception(self, msg):
"""Helper method to throw DevFailed exception when inside create_attribute"""
Except.throw_exception("PyDs_WrongAttributeDefinition", msg, "create_attribute()")
@@ -533,20 +536,20 @@ class DeviceClass(_DeviceClass):
klass = self.__class__
klass_name = klass.__name__
- info, klass = get_class_by_class(klass), get_constructed_class_by_class(klass)
-
+
+ info = get_class_by_class(klass)
if info is None:
raise RuntimeError("Device class '%s' is not registered" % klass_name)
- if klass is None:
+ deviceClass = get_constructed_class_by_class(klass)
+ if deviceClass is None:
raise RuntimeError("Device class '%s' as not been constructed" % klass_name)
- deviceClassClass, deviceImplClass, deviceImplName = info
- deviceImplClass._device_class_instance = klass
-
+ _, deviceImplClass, deviceImplName = info
tmp_dev_list = []
+
for dev_name in device_list:
- device = deviceImplClass(klass, dev_name)
+ device = deviceImplClass(deviceClass, dev_name)
self._add_device(device)
tmp_dev_list.append(device)
diff --git a/PyTango/device_server.py b/PyTango/device_server.py
index 8c05fa5..6bd051f 100644
--- a/PyTango/device_server.py
+++ b/PyTango/device_server.py
@@ -44,7 +44,7 @@ from ._PyTango import DevFailed, DeviceImpl, Device_3Impl, Device_4Impl, \
from .utils import document_method as __document_method
from .utils import copy_doc
from .attr_data import AttrData
-
+from .globals import get_device_class_from_device_impl
from .log4tango import TangoStream
class AttributeAlarm(object):
@@ -273,10 +273,9 @@ def __init_Attribute():
Attribute.set_properties = __Attribute__set_properties
def __DeviceImpl__get_device_class(self):
- try:
- return self._device_class_instance
- except AttributeError:
- return None
+ if self._device_class_instance is None:
+ self._device_class_instance = get_device_class_from_device_impl(self)
+ return self._device_class_instance
def __DeviceImpl__get_device_properties(self, ds_class = None):
"""get_device_properties(self, ds_class = None) -> None
diff --git a/PyTango/globals.py b/PyTango/globals.py
index e288607..8a91bf4 100644
--- a/PyTango/globals.py
+++ b/PyTango/globals.py
@@ -28,7 +28,9 @@ This is an internal PyTango module.
__all__ = [ "get_class", "get_classes", "get_cpp_class", "get_cpp_classes",
"get_constructed_class", "get_constructed_classes",
"class_factory", "delete_class_list",
- "class_list", "cpp_class_list", "constructed_class"]
+ "class_list", "cpp_class_list", "constructed_class", "delete_class",
+ "get_device_class_from_device_impl",
+ "get_device_class_from_device_impl_class"]
__docformat__ = "restructuredtext"
@@ -83,6 +85,14 @@ def get_constructed_class_by_class(klass):
return k
return None
+def get_device_class_from_device_impl(device_impl):
+ return get_device_class_from_device_impl_class(device_impl.__class__)
+
+def get_device_class_from_device_impl_class(device_impl_class):
+ for info in get_classes():
+ if info[1] == device_impl_class:
+ return get_constructed_class_by_class(info[0])
+
#
# A method to delete Tango classes from Python
#
@@ -90,7 +100,14 @@ def get_constructed_class_by_class(klass):
def delete_class_list():
global constructed_class
if len(constructed_class) != 0:
- del(constructed_class[:])
+ del(constructed_class[:])
+
+def delete_class(device_class):
+ constructed_classes = get_constructed_classes()
+ try:
+ constructed_classes.remove(device_class)
+ except ValueError:
+ pass
#
# A generic class_factory method
diff --git a/doc/revision.rst b/doc/revision.rst
index 8019d93..4e57970 100644
--- a/doc/revision.rst
+++ b/doc/revision.rst
@@ -82,6 +82,7 @@ Version history
+============+==============================================================================================================================================================================+
| 8.0.3 | Bug fixes: |
| | - from sourceforge: |
+| | - `3576353: [pytango] segfault on 'RestartServer' <https://sourceforge.net/tracker/?func=detail&aid=3576353&group_id=57612&atid=484769>`_ |
| | - `3579062: [pytango] Attribute missing methods <https://sourceforge.net/tracker/?func=detail&aid=3579062&group_id=57612&atid=484769>`_ |
| | - `3586337: [pytango] Some DeviceClass methods are not python safe <https://sourceforge.net/tracker/?func=detail&aid=3586337&group_id=57612&atid=484769>`_ |
+------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
diff --git a/src/server/device_class.cpp b/src/server/device_class.cpp
index d5b8033..3677a4f 100644
--- a/src/server/device_class.cpp
+++ b/src/server/device_class.cpp
@@ -167,7 +167,9 @@ CppDeviceClassWrap::CppDeviceClassWrap(PyObject *self, const std::string &name)
* Destructor
*/
CppDeviceClassWrap::~CppDeviceClassWrap()
-{}
+{
+ CALL_DEVCLASS_METHOD(_DeviceClass__unregister_class)
+}
void CppDeviceClassWrap::init_class()
{
@@ -304,24 +306,6 @@ namespace PyDeviceClass
}
return py_cmd_list;
}
-
- /*
- void add_device(CppDeviceClass &self, auto_ptr<Tango::DeviceImpl> dev)
- {
- self.add_device(dev.get());
- dev.release();
- }
-
- void add_device(CppDeviceClass &self, auto_ptr<Tango::Device_4Impl> dev)
- {
- self.add_device(dev.get());
- dev.release();
- }
-
- void (*add_device1)(CppDeviceClass &, auto_ptr<Tango::DeviceImpl>) = &add_device;
- void (*add_device2)(CppDeviceClass &, auto_ptr<Tango::Device_4Impl>) = &add_device;
- */
-
}
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS (export_device_overload,
diff --git a/src/server/device_impl.cpp b/src/server/device_impl.cpp
index 16bd950..69b3d4c 100644
--- a/src/server/device_impl.cpp
+++ b/src/server/device_impl.cpp
@@ -1198,7 +1198,6 @@ void export_device_impl()
.def("_add_attribute", &PyDeviceImpl::add_attribute)
.def("_remove_attribute", &PyDeviceImpl::remove_attribute,
remove_attribute_overload())
- //@TODO .def("get_device_class")
//@TODO .def("get_db_device")
.def("is_attribute_polled", &PyDeviceImpl::is_attribute_polled)
.def("is_command_polled", &PyDeviceImpl::is_command_polled)
--
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