From 42c2ae77a7310c9c41326c2a50fe7a9f5ee406f3 Mon Sep 17 00:00:00 2001 From: Ayala Shachar Date: Wed, 16 Oct 2019 16:44:04 +0300 Subject: [PATCH 1/2] Remove usage of deprecated collections API --- logbook/compat.py | 4 ++-- logbook/handlers.py | 8 ++++---- logbook/helpers.py | 2 ++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/logbook/compat.py b/logbook/compat.py index b65ac006..602a11af 100644 --- a/logbook/compat.py +++ b/logbook/compat.py @@ -16,7 +16,7 @@ from datetime import date, datetime import logbook -from logbook.helpers import u, string_types, iteritems +from logbook.helpers import u, string_types, iteritems, collections_abc _epoch_ord = date(1970, 1, 1).toordinal() @@ -133,7 +133,7 @@ def convert_record(self, old_record): kwargs = None # Logging allows passing a mapping object, in which case args will be a mapping. - if isinstance(args, collections.Mapping): + if isinstance(args, collections_abc.Mapping): kwargs = args args = None record = LoggingCompatRecord(old_record.name, diff --git a/logbook/handlers.py b/logbook/handlers.py index 58efbce0..9c28a83c 100644 --- a/logbook/handlers.py +++ b/logbook/handlers.py @@ -32,7 +32,7 @@ _missing, lookup_level, Flags, ContextObject, ContextStackManager, _datetime_factory) from logbook.helpers import ( - rename, b, _is_text_stream, is_unicode, PY2, zip, xrange, string_types, + rename, b, _is_text_stream, is_unicode, PY2, zip, xrange, string_types, collections_abc, integer_types, reraise, u, with_metaclass) from logbook.concurrency import new_fine_grained_lock @@ -1355,10 +1355,10 @@ def get_connection(self): # - tuple to be unpacked to variables keyfile and certfile. # - secure=() equivalent to secure=True for backwards compatibility. # - secure=False equivalent to secure=None to disable. - if isinstance(self.secure, collections.Mapping): + if isinstance(self.secure, collections_abc.Mapping): keyfile = self.secure.get('keyfile', None) certfile = self.secure.get('certfile', None) - elif isinstance(self.secure, collections.Iterable): + elif isinstance(self.secure, collections_abc.Iterable): # Allow empty tuple for backwards compatibility if len(self.secure) == 0: keyfile = certfile = None @@ -1381,7 +1381,7 @@ def get_connection(self): con.ehlo() # Allow credentials to be a tuple or dict. - if isinstance(self.credentials, collections.Mapping): + if isinstance(self.credentials, collections_abc.Mapping): credentials_args = () credentials_kwargs = self.credentials else: diff --git a/logbook/helpers.py b/logbook/helpers.py index d53bcf03..4ea693f7 100644 --- a/logbook/helpers.py +++ b/logbook/helpers.py @@ -20,8 +20,10 @@ if PY2: import __builtin__ as _builtins + import collections as collections_abc else: import builtins as _builtins + import collections.abc as collections_abc try: import json From 768c18f1b0bb8a974ffc4323dc302b03c96cbf86 Mon Sep 17 00:00:00 2001 From: Rotem Yaari Date: Wed, 16 Oct 2019 20:46:42 +0300 Subject: [PATCH 2/2] Bump version --- logbook/__version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logbook/__version__.py b/logbook/__version__.py index 5197c5f5..a06ff4e0 100644 --- a/logbook/__version__.py +++ b/logbook/__version__.py @@ -1 +1 @@ -__version__ = "1.5.2" +__version__ = "1.5.3"