Skip to content

Commit 6a38deb

Browse files
committed
remove deprecated members of can.Message
1 parent a688695 commit 6a38deb

1 file changed

Lines changed: 2 additions & 49 deletions

File tree

‎can/message.py‎

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -45,46 +45,13 @@ class Message(object):
4545
"is_fd",
4646
"bitrate_switch",
4747
"error_state_indicator",
48-
"__weakref__", # support weak references to messages
49-
"_dict" # see __getattr__
48+
"__weakref__" # support weak references to messages
5049
)
5150

52-
def __getattr__(self, key):
53-
# TODO keep this for a version, in order to not break old code
54-
# this entire method (as well as the _dict attribute in __slots__ and the __setattr__ method)
55-
# can be removed in 4.0
56-
# this method is only called if the attribute was not found elsewhere, like in __slots__
57-
try:
58-
warnings.warn("Custom attributes of messages are deprecated and will be removed in 4.0", DeprecationWarning)
59-
return self._dict[key]
60-
except KeyError:
61-
raise AttributeError("'message' object has no attribute '{}'".format(key))
62-
63-
def __setattr__(self, key, value):
64-
# see __getattr__
65-
try:
66-
super(Message, self).__setattr__(key, value)
67-
except AttributeError:
68-
warnings.warn("Custom attributes of messages are deprecated and will be removed in 4.0", DeprecationWarning)
69-
self._dict[key] = value
70-
71-
@property
72-
def id_type(self):
73-
# TODO remove in 4.0
74-
warnings.warn("Message.id_type is deprecated and will be removed in 4.0, use is_extended_id instead", DeprecationWarning)
75-
return self.is_extended_id
76-
77-
@id_type.setter
78-
def id_type(self, value):
79-
# TODO remove in 4.0
80-
warnings.warn("Message.id_type is deprecated and will be removed in 4.0, use is_extended_id instead", DeprecationWarning)
81-
self.is_extended_id = value
82-
8351
def __init__(self, timestamp=0.0, arbitration_id=0, is_extended_id=None,
8452
is_remote_frame=False, is_error_frame=False, channel=None,
8553
dlc=None, data=None,
8654
is_fd=False, bitrate_switch=False, error_state_indicator=False,
87-
extended_id=None, # deprecated in 3.x, TODO remove in 4.x
8855
check=False):
8956
"""
9057
To create a message object, simply provide any of the below attributes
@@ -98,24 +65,12 @@ def __init__(self, timestamp=0.0, arbitration_id=0, is_extended_id=None,
9865
9966
:raises ValueError: iff `check` is set to `True` and one or more arguments were invalid
10067
"""
101-
self._dict = dict() # see __getattr__
102-
10368
self.timestamp = timestamp
10469
self.arbitration_id = arbitration_id
105-
106-
if extended_id is not None:
107-
# TODO remove in 4.0
108-
warnings.warn("The extended_id parameter is deprecated and will be removed in 4.0, use is_extended_id instead", DeprecationWarning)
109-
110-
if is_extended_id is not None:
111-
self.is_extended_id = is_extended_id
112-
else:
113-
self.is_extended_id = True if extended_id is None else extended_id
114-
70+
self.is_extended_id = is_extended_id
11571
self.is_remote_frame = is_remote_frame
11672
self.is_error_frame = is_error_frame
11773
self.channel = channel
118-
11974
self.is_fd = is_fd
12075
self.bitrate_switch = bitrate_switch
12176
self.error_state_indicator = error_state_indicator
@@ -239,7 +194,6 @@ def __copy__(self):
239194
bitrate_switch=self.bitrate_switch,
240195
error_state_indicator=self.error_state_indicator
241196
)
242-
new._dict.update(self._dict)
243197
return new
244198

245199
def __deepcopy__(self, memo):
@@ -256,7 +210,6 @@ def __deepcopy__(self, memo):
256210
bitrate_switch=self.bitrate_switch,
257211
error_state_indicator=self.error_state_indicator
258212
)
259-
new._dict.update(self._dict)
260213
return new
261214

262215
def _check(self):

0 commit comments

Comments
 (0)