From 01b55091398d8b9a6d3624993f715014a4a15918 Mon Sep 17 00:00:00 2001 From: Michael Wiegand Date: Mon, 25 Feb 2019 09:18:53 +0100 Subject: [PATCH 1/2] Access `Mapping` via `collections.abc` The Collections Abstract Base Classes were moved from the `collections` module to the `collections.abc` module in Python 3.3. Using them via the `collections` module was deprecated in Python 3.7 and will stop working in Python 3.8, so the `isinstance` calls in `python-gvm` should be adjusted accordingly. For reference, this the warning shown when running the code in Python 3.7: ``` DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working ``` --- gvm/protocols/gmpv7.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gvm/protocols/gmpv7.py b/gvm/protocols/gmpv7.py index 7e338756d..35f607881 100644 --- a/gvm/protocols/gmpv7.py +++ b/gvm/protocols/gmpv7.py @@ -1779,7 +1779,7 @@ def create_task(self, name, config_id, target_id, scanner_id, *, cmd.add_element('observers', _to_comma_list(observers)) if preferences is not None: - if not isinstance(preferences, collections.Mapping): + if not isinstance(preferences, collections.abc.Mapping): raise InvalidArgument( 'preferences argument must be a dict' ) @@ -5021,7 +5021,7 @@ def modify_task(self, task_id, *, name=None, config_id=None, target_id=None, cmd.add_element('observers', _to_comma_list(observers)) if preferences is not None: - if not isinstance(preferences, collections.Mapping): + if not isinstance(preferences, collections.abc.Mapping): raise InvalidArgument( 'preferences argument must be a dict' ) From 73e5d62d6c7ed22c8334c607c7a39fffa7847de6 Mon Sep 17 00:00:00 2001 From: Michael Wiegand Date: Mon, 25 Feb 2019 09:32:28 +0100 Subject: [PATCH 2/2] Add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f01f26ec..897a679fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ `get_preference` * Fixed wrong order of key and value for condition_data, event_data and method_data dict parameters of `modify_alert` method. +* Address DeprecationWarning regarding `collections` module # python-gvm 1.0.0.beta2 (04.12.2018)