5151 'DBR_DOUBLE' , # 64 bit float
5252
5353 'DBR_CHAR_STR' , # Long strings as char arrays
54- 'DBR_CHAR_UNICODE' , # Long unicode strings as char arrays
5554 'DBR_ENUM_STR' , # Enums as strings, default otherwise
5655 'DBR_CHAR_BYTES' , # Long byte strings as char arrays
5756
@@ -163,29 +162,11 @@ class ca_str(str):
163162 def __pos__ (self ):
164163 return str (self )
165164
166-
167- # Overlapping handling for python 2 and python 3. We have three types with two
168- # different semantics: str, bytes, unicode. In python2 str is bytes, while in
169- # python3 str is unicode. We walk a delicate balancing act to get the right
170- # behaviour in both environments!
171- if sys .version_info < (3 ,):
172- ca_bytes = ca_str
173- class ca_unicode (bytes ):
174- __doc__ = ca_doc_string
175- datetime = timestamp_to_datetime
176- def __pos__ (self ):
177- return unicode (self )
178- str_char_code = 'S'
179- else :
180- class ca_bytes (bytes ):
181- __doc__ = ca_doc_string
182- datetime = timestamp_to_datetime
183- def __pos__ (self ):
184- return bytes (self )
185- ca_unicode = ca_str
186- str_char_code = 'U'
187- unicode = str
188-
165+ class ca_bytes (bytes ):
166+ __doc__ = ca_doc_string
167+ datetime = timestamp_to_datetime
168+ def __pos__ (self ):
169+ return bytes (self )
189170
190171class ca_int (int ):
191172 __doc__ = ca_doc_string
@@ -544,7 +525,6 @@ def copy_attributes(self, other):
544525# Special value for DBR_CHAR as str special processing.
545526DBR_ENUM_STR = 996
546527DBR_CHAR_BYTES = 997
547- DBR_CHAR_UNICODE = 998
548528DBR_CHAR_STR = 999
549529
550530
@@ -604,7 +584,7 @@ def copy_attributes(self, other):
604584 'I' : DBR_LONG , # uintc = uint32
605585
606586 # Unicode is supported by decoding from DBR_STRING
607- 'U' : DBR_STRING , # str => unicode
587+ 'U' : DBR_STRING , # str
608588
609589 # We translate machine native integers to DBR_LONG as EPICS has no support
610590 # for 64-bit integers, but not allowing int as an argument is too confusing.
@@ -652,7 +632,7 @@ def _type_to_dbrcode(datatype, format):
652632 - FORMAT_CTRL: retrieve limit and control data
653633 '''
654634 if datatype not in BasicDbrTypes :
655- if datatype in [DBR_CHAR_STR , DBR_CHAR_BYTES , DBR_CHAR_UNICODE ]:
635+ if datatype in [DBR_CHAR_STR , DBR_CHAR_BYTES ]:
656636 datatype = DBR_CHAR # Retrieve this type using char array
657637 elif datatype in [DBR_STSACK_STRING , DBR_CLASS_NAME ]:
658638 return (datatype , datatype ) # format is meaningless in this case
@@ -713,31 +693,20 @@ def _convert_char_str(raw_dbr, count):
713693def _convert_char_bytes (raw_dbr , count ):
714694 return ca_bytes (_string_at (raw_dbr .raw_value , count ))
715695
716- # Conversion from char array to unicode strings
717- def _convert_char_unicode (raw_dbr , count ):
718- return ca_unicode (_string_at (raw_dbr .raw_value , count ).decode ('UTF-8' ))
719-
720696
721697# Arrays of standard strings.
722698def _convert_str_str (raw_dbr , count ):
723699 return ca_str (decode (_make_strings (raw_dbr , count )[0 ]))
724700def _convert_str_str_array (raw_dbr , count ):
725701 strings = [decode (s ) for s in _make_strings (raw_dbr , count )]
726- return _string_array (strings , count , str_char_code )
702+ return _string_array (strings , count , 'U' )
727703
728704# Arrays of bytes strings.
729705def _convert_str_bytes (raw_dbr , count ):
730706 return ca_bytes (_make_strings (raw_dbr , count )[0 ])
731707def _convert_str_bytes_array (raw_dbr , count ):
732708 return _string_array (_make_strings (raw_dbr , count ), count , 'S' )
733709
734- # Arrays of unicode strings.
735- def _convert_str_unicode (raw_dbr , count ):
736- return ca_str (_make_strings (raw_dbr , count )[0 ].decode ('UTF-8' ))
737- def _convert_str_unicode_array (raw_dbr , count ):
738- strings = [s .decode ('UTF-8' ) for s in _make_strings (raw_dbr , count )]
739- return _string_array (strings , count , 'U' )
740-
741710
742711# For everything that isn't a string we either return a scalar or a ca_array
743712def _convert_other (raw_dbr , count ):
@@ -790,16 +759,11 @@ def type_to_dbr(channel, datatype, format):
790759 elif dtype is numpy .uint8 and datatype == DBR_CHAR_BYTES :
791760 # Conversion from char array to bytes strings
792761 convert = _convert_char_bytes
793- elif dtype is numpy .uint8 and datatype == DBR_CHAR_UNICODE :
794- # Conversion from char array to unicode strings
795- convert = _convert_char_unicode
796762 else :
797763 if dtype is str_dtype :
798- # String arrays, either unicode or normal.
764+ # String arrays
799765 if isinstance (datatype , type ) and issubclass (datatype , bytes ):
800766 convert = (_convert_str_bytes , _convert_str_bytes_array )
801- elif isinstance (datatype , type ) and issubclass (datatype , unicode ):
802- convert = (_convert_str_unicode , _convert_str_unicode_array )
803767 else :
804768 convert = (_convert_str_str , _convert_str_str_array )
805769 else :
@@ -867,7 +831,7 @@ def value_to_dbr(channel, datatype, value):
867831
868832 # If no datatype specified then use the target datatype.
869833 if datatype is None :
870- if isinstance (value , (str , bytes , unicode )):
834+ if isinstance (value , (str , bytes )):
871835 # Give strings with no datatype special treatment, let the IOC do
872836 # the decoding. It's safer this way.
873837 datatype = DBR_STRING
@@ -893,7 +857,7 @@ def value_to_dbr(channel, datatype, value):
893857 # We'll let numpy do most of the heavy lifting.
894858 result = _require_value (value , str_dtype )
895859 except UnicodeEncodeError :
896- # Whoops, looks like unicode, need to encode each string.
860+ # Whoops, looks like we need to encode each string.
897861 value = _require_value (value , None )
898862 result = numpy .empty (value .shape , str_dtype )
899863 for n , s in enumerate (value ):
0 commit comments