From d4cf6781fbc4f91eca2f5c897582c2b8b6ff5da9 Mon Sep 17 00:00:00 2001 From: Karthikeyan Singaravelan Date: Wed, 25 Dec 2019 18:00:37 +0530 Subject: [PATCH 1/2] Fix DeprecationWarning regarding collections.abc and isAlive. --- IPy.py | 13 ++++++++----- test/test_IPy.py | 6 +++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/IPy.py b/IPy.py index 3ccf989..6c48c94 100644 --- a/IPy.py +++ b/IPy.py @@ -9,9 +9,12 @@ __version__ = '1.00' import bisect -import collections import sys import types +try: + import collections.abc as collections_abc +except ImportError: + import collections as collections_abc # Definition of the Ranges for IPv4 IPs # this should include www.iana.org/assignments/ipv4-address-space @@ -1022,10 +1025,10 @@ def v46map(self): raise ValueError("%s cannot be converted to an IPv4 address." % repr(self)) -class IPSet(collections.MutableSet): +class IPSet(collections_abc.MutableSet): def __init__(self, iterable=[]): # Make sure it's iterable, otherwise wrap - if not isinstance(iterable, collections.Iterable): + if not isinstance(iterable, collections_abc.Iterable): raise TypeError("'%s' object is not iterable" % type(iterable).__name__) # Make sure we only accept IP objects @@ -1099,7 +1102,7 @@ def len(self): def add(self, value): # Make sure it's iterable, otherwise wrap - if not isinstance(value, collections.Iterable): + if not isinstance(value, collections_abc.Iterable): value = [value] # Check type @@ -1113,7 +1116,7 @@ def add(self, value): def discard(self, value): # Make sure it's iterable, otherwise wrap - if not isinstance(value, collections.Iterable): + if not isinstance(value, collections_abc.Iterable): value = [value] # This is much faster than iterating over the addresses diff --git a/test/test_IPy.py b/test/test_IPy.py index dc4b61f..8dbbd97 100644 --- a/test/test_IPy.py +++ b/test/test_IPy.py @@ -788,7 +788,11 @@ def run(self): it.setDaemon(True) it.start() it.join(timeout_duration) - if it.isAlive(): + if hasattr(it, 'is_alive'): + is_alive = it.is_alive() + else: + is_alive = it.isAlive() + if is_alive: return default else: return it.result From b02fb5d9a90a238605cee2cb363e015e9dd164af Mon Sep 17 00:00:00 2001 From: Karthikeyan Singaravelan Date: Tue, 21 Jan 2020 22:42:37 +0530 Subject: [PATCH 2/2] Use pytest instead of nose for Python 3.9 compatibility. Co-authored-by: Hugo van Kemenade --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4c96f64..74945a7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,4 +9,5 @@ python: - "3.7-dev" - "3.8-dev" - "nightly" -script: nosetests -e fuzz +install: pip install pytest +script: pytest -k "not fuzz"