Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support for old python versions #330

Merged
merged 2 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 3 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,14 @@ arch:
- ppc64le
- arm64
python:
- '2.7'
- '3.4'
- '3.5'
- '3.6'
- '3.7'
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- pypy

matrix:
exclude:
- python: 3.4
- arch: ppc64le
python: pypy
- arch: arm64
Expand All @@ -32,9 +27,10 @@ env:
- DEPEENDENCIES="flask==0.10 werkzeug==0.16.1"
- DEPEENDENCIES="flask==1.0"
- DEPEENDENCIES="flask==1.1"
- DEPEENDENCIES="flask==2.3.2"

install:
- pip install -U setuptools pep8 six coverage docutils pygments packaging $DEPEENDENCIES
- pip install -U setuptools pep8 coverage docutils pygments packaging $DEPEENDENCIES

script:
- coverage erase
Expand Down
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ Tests
A simple set of tests is included in ``test/``.
To run, install nose, and simply invoke ``nosetests`` or ``python setup.py test`` to exercise the tests.

If nosetests does not work for you, due to it no longer working with newer python versions.
You can use pytest to run the tests instead.

Contributing
------------

Expand Down
2 changes: 1 addition & 1 deletion flask_cors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
rootlogger.addHandler(NullHandler())

if rootlogger.level == logging.NOTSET:
rootlogger.setLevel(logging.WARN)
rootlogger.setLevel(logging.WARN)
17 changes: 5 additions & 12 deletions flask_cors/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,8 @@
"""
import re
import logging
try:
# on python 3
from collections.abc import Iterable
except ImportError:
# on python 2.7 and pypy
from collections import Iterable
from collections.abc import Iterable
from datetime import timedelta
from six import string_types
from flask import request, current_app
from werkzeug.datastructures import Headers, MultiDict

Expand Down Expand Up @@ -82,7 +76,7 @@ def pattern_length(pair):
key=pattern_length,
reverse=True)

elif isinstance(resources, string_types):
elif isinstance(resources, str):
return [(re_fix(resources), {})]

elif isinstance(resources, Iterable):
Expand Down Expand Up @@ -329,9 +323,8 @@ def flexible_str(obj):
"""
if obj is None:
return None
elif(not isinstance(obj, string_types)
and isinstance(obj, Iterable)):
return ', '.join(str(item) for item in sorted(obj))
elif not isinstance(obj, str) and isinstance(obj, Iterable):
return ", ".join(str(item) for item in sorted(obj))
else:
return str(obj)

Expand All @@ -346,7 +339,7 @@ def ensure_iterable(inst):
"""
Wraps scalars or string types as a list, or returns the iterable instance.
"""
if isinstance(inst, string_types):
if isinstance(inst, str):
return [inst]
elif not isinstance(inst, Iterable):
return [inst]
Expand Down
4 changes: 3 additions & 1 deletion flask_cors/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
:copyright: (c) 2016 by Cory Dolphin.
:license: MIT, see LICENSE for more details.
"""
import logging
from functools import update_wrapper
from flask import make_response, request, current_app
from .core import *

from .core import get_cors_options, set_cors_headers, FLASK_CORS_EVALUATED

LOG = logging.getLogger(__name__)

Expand Down
17 changes: 12 additions & 5 deletions flask_cors/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@
:copyright: (c) 2016 by Cory Dolphin.
:license: MIT, see LICENSE for more details.
"""
import logging
from urllib.parse import unquote_plus
from flask import request
from .core import *
try:
from urllib.parse import unquote_plus
except ImportError:
from urllib import unquote_plus

from .core import (
parse_resources,
get_cors_options,
get_regexp_pattern,
ACL_ORIGIN,
try_match,
set_cors_headers
)


LOG = logging.getLogger(__name__)

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.1.01'
__version__ = '4.0.0'
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
Flask>=0.9
Six
8 changes: 1 addition & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,10 @@
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
Expand Down