From c93f4e4caa5bdc2b7d3695ab51cee65914b927ab Mon Sep 17 00:00:00 2001 From: Jean-Manuel CABA Date: Mon, 29 Apr 2019 18:22:42 +0200 Subject: [PATCH] Fix DeprecationWarning on python 3.7 for python 3.8 - got this with version 3.7.3 of python so fixed it - add python 3.7 to travis - ensure the retro compatibility with pypy and python 2.7 - bump version to 3.0.8 --- .travis.yml | 9 +++++++++ CHANGELOG.md | 3 +++ flask_cors/core.py | 13 +++++++++---- flask_cors/version.py | 2 +- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index c46cf41..5884719 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,15 @@ python: - '3.6' - pypy +# from https://github.com/travis-ci/travis-ci/issues/9815 +# https://github.com/travis-ci/travis-ci/issues/9069#issuecomment-425720905 +# Enable 3.7 without globally enabling sudo and dist: xenial for other build jobs +matrix: + include: + - python: 3.7 + dist: xenial + sudo: true + env: - FLASK=0.10.1 - FLASK=0.10 diff --git a/CHANGELOG.md b/CHANGELOG.md index 2898b03..22de467 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Change Log +## 3.0.8 +DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working + ## 3.0.7 Updated logging.warn to logging.warning (#234) Thanks Vaibhav diff --git a/flask_cors/core.py b/flask_cors/core.py index 439879a..f29aeb4 100644 --- a/flask_cors/core.py +++ b/flask_cors/core.py @@ -9,7 +9,12 @@ """ import re import logging -import collections +try: + # on python 3 + from collections.abc import Iterable +except ImportError: + # on python 2.7 and pypy + from collections import Iterable from datetime import timedelta from six import string_types from flask import request, current_app @@ -78,7 +83,7 @@ def pattern_length(pair): elif isinstance(resources, string_types): return [(re_fix(resources), {})] - elif isinstance(resources, collections.Iterable): + elif isinstance(resources, Iterable): return [(re_fix(r), {}) for r in resources] # Type of compiled regex is not part of the public API. Test for this @@ -319,7 +324,7 @@ def flexible_str(obj): if obj is None: return None elif(not isinstance(obj, string_types) - and isinstance(obj, collections.Iterable)): + and isinstance(obj, Iterable)): return ', '.join(str(item) for item in sorted(obj)) else: return str(obj) @@ -337,7 +342,7 @@ def ensure_iterable(inst): """ if isinstance(inst, string_types): return [inst] - elif not isinstance(inst, collections.Iterable): + elif not isinstance(inst, Iterable): return [inst] else: return inst diff --git a/flask_cors/version.py b/flask_cors/version.py index 8595381..8a7ae5d 100644 --- a/flask_cors/version.py +++ b/flask_cors/version.py @@ -1 +1 @@ -__version__ = '3.0.7' +__version__ = '3.0.8'