Skip to content
Myr

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

3 files+8 added−43 removed

modified:flask/testsuite/helpers.py+2 added-2 removed
13 unmodified lines
14import unittest15from logging import StreamHandler16from flask.testsuite import FlaskTestCase, catch_warnings, catch_stderr17from werkzeug.http import parse_cache_control_header, parse_options_header18from flask._compat import StringIO, text_type, implements_iterator18from flask._compat import StringIO, text_type192021def has_encoding(name):22 try:
522 unmodified lines
545 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 line
554 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 lines
modified:flask/_compat.py+2 added-40 removed
11 unmodified lines
12"""13import sys1415PY2 = sys.version_info[0] == 216PYPY = hasattr(sys, 'pypy_translation_info')16_identity = lambda x: x171819if not PY2:21 unichr = chr22 range_type = range20 text_type = str21 string_types = (str,)22 integer_types = (int, )2324 iterkeys = lambda d: iter(d.keys())25 itervalues = lambda d: iter(d.values())26 iteritems = lambda d: iter(d.items())2731 import pickle32 from io import BytesIO, StringIO28 from io import StringIO33 NativeStringIO = StringIO2930 def reraise(tp, value, tb=None):31 if value.__traceback__ is not tb:32 raise value.with_traceback(tb)33 raise value3440 ifilter = filter41 imap = map42 izip = zip43 intern = sys.intern4445 implements_iterator = _identity35 implements_to_string = _identity47 encode_filename = _identity48 get_next = lambda x: x.__next__3637else:51 unichr = unichr38 text_type = unicode53 range_type = xrange39 string_types = (str, unicode)40 integer_types = (int, long)4142 iterkeys = lambda d: d.iterkeys()43 itervalues = lambda d: d.itervalues()44 iteritems = lambda d: d.iteritems()4561 import cPickle as pickle62 from cStringIO import StringIO as BytesIO, StringIO46 from cStringIO import StringIO as StringIO63 NativeStringIO = BytesIO4748 exec('def reraise(tp, value, tb=None):\n raise tp, value, tb')4967 from itertools import imap, izip, ifilter68 intern = intern6970 def implements_iterator(cls):71 cls.next = cls.__next__72 del cls.__next__73 return cls7450 def implements_to_string(cls):51 cls.__unicode__ = cls.__str__52 cls.__str__ = lambda x: x.__unicode__().encode('utf-8')53 return cls5480 get_next = lambda x: x.next5582 def encode_filename(filename):83 if isinstance(filename, unicode):84 return filename.encode('utf-8')85 return filename868756def 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 checks
10 unmodified lines
70 if this_bases is None:71 return type.__new__(cls, name, (), d)72 return meta(name, bases, d)73 return metaclass('temporary_class', None, {})106107108try:109 from urllib.parse import quote_from_bytes as url_quote110except ImportError:111 from urllib import quote as url_quote
modified:flask/helpers.py+4 added-1 removed
16 unmodified lines
17from time import time18from zlib import adler3219from threading import RLock20from werkzeug.routing import BuildError21from werkzeug.urls import url_quote21from functools import update_wrapper2223try:24 from werkzeug.urls import url_quote25except ImportError:26 from urlparse import quote as url_quote2728from werkzeug.datastructures import Headers29from werkzeug.exceptions import NotFound30
819 unmodified lines