30
30
# -*- coding: utf-8 -*-
31
31
32
32
import enum
33
- import warnings
34
33
from functools import lru_cache
35
34
from typing import Optional
36
35
@@ -491,14 +490,6 @@ def value(self):
491
490
"""The value of this simulation object."""
492
491
return self ._value
493
492
494
- def __str__ (self ):
495
- if isinstance (self .value , bytes ):
496
- StringObject ._emit_str_warning (self )
497
- return self .value .decode ("ascii" )
498
- else :
499
- ModifiableObject ._emit_str_warning (self )
500
- return str (self .value )
501
-
502
493
503
494
class NonHierarchyIndexableObject (NonHierarchyObject ):
504
495
"""A non-hierarchy indexable object.
@@ -770,20 +761,6 @@ def value(self) -> BinaryValue:
770
761
def __int__ (self ):
771
762
return int (self .value )
772
763
773
- def _emit_str_warning (self ):
774
- warnings .warn (
775
- "`str({t})` is deprecated, and in future will return `{t}._path`. "
776
- "To get a string representation of the value, use `str({t}.value)`." .format (
777
- t = type (self ).__qualname__
778
- ),
779
- FutureWarning ,
780
- stacklevel = 3 ,
781
- )
782
-
783
- def __str__ (self ):
784
- self ._emit_str_warning ()
785
- return str (self .value )
786
-
787
764
788
765
class RealObject (ModifiableObject ):
789
766
"""Specific object handle for Real signals and variables."""
@@ -928,21 +905,10 @@ def _set_value(self, value, call_sim):
928
905
.. versionchanged:: 1.4
929
906
Takes :class:`bytes` instead of :class:`str`.
930
907
Users are now expected to choose an encoding when using these objects.
931
- As a convenience, when assigning :class:`str` values, ASCII encoding will be used as a safe default.
932
908
933
909
"""
934
910
value , set_action = self ._check_for_set_action (value )
935
911
936
- if isinstance (value , str ):
937
- warnings .warn (
938
- "Handles on string objects will soon not accept `str` objects. "
939
- "Please use a bytes object by encoding the string as you see fit. "
940
- "`str.encode('ascii')` is typically sufficient." ,
941
- DeprecationWarning ,
942
- stacklevel = 2 ,
943
- )
944
- value = value .encode ("ascii" ) # may throw UnicodeEncodeError
945
-
946
912
if not isinstance (value , bytes ):
947
913
raise TypeError (
948
914
"Unsupported type for string value assignment: {} ({!r})" .format (
@@ -956,20 +922,6 @@ def _set_value(self, value, call_sim):
956
922
def value (self ) -> bytes :
957
923
return self ._handle .get_signal_val_str ()
958
924
959
- def _emit_str_warning (self ):
960
- warnings .warn (
961
- "`str({t})` is deprecated, and in future will return `{t}._path`. "
962
- "To access the `bytes` value of this handle, use `{t}.value`." .format (
963
- t = type (self ).__qualname__
964
- ),
965
- FutureWarning ,
966
- stacklevel = 3 ,
967
- )
968
-
969
- def __str__ (self ):
970
- self ._emit_str_warning ()
971
- return self .value .decode ("ascii" )
972
-
973
925
974
926
_handle2obj = {}
975
927
0 commit comments