Removed a bunch of code from _compat
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Armin Ronacher · committed by Armin Ronacher · parent c629f69 · Browse files · 3 files·+8 added−43 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+8 added−43 removed
- other:+8 added−43 removed
Provenance
- Commit
0190b77- Tree
7cb51a6- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent
c629f69
3 files changed+8 added−43 removed
modified:flask/testsuite/helpers.py+2 added-2 removed
13 unmodified lines14 import unittest15 from logging import StreamHandler16 from flask.testsuite import FlaskTestCase, catch_warnings, catch_stderr17 from werkzeug.http import parse_cache_control_header, parse_options_header18-from flask._compat import StringIO, text_type, implements_iterator18+from flask._compat import StringIO, text_type19 20 21 def has_encoding(name):22 try:522 unmodified lines545 def test_streaming_with_context_and_custom_close(self):546 app = flask.Flask(__name__)547 app.testing = True548 called = []549- @implements_iterator549 class Wrapper(object):550 def __init__(self, gen):551 self._gen = gen552 def __iter__(self):1 unmodified line554 def close(self):555 called.append(42)556 def __next__(self):557 return next(self._gen)558+ next = __next__559 @app.route('/')560 def index():561 def generate():562 yield 'Hello '19 unmodified linesmodified:flask/_compat.py+2 added-40 removed
11 unmodified lines12 """13 import sys14 15 PY2 = sys.version_info[0] == 216-PYPY = hasattr(sys, 'pypy_translation_info')16 _identity = lambda x: x17 18 19 if not PY2:21- unichr = chr22- range_type = range20 text_type = str21 string_types = (str,)22 integer_types = (int, )23 24 iterkeys = lambda d: iter(d.keys())25 itervalues = lambda d: iter(d.values())26 iteritems = lambda d: iter(d.items())27 31- import pickle32- from io import BytesIO, StringIO28+ from io import StringIO33- NativeStringIO = StringIO29 30 def reraise(tp, value, tb=None):31 if value.__traceback__ is not tb:32 raise value.with_traceback(tb)33 raise value34 40- ifilter = filter41- imap = map42- izip = zip43- intern = sys.intern44-45- implements_iterator = _identity35 implements_to_string = _identity47- encode_filename = _identity48- get_next = lambda x: x.__next__36 37 else:51- unichr = unichr38 text_type = unicode53- range_type = xrange39 string_types = (str, unicode)40 integer_types = (int, long)41 42 iterkeys = lambda d: d.iterkeys()43 itervalues = lambda d: d.itervalues()44 iteritems = lambda d: d.iteritems()45 61- import cPickle as pickle62- from cStringIO import StringIO as BytesIO, StringIO46+ from cStringIO import StringIO as StringIO63- NativeStringIO = BytesIO47 48 exec('def reraise(tp, value, tb=None):\n raise tp, value, tb')49 67- from itertools import imap, izip, ifilter68- intern = intern69-70- def implements_iterator(cls):71- cls.next = cls.__next__72- del cls.__next__73- return cls74-50 def implements_to_string(cls):51 cls.__unicode__ = cls.__str__52 cls.__str__ = lambda x: x.__unicode__().encode('utf-8')53 return cls54 80- get_next = lambda x: x.next55 82- def encode_filename(filename):83- if isinstance(filename, unicode):84- return filename.encode('utf-8')85- return filename86-87-56 def with_metaclass(meta, *bases):57 # This requires a bit of explanation: the basic idea is to make a58 # dummy metaclass for one level of class instantiation that replaces59 # itself with the actual metaclass. Because of internal type checks10 unmodified lines70 if this_bases is None:71 return type.__new__(cls, name, (), d)72 return meta(name, bases, d)73 return metaclass('temporary_class', None, {})106-107-108-try:109- from urllib.parse import quote_from_bytes as url_quote110-except ImportError:111- from urllib import quote as url_quotemodified:flask/helpers.py+4 added-1 removed
16 unmodified lines17 from time import time18 from zlib import adler3219 from threading import RLock20 from werkzeug.routing import BuildError21-from werkzeug.urls import url_quote21 from functools import update_wrapper22 23+try:24+ from werkzeug.urls import url_quote25+except ImportError:26+ from urlparse import quote as url_quote27 28 from werkzeug.datastructures import Headers29 from werkzeug.exceptions import NotFound30 819 unmodified lines