[pytango] 134/483: fixes #3564959

Sandor Bodo-Merle sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:14:33 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 d4943fec999afdf0b130bb721ec383b43e926d7c
Author: tiagocoutinho <tiagocoutinho at 4e9c00fd-8f2e-0410-aa12-93ce3db5e235>
Date:   Wed Sep 5 15:38:43 2012 +0000

    fixes #3564959
    
    git-svn-id: http://svn.code.sf.net/p/tango-cs/code/bindings/PyTango/trunk@21091 4e9c00fd-8f2e-0410-aa12-93ce3db5e235
---
 PyTango/encoded_attribute.py | 18 +++++++++---------
 PyTango/utils.py             |  9 ++++++---
 doc/revision.rst             |  1 +
 3 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/PyTango/encoded_attribute.py b/PyTango/encoded_attribute.py
index 48b8ea9..d23d784 100644
--- a/PyTango/encoded_attribute.py
+++ b/PyTango/encoded_attribute.py
@@ -34,7 +34,7 @@ import collections
 from ._PyTango import EncodedAttribute, ExtractAs, _ImageFormat
 from ._PyTango import constants
 
-from .utils import is_pure_str
+from .utils import is_pure_str, is_seq
 
 if constants.NUMPY_SUPPORT:
     try:
@@ -122,7 +122,7 @@ def __EncodedAttribute_encode_gray8(self, gray8, width=0, height=0):
 
 def __EncodedAttribute_generic_encode_gray8(self, gray8, width=0, height=0, quality=0, format=_ImageFormat.RawImage):
     """Internal usage only"""
-    if not isinstance(gray8, collections.Sequence):
+    if not is_seq(gray8):
         raise TypeError("Expected sequence (str, numpy.ndarray, list, tuple "
                         "or bytearray) as first argument")
     
@@ -155,7 +155,7 @@ def __EncodedAttribute_generic_encode_gray8(self, gray8, width=0, height=0, qual
             raise IndexError("Expected sequence with at least one row")
         
         row0 = gray8[0]
-        if not isinstance(row0, collections.Sequence):
+        if not is_seq(row0):
             raise IndexError("Expected sequence (str, numpy.ndarray, list, tuple or "
                              "bytearray) inside a sequence")
         width = len(row0)
@@ -198,7 +198,7 @@ def __EncodedAttribute_encode_gray16(self, gray16, width=0, height=0):
                enc.encode_gray16(data)
                attr.set_value(data)
     """
-    if not isinstance(gray16, collections.Sequence):
+    if not is_seq(gray16):
         raise TypeError("Expected sequence (str, numpy.ndarray, list, tuple "
                         "or bytearray) as first argument")
     
@@ -232,7 +232,7 @@ def __EncodedAttribute_encode_gray16(self, gray16, width=0, height=0):
             raise IndexError("Expected sequence with at least one row")
         
         row0 = gray16[0]
-        if not isinstance(row0, collections.Sequence):
+        if not is_seq(row0):
             raise IndexError("Expected sequence (str, numpy.ndarray, list, tuple or "
                              "bytearray) inside a sequence")
         width = len(row0)
@@ -317,7 +317,7 @@ def __EncodedAttribute_encode_rgb24(self, rgb24, width=0, height=0):
     
 def __EncodedAttribute_generic_encode_rgb24(self, rgb24, width=0, height=0, quality=0, format=_ImageFormat.RawImage):
     """Internal usage only"""
-    if not isinstance(rgb24, collections.Sequence):
+    if not is_seq(rgb24):
         raise TypeError("Expected sequence (str, numpy.ndarray, list, tuple "
                         "or bytearray) as first argument")
     
@@ -350,7 +350,7 @@ def __EncodedAttribute_generic_encode_rgb24(self, rgb24, width=0, height=0, qual
             raise IndexError("Expected sequence with at least one row")
         
         row0 = rgb24[0]
-        if not isinstance(row0, collections.Sequence):
+        if not is_seq(row0):
             raise IndexError("Expected sequence (str, numpy.ndarray, list, tuple or "
                              "bytearray) inside a sequence")
         width = len(row0)
@@ -393,7 +393,7 @@ def __EncodedAttribute_encode_jpeg_rgb32(self, rgb32, width=0, height=0, quality
                enc.encode_jpeg_rgb32(data)
                attr.set_value(data)
     """
-    if not isinstance(rgb32, collections.Sequence):
+    if not is_seq(rgb32):
         raise TypeError("Expected sequence (str, numpy.ndarray, list, tuple "
                         "or bytearray) as first argument")
     
@@ -426,7 +426,7 @@ def __EncodedAttribute_encode_jpeg_rgb32(self, rgb32, width=0, height=0, quality
             raise IndexError("Expected sequence with at least one row")
         
         row0 = rgb32[0]
-        if not isinstance(row0, collections.Sequence):
+        if not is_seq(row0):
             raise IndexError("Expected sequence (str, numpy.ndarray, list, tuple or "
                              "bytearray) inside a sequence")
         width = len(row0)
diff --git a/PyTango/utils.py b/PyTango/utils.py
index f429068..d2b6989 100644
--- a/PyTango/utils.py
+++ b/PyTango/utils.py
@@ -28,8 +28,8 @@ This is an internal PyTango module.
 from __future__ import with_statement
 from __future__ import print_function
 
-__all__ = [ "is_pure_str", "is_non_str_seq", "is_integer", "is_number",
-            "is_scalar_type", "is_array_type", "is_numerical_type",
+__all__ = [ "is_pure_str", "is_seq", "is_non_str_seq", "is_integer",
+            "is_number", "is_scalar_type", "is_array_type", "is_numerical_type",
             "is_int_type", "is_float_type", "obj_2_str", "seqStr_2_obj",
             "document_method", "document_static_method", "document_enum",
             "CaselessList", "CaselessDict", "EventCallBack", "get_home",
@@ -122,8 +122,11 @@ __number_klasses = tuple(__number_klasses)
 def is_pure_str(obj):
     return isinstance(obj , __str_klasses)
 
+def is_seq(obj):
+    return isinstance(obj, (collections.Sequence, bytearray))
+
 def is_non_str_seq(obj):
-    return isinstance(obj, collections.Sequence) and not is_pure_str(obj)
+    return is_seq(obj) and not is_pure_str(obj)
 
 def is_integer(obj):
     return isinstance(obj, __int_klasses)
diff --git a/doc/revision.rst b/doc/revision.rst
index 5120a93..cea73b0 100644
--- a/doc/revision.rst
+++ b/doc/revision.rst
@@ -84,6 +84,7 @@ Version history
 |            |         - `3023857: DevEncoded write attribute not supported <https://sourceforge.net/tracker/?func=detail&aid=3023857&group_id=57612&atid=484769>`_                         |
 |            |         - `3521545: [pytango] problem with tango profile <https://sourceforge.net/tracker/?func=detail&aid=3521545&group_id=57612&atid=484769>`_                             |
 |            |         - `3530535: PyTango group writting fails <https://sourceforge.net/tracker/?func=detail&aid=3530535&group_id=57612&atid=484769>`_                                     |
+|            |         - `3564959: EncodedAttribute.encode_xxx() methods don't accept bytearray  <https://sourceforge.net/tracker/?func=detail&aid=3564959&group_id=57612&atid=484769>`_    |
 +------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 | 7.2.3      | Features:                                                                                                                                                                    |
 |            |     - from sourceforge:                                                                                                                                                      |

-- 
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