Skip to content

Commit

Permalink
Fix DeprecationWarning on python 3.7 for python 3.8
Browse files Browse the repository at this point in the history
 - 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
  • Loading branch information
Jean-Manuel CABA authored and corydolphin committed Jun 8, 2019
1 parent 13fbb1e commit c93f4e4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
13 changes: 9 additions & 4 deletions flask_cors/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion flask_cors/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '3.0.7'
__version__ = '3.0.8'

0 comments on commit c93f4e4

Please sign in to comment.