@@ -43,14 +43,14 @@ class Message(object):
4343 "is_fd" ,
4444 "bitrate_switch" ,
4545 "error_state_indicator" ,
46- "__weakref__" , # support weak references to messages
47- "_dict" # see __getattr__
46+ "__weakref__" , # support weak references to messages
47+ "_dict" # see __getattr__
4848 )
4949
5050 def __getattr__ (self , key ):
5151 # TODO keep this for a version, in order to not break old code
5252 # this entire method (as well as the _dict attribute in __slots__ and the __setattr__ method)
53- # can be removed in 3 .0
53+ # can be removed in 4 .0
5454 # this method is only called if the attribute was not found elsewhere, like in __slots__
5555 try :
5656 warnings .warn ("Custom attributes of messages are deprecated and will be removed in the next major version" , DeprecationWarning )
@@ -68,20 +68,21 @@ def __setattr__(self, key, value):
6868
6969 @property
7070 def id_type (self ):
71- # TODO remove in 3 .0
71+ # TODO remove in 4 .0
7272 warnings .warn ("Message.id_type is deprecated, use is_extended_id" , DeprecationWarning )
7373 return self .is_extended_id
7474
7575 @id_type .setter
7676 def id_type (self , value ):
77- # TODO remove in 3 .0
77+ # TODO remove in 4 .0
7878 warnings .warn ("Message.id_type is deprecated, use is_extended_id" , DeprecationWarning )
7979 self .is_extended_id = value
8080
81- def __init__ (self , timestamp = 0.0 , arbitration_id = 0 , extended_id = True ,
81+ def __init__ (self , timestamp = 0.0 , arbitration_id = 0 , is_extended_id = None ,
8282 is_remote_frame = False , is_error_frame = False , channel = None ,
8383 dlc = None , data = None ,
8484 is_fd = False , bitrate_switch = False , error_state_indicator = False ,
85+ extended_id = True ,
8586 check = False ):
8687 """
8788 To create a message object, simply provide any of the below attributes
@@ -99,7 +100,13 @@ def __init__(self, timestamp=0.0, arbitration_id=0, extended_id=True,
99100
100101 self .timestamp = timestamp
101102 self .arbitration_id = arbitration_id
102- self .is_extended_id = extended_id
103+ if is_extended_id is not None :
104+ self .is_extended_id = is_extended_id
105+ else :
106+ if not extended_id :
107+ # Passed extended_id=False (default argument is True) so we warn to update
108+ warnings .warn ("extended_id is a deprecated parameter, use is_extended_id" , DeprecationWarning )
109+ self .is_extended_id = extended_id
103110
104111 self .is_remote_frame = is_remote_frame
105112 self .is_error_frame = is_error_frame
@@ -152,7 +159,7 @@ def __str__(self):
152159 if self .data is not None :
153160 for index in range (0 , min (self .dlc , len (self .data ))):
154161 data_strings .append ("{0:02x}" .format (self .data [index ]))
155- if data_strings : # if not empty
162+ if data_strings : # if not empty
156163 field_strings .append (" " .join (data_strings ).ljust (24 , " " ))
157164 else :
158165 field_strings .append (" " * 24 )
0 commit comments