diff --git a/flask/helpers.py b/flask/helpers.py index 1359bba6..dbbbf2e6 100644 --- a/flask/helpers.py +++ b/flask/helpers.py @@ -24,7 +24,6 @@ from functools import update_wrapper from werkzeug.datastructures import Headers from werkzeug.exceptions import NotFound -import six from flask._compat import string_types, text_type # this was moved in 0.7 @@ -128,7 +127,7 @@ def stream_with_context(generator_or_function): # pushed. This item is discarded. Then when the iteration continues the # real generator is executed. wrapped_g = generator() - six.advance_iterator(wrapped_g) + next(wrapped_g) return wrapped_g diff --git a/flask/json.py b/flask/json.py index 6b95fde0..7777ba5d 100644 --- a/flask/json.py +++ b/flask/json.py @@ -11,13 +11,13 @@ import uuid from datetime import datetime from .globals import current_app, request +from ._compat import text_type from werkzeug.http import http_date # Use the same json implementation as itsdangerous on which we # depend anyways. from itsdangerous import json as _json -import six # figure out if simplejson escapes slashes. This behavior was changed @@ -60,7 +60,7 @@ class JSONEncoder(_json.JSONEncoder): if isinstance(o, uuid.UUID): return str(o) if hasattr(o, '__html__'): - return six.text_type(o.__html__()) + return text_type(o.__html__()) return _json.JSONEncoder.default(self, o) diff --git a/flask/templating.py b/flask/templating.py index 754c6893..63adb092 100644 --- a/flask/templating.py +++ b/flask/templating.py @@ -15,7 +15,7 @@ from jinja2 import BaseLoader, Environment as BaseEnvironment, \ from .globals import _request_ctx_stack, _app_ctx_stack from .signals import template_rendered from .module import blueprint_is_module -import six +from ._compat import itervalues, iteritems def _default_template_ctx_processor(): @@ -80,7 +80,7 @@ class DispatchingJinjaLoader(BaseLoader): except (ValueError, KeyError): pass - for blueprint in six.itervalues(self.app.blueprints): + for blueprint in itervalues(self.app.blueprints): if blueprint_is_module(blueprint): continue loader = blueprint.jinja_loader @@ -93,7 +93,7 @@ class DispatchingJinjaLoader(BaseLoader): if loader is not None: result.update(loader.list_templates()) - for name, blueprint in six.iteritems(self.app.blueprints): + for name, blueprint in iteritems(self.app.blueprints): loader = blueprint.jinja_loader if loader is not None: for template in loader.list_templates(): diff --git a/flask/testsuite/basic.py b/flask/testsuite/basic.py index 85b758b1..485ed5fd 100644 --- a/flask/testsuite/basic.py +++ b/flask/testsuite/basic.py @@ -17,10 +17,10 @@ import unittest from datetime import datetime from threading import Thread from flask.testsuite import FlaskTestCase, emits_module_deprecation_warning +from flask._compat import text_type from werkzeug.exceptions import BadRequest, NotFound from werkzeug.http import parse_date from werkzeug.routing import BuildError -import six class BasicFunctionalityTestCase(FlaskTestCase): @@ -276,7 +276,7 @@ class BasicFunctionalityTestCase(FlaskTestCase): @app.route('/test') def test(): - return six.text_type(flask.session.permanent) + return text_type(flask.session.permanent) client = app.test_client() rv = client.get('/') diff --git a/flask/testsuite/blueprints.py b/flask/testsuite/blueprints.py index 89a8f2d7..97a196d7 100644 --- a/flask/testsuite/blueprints.py +++ b/flask/testsuite/blueprints.py @@ -13,10 +13,10 @@ import flask import unittest import warnings from flask.testsuite import FlaskTestCase, emits_module_deprecation_warning +from flask._compat import text_type from werkzeug.exceptions import NotFound from werkzeug.http import parse_cache_control_header from jinja2 import TemplateNotFound -import six # import moduleapp here because it uses deprecated features and we don't @@ -303,7 +303,7 @@ class BlueprintTestCase(FlaskTestCase): @bp.route('/bar') def bar(bar): - return six.text_type(bar) + return text_type(bar) app = flask.Flask(__name__) app.register_blueprint(bp, url_prefix='/1', url_defaults={'bar': 23}) diff --git a/flask/testsuite/ext.py b/flask/testsuite/ext.py index f6209c67..370a31d8 100644 --- a/flask/testsuite/ext.py +++ b/flask/testsuite/ext.py @@ -11,9 +11,12 @@ import sys import unittest +try: + from imp import reload as reload_module +except ImportError: + reload_module = reload from flask.testsuite import FlaskTestCase from flask._compat import PY2 -from six.moves import reload_module class ExtImportHookTestCase(FlaskTestCase): diff --git a/flask/testsuite/helpers.py b/flask/testsuite/helpers.py index b76d36d1..d0054de1 100644 --- a/flask/testsuite/helpers.py +++ b/flask/testsuite/helpers.py @@ -15,8 +15,7 @@ import unittest from logging import StreamHandler from flask.testsuite import FlaskTestCase, catch_warnings, catch_stderr from werkzeug.http import parse_cache_control_header, parse_options_header -import six -from flask._compat import StringIO +from flask._compat import StringIO, text_type def has_encoding(name): @@ -34,7 +33,7 @@ class JSONTestCase(FlaskTestCase): app = flask.Flask(__name__) @app.route('/json', methods=['POST']) def return_json(): - return six.text_type(flask.request.json) + return text_type(flask.request.json) c = app.test_client() rv = c.post('/json', data='malformed', content_type='application/json') self.assert_equal(rv.status_code, 400) @@ -43,7 +42,7 @@ class JSONTestCase(FlaskTestCase): app = flask.Flask(__name__) @app.route('/json', methods=['POST']) def return_json(): - return six.text_type(flask.request.json) + return text_type(flask.request.json) c = app.test_client() rv = c.post('/json', data='malformed', content_type='application/json') self.assert_equal(rv.status_code, 400) @@ -95,7 +94,7 @@ class JSONTestCase(FlaskTestCase): app = flask.Flask(__name__) @app.route('/add', methods=['POST']) def add(): - return six.text_type(flask.request.json['a'] + flask.request.json['b']) + return text_type(flask.request.json['a'] + flask.request.json['b']) c = app.test_client() rv = c.post('/add', data=flask.json.dumps({'a': 1, 'b': 2}), content_type='application/json') @@ -506,7 +505,7 @@ class StreamingTestCase(FlaskTestCase): def close(self): called.append(42) def next(self): - return six.advance_iterator(self._gen) + return next(self._gen) @app.route('/') def index(): def generate(): diff --git a/flask/testsuite/testing.py b/flask/testsuite/testing.py index e7206d21..cd96b497 100644 --- a/flask/testsuite/testing.py +++ b/flask/testsuite/testing.py @@ -12,7 +12,7 @@ import flask import unittest from flask.testsuite import FlaskTestCase -import six +from flask._compat import text_type class TestToolsTestCase(FlaskTestCase): @@ -84,7 +84,7 @@ class TestToolsTestCase(FlaskTestCase): @app.route('/') def index(): - return six.text_type(flask.session['foo']) + return text_type(flask.session['foo']) with app.test_client() as c: with c.session_transaction() as sess: diff --git a/setup.py b/setup.py index 1d3e36ad..ddc83251 100644 --- a/setup.py +++ b/setup.py @@ -91,7 +91,6 @@ setup( zip_safe=False, platforms='any', install_requires=[ - 'six>=1.3.0', 'Werkzeug>=0.7', 'Jinja2>=2.4', 'itsdangerous>=0.17'