From 36a63b188d53777370921804769e32951f31a882 Mon Sep 17 00:00:00 2001 From: Felix Divo Date: Sat, 18 May 2019 18:02:11 +0200 Subject: [PATCH 01/10] remove func:send_periodic() --- can/broadcastmanager.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/can/broadcastmanager.py b/can/broadcastmanager.py index 79d586744..85ad03776 100644 --- a/can/broadcastmanager.py +++ b/can/broadcastmanager.py @@ -142,17 +142,3 @@ def _run(self): # Compensate for the time it takes to send the message delay = self.period - (time.time() - started) time.sleep(max(0.0, delay)) - - -def send_periodic(bus, message, period, *args, **kwargs): - """ - Send a :class:`~can.Message` every `period` seconds on the given bus. - - :param can.BusABC bus: A CAN bus which supports sending. - :param can.Message message: Message to send periodically. - :param float period: The minimum time between sending messages. - :return: A started task instance - """ - warnings.warn("The function `can.send_periodic` is deprecated and will " + - "be removed in an upcoming version. Please use `can.Bus.send_periodic` instead.", DeprecationWarning) - return bus.send_periodic(message, period, *args, **kwargs) From f7813f55a7654b567b14e6f9ae63b6bb4a553e4b Mon Sep 17 00:00:00 2001 From: Felix Divo Date: Sat, 18 May 2019 18:04:58 +0200 Subject: [PATCH 02/10] remove old CAN module --- can/CAN.py | 29 ----------------------------- doc/development.rst | 2 -- setup.cfg | 3 --- 3 files changed, 34 deletions(-) delete mode 100644 can/CAN.py diff --git a/can/CAN.py b/can/CAN.py deleted file mode 100644 index 0ed96dfb1..000000000 --- a/can/CAN.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding: utf-8 - -""" -This module was once the core of python-can, containing -implementations of all the major classes in the library, now -however all functionality has been refactored out. This API -is left intact for version 2.x to aide with migration. - -WARNING: -This module is deprecated an will get removed in version 3.x. -Please use ``import can`` instead. -""" - -from __future__ import absolute_import - -from can.message import Message -from can.listener import Listener, BufferedReader, RedirectReader -from can.util import set_logging_level -from can.io import * - -import warnings - -# See #267. -# Version 2.0 - 2.1: Log a Debug message -# Version 2.2: Log a Warning -# Version 3.x: DeprecationWarning -# Version 4.0: Remove the module -warnings.warn('Loading python-can via the old "CAN" API is deprecated since v3.0 an will get removed in v4.0 ' - 'Please use `import can` instead.', DeprecationWarning) diff --git a/doc/development.rst b/doc/development.rst index 602e4e347..8bad5c58e 100644 --- a/doc/development.rst +++ b/doc/development.rst @@ -69,8 +69,6 @@ The modules in ``python-can`` are: |:doc:`broadcastmanager ` | Contains interface independent broadcast manager | | | code. | +---------------------------------+------------------------------------------------------+ -|:doc:`CAN ` | Legacy API. Deprecated. | -+---------------------------------+------------------------------------------------------+ Creating a new Release diff --git a/setup.cfg b/setup.cfg index 49177e68e..e9a7cb985 100644 --- a/setup.cfg +++ b/setup.cfg @@ -15,9 +15,6 @@ addopts = -v --timeout=300 --cov=can --cov-config=setup.cfg branch = False # already specified by call to pytest using --cov=can #source = can -omit = - # legacy code - can/CAN.py [coverage:report] # two digits after decimal point From 80f2fdd88b9ad896456a8165cb095a66c2ac2fc7 Mon Sep 17 00:00:00 2001 From: Felix Divo Date: Sat, 18 May 2019 18:06:14 +0200 Subject: [PATCH 03/10] remove now obsolete docs for send_periodic() --- doc/bcm.rst | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/doc/bcm.rst b/doc/bcm.rst index 96e73d52d..549b06edd 100644 --- a/doc/bcm.rst +++ b/doc/bcm.rst @@ -42,14 +42,3 @@ which inherits from :class:`~can.broadcastmanager.CyclicTask`. .. autoclass:: can.RestartableCyclicTaskABC :members: - - -Functional API --------------- - -.. warning:: - The functional API in :func:`can.broadcastmanager.send_periodic` is now deprecated - and will be removed in version 4.0. - Use the object oriented API via :meth:`can.BusABC.send_periodic` instead. - -.. autofunction:: can.broadcastmanager.send_periodic From da61c16d45cbeac37b745b3ab39e478fe76a55dd Mon Sep 17 00:00:00 2001 From: Felix Divo Date: Sat, 18 May 2019 18:07:46 +0200 Subject: [PATCH 04/10] remove deprecated access to socketcan member --- can/interface.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/can/interface.py b/can/interface.py index 6c830d0c4..cbc907f86 100644 --- a/can/interface.py +++ b/can/interface.py @@ -18,11 +18,6 @@ from .util import load_config from .interfaces import BACKENDS -if 'linux' in sys.platform: - # Deprecated and undocumented access to SocketCAN cyclic tasks - # Will be removed in version 4.0 - from can.interfaces.socketcan import CyclicSendTask, MultiRateCyclicSendTask - # Required by "detect_available_configs" for argument interpretation if sys.version_info.major > 2: basestring = str From 3851335a049e49d4bd1b7fbd95100f31db7b0c11 Mon Sep 17 00:00:00 2001 From: Felix Divo Date: Sat, 18 May 2019 18:12:20 +0200 Subject: [PATCH 05/10] remove entry point python_can.interface --- can/interfaces/__init__.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/can/interfaces/__init__.py b/can/interfaces/__init__.py index ec79e51d6..c4c7f52f7 100644 --- a/can/interfaces/__init__.py +++ b/can/interfaces/__init__.py @@ -31,10 +31,4 @@ for interface in iter_entry_points('can.interface') }) -# Old entry point name. May be removed >3.0. -for interface in iter_entry_points('python_can.interface'): - BACKENDS[interface.name] = (interface.module_name, interface.attrs[0]) - warnings.warn('{} is using the deprecated python_can.interface entry point. '.format(interface.name) + - 'Please change to can.interface instead.', DeprecationWarning) - VALID_INTERFACES = frozenset(list(BACKENDS.keys()) + ['socketcan_native', 'socketcan_ctypes']) From b7a9e7519e917c9b6c91d964019916b1d43ef720 Mon Sep 17 00:00:00 2001 From: Felix Divo Date: Sat, 18 May 2019 18:14:30 +0200 Subject: [PATCH 06/10] remove special case for socketcan_{native,ctypes} --- can/interfaces/socketcan/socketcan.py | 4 +--- can/util.py | 7 ------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/can/interfaces/socketcan/socketcan.py b/can/interfaces/socketcan/socketcan.py index 633c87b22..6aebc7221 100644 --- a/can/interfaces/socketcan/socketcan.py +++ b/can/interfaces/socketcan/socketcan.py @@ -1,6 +1,6 @@ # coding: utf-8 -import logging +import logging import ctypes import ctypes.util import os @@ -14,8 +14,6 @@ log_tx = log.getChild("tx") log_rx = log.getChild("rx") -log.debug("Loading socketcan native backend") - try: import fcntl except ImportError: diff --git a/can/util.py b/can/util.py index af421651f..be6793152 100644 --- a/can/util.py +++ b/can/util.py @@ -186,13 +186,6 @@ def load_config(path=None, config=None, context=None): if key not in config: config[key] = None - # Handle deprecated socketcan types - if config['interface'] in ('socketcan_native', 'socketcan_ctypes'): - # DeprecationWarning in 3.x releases - # TODO: Remove completely in 4.0 - warnings.warn('{} is deprecated, use socketcan instead'.format(config['interface']), DeprecationWarning) - config['interface'] = 'socketcan' - if config['interface'] not in VALID_INTERFACES: raise NotImplementedError('Invalid CAN Bus Type - {}'.format(config['interface'])) From 780ac38dce0e6edb03c816217d74c5de7bdddd9f Mon Sep 17 00:00:00 2001 From: Felix Divo Date: Sat, 18 May 2019 18:18:10 +0200 Subject: [PATCH 07/10] remove deprecated members of can.Message --- can/message.py | 51 ++------------------------------------------------ 1 file changed, 2 insertions(+), 49 deletions(-) diff --git a/can/message.py b/can/message.py index f85218fc0..1c1a3fd9d 100644 --- a/can/message.py +++ b/can/message.py @@ -45,46 +45,13 @@ class Message(object): "is_fd", "bitrate_switch", "error_state_indicator", - "__weakref__", # support weak references to messages - "_dict" # see __getattr__ + "__weakref__" # support weak references to messages ) - def __getattr__(self, key): - # TODO keep this for a version, in order to not break old code - # this entire method (as well as the _dict attribute in __slots__ and the __setattr__ method) - # can be removed in 4.0 - # this method is only called if the attribute was not found elsewhere, like in __slots__ - try: - warnings.warn("Custom attributes of messages are deprecated and will be removed in 4.0", DeprecationWarning) - return self._dict[key] - except KeyError: - raise AttributeError("'message' object has no attribute '{}'".format(key)) - - def __setattr__(self, key, value): - # see __getattr__ - try: - super(Message, self).__setattr__(key, value) - except AttributeError: - warnings.warn("Custom attributes of messages are deprecated and will be removed in 4.0", DeprecationWarning) - self._dict[key] = value - - @property - def id_type(self): - # TODO remove in 4.0 - warnings.warn("Message.id_type is deprecated and will be removed in 4.0, use is_extended_id instead", DeprecationWarning) - return self.is_extended_id - - @id_type.setter - def id_type(self, value): - # TODO remove in 4.0 - warnings.warn("Message.id_type is deprecated and will be removed in 4.0, use is_extended_id instead", DeprecationWarning) - self.is_extended_id = value - def __init__(self, timestamp=0.0, arbitration_id=0, is_extended_id=None, is_remote_frame=False, is_error_frame=False, channel=None, dlc=None, data=None, is_fd=False, bitrate_switch=False, error_state_indicator=False, - extended_id=None, # deprecated in 3.x, TODO remove in 4.x check=False): """ 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, :raises ValueError: iff `check` is set to `True` and one or more arguments were invalid """ - self._dict = dict() # see __getattr__ - self.timestamp = timestamp self.arbitration_id = arbitration_id - - if extended_id is not None: - # TODO remove in 4.0 - warnings.warn("The extended_id parameter is deprecated and will be removed in 4.0, use is_extended_id instead", DeprecationWarning) - - if is_extended_id is not None: - self.is_extended_id = is_extended_id - else: - self.is_extended_id = True if extended_id is None else extended_id - + self.is_extended_id = is_extended_id self.is_remote_frame = is_remote_frame self.is_error_frame = is_error_frame self.channel = channel - self.is_fd = is_fd self.bitrate_switch = bitrate_switch self.error_state_indicator = error_state_indicator @@ -239,7 +194,6 @@ def __copy__(self): bitrate_switch=self.bitrate_switch, error_state_indicator=self.error_state_indicator ) - new._dict.update(self._dict) return new def __deepcopy__(self, memo): @@ -256,7 +210,6 @@ def __deepcopy__(self, memo): bitrate_switch=self.bitrate_switch, error_state_indicator=self.error_state_indicator ) - new._dict.update(self._dict) return new def _check(self): From bc1e5cff17f2fd45b962bdf7134e8d58a4172587 Mon Sep 17 00:00:00 2001 From: Felix Divo Date: Sat, 18 May 2019 18:33:33 +0200 Subject: [PATCH 08/10] remove import of removed function --- can/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/can/__init__.py b/can/__init__.py index a612363ae..0bc8cfe62 100644 --- a/can/__init__.py +++ b/can/__init__.py @@ -45,7 +45,7 @@ class CanError(IOError): from . import interface from .interface import Bus, detect_available_configs -from .broadcastmanager import send_periodic, \ +from .broadcastmanager import \ CyclicSendTaskABC, \ LimitedDurationCyclicSendTaskABC, \ ModifiableCyclicTaskABC, \ From 42f8e4e39dae06d55b4280ff5d7f6e25d2a8c63a Mon Sep 17 00:00:00 2001 From: Felix Divo Date: Sat, 18 May 2019 19:04:22 +0200 Subject: [PATCH 09/10] fix small problem in __repr__() --- can/message.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/can/message.py b/can/message.py index 1c1a3fd9d..e0435867e 100644 --- a/can/message.py +++ b/can/message.py @@ -149,7 +149,7 @@ def __nonzero__(self): def __repr__(self): args = ["timestamp={}".format(self.timestamp), "arbitration_id={:#x}".format(self.arbitration_id), - "extended_id={}".format(self.is_extended_id)] + "is_extended_id={}".format(self.is_extended_id)] if self.is_remote_frame: args.append("is_remote_frame={}".format(self.is_remote_frame)) From 0bbee78316fa46e53706a00ac98a717c8648ed00 Mon Sep 17 00:00:00 2001 From: Felix Divo Date: Sat, 18 May 2019 19:05:09 +0200 Subject: [PATCH 10/10] make is_extended_id True by default again --- can/message.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/can/message.py b/can/message.py index e0435867e..3826cede2 100644 --- a/can/message.py +++ b/can/message.py @@ -48,7 +48,7 @@ class Message(object): "__weakref__" # support weak references to messages ) - def __init__(self, timestamp=0.0, arbitration_id=0, is_extended_id=None, + def __init__(self, timestamp=0.0, arbitration_id=0, is_extended_id=True, is_remote_frame=False, is_error_frame=False, channel=None, dlc=None, data=None, is_fd=False, bitrate_switch=False, error_state_indicator=False,