Skip to content

Commit c93f4e4

Browse files
Jean-Manuel CABAcorydolphin
authored andcommitted
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
1 parent 13fbb1e commit c93f4e4

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ python:
99
- '3.6'
1010
- pypy
1111

12+
# from https://github.com/travis-ci/travis-ci/issues/9815
13+
# https://github.com/travis-ci/travis-ci/issues/9069#issuecomment-425720905
14+
# Enable 3.7 without globally enabling sudo and dist: xenial for other build jobs
15+
matrix:
16+
include:
17+
- python: 3.7
18+
dist: xenial
19+
sudo: true
20+
1221
env:
1322
- FLASK=0.10.1
1423
- FLASK=0.10

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Change Log
22

3+
## 3.0.8
4+
DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
5+
36
## 3.0.7
47
Updated logging.warn to logging.warning (#234) Thanks Vaibhav
58

flask_cors/core.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
"""
1010
import re
1111
import logging
12-
import collections
12+
try:
13+
# on python 3
14+
from collections.abc import Iterable
15+
except ImportError:
16+
# on python 2.7 and pypy
17+
from collections import Iterable
1318
from datetime import timedelta
1419
from six import string_types
1520
from flask import request, current_app
@@ -78,7 +83,7 @@ def pattern_length(pair):
7883
elif isinstance(resources, string_types):
7984
return [(re_fix(resources), {})]
8085

81-
elif isinstance(resources, collections.Iterable):
86+
elif isinstance(resources, Iterable):
8287
return [(re_fix(r), {}) for r in resources]
8388

8489
# Type of compiled regex is not part of the public API. Test for this
@@ -319,7 +324,7 @@ def flexible_str(obj):
319324
if obj is None:
320325
return None
321326
elif(not isinstance(obj, string_types)
322-
and isinstance(obj, collections.Iterable)):
327+
and isinstance(obj, Iterable)):
323328
return ', '.join(str(item) for item in sorted(obj))
324329
else:
325330
return str(obj)
@@ -337,7 +342,7 @@ def ensure_iterable(inst):
337342
"""
338343
if isinstance(inst, string_types):
339344
return [inst]
340-
elif not isinstance(inst, collections.Iterable):
345+
elif not isinstance(inst, Iterable):
341346
return [inst]
342347
else:
343348
return inst

flask_cors/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '3.0.7'
1+
__version__ = '3.0.8'

0 commit comments

Comments
 (0)