remove deprecated code
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Lord · committed by David Lord · parent e52b42d · Browse files · 10 files·+9 added−134 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
10 files+9 added−134 removed
- tests:+2 added−11 removed
- other:+7 added−123 removed
Provenance
- Commit
b0015c7- Tree
e05049d- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent
e52b42d
10 files changed+9 added−134 removed
modified:src/jinja2/asyncsupport.py-12 removed
247 unmodified lines248 self._current = rv249 return rv, self250 251 252-async def make_async_loop_context(iterable, undefined, recurse=None, depth0=0):253- import warnings254-255- warnings.warn(256- "This template must be recompiled with at least Jinja 2.11, or"257- " it will fail in 3.0.",258- DeprecationWarning,259- stacklevel=2,260- )261- return AsyncLoopContext(iterable, undefined, recurse, depth0)262-263-252 patch_all()modified:src/jinja2/environment.py+2 added-36 removed
13 unmodified lines14 from ._compat import encode_filename15 from ._compat import implements_iterator16 from ._compat import implements_to_string17 from ._compat import iteritems18-from ._compat import PY219-from ._compat import PYPY18 from ._compat import reraise19 from ._compat import string_types20 from ._compat import text_type21 from .compiler import CodeGenerator664 unmodified lines686 filter_func=None,687 zip="deflated",688 log_function=None,689 ignore_errors=True,692- py_compile=False,690 ):691 """Finds all the templates the loader can find, compiles them692 and stores them in `target`. If `zip` is `None`, instead of in a693 zipfile, the templates will be stored in a directory.8 unmodified lines702 log function is provided, errors are logged. If you want template703 syntax errors to abort the compilation you can set `ignore_errors`704 to `False` and you will get an exception on syntax errors.705 709- If `py_compile` is set to `True` .pyc files will be written to the710- target instead of standard .py files. This flag does not do anything711- on pypy and Python 3 where pyc files are not picked up by itself and712- don't give much benefit.713-706 .. versionadded:: 2.4707 """708 from .loaders import ModuleLoader709 1 unmodified line711 712 def log_function(x):713 pass714 723- if py_compile:724- if not PY2 or PYPY:725- import warnings726-727- warnings.warn(728- "'py_compile=True' has no effect on PyPy or Python"729- " 3 and will be removed in version 3.0",730- DeprecationWarning,731- stacklevel=2,732- )733- py_compile = False734- else:735- import imp736- import marshal737-738- py_header = imp.get_magic() + u"\xff\xff\xff\xff".encode("iso-8859-15")739-740- # Python 3.3 added a source filesize to the header741- if sys.version_info >= (3, 3):742- py_header += u"\x00\x00\x00\x00".encode("iso-8859-15")743-715 def write_file(filename, data):716 if zip:717 info = ZipInfo(filename)718 info.external_attr = 0o755 << 1629 unmodified lines748 continue749 750 filename = ModuleLoader.get_module_filename(name)751 781- if py_compile:782- c = self._compile(code, encode_filename(filename))783- write_file(filename + "c", py_header + marshal.dumps(c))784- log_function('Byte-compiled "%s" as %s' % (name, filename + "c"))785- else:786- write_file(filename, code)787- log_function('Compiled "%s" as %s' % (name, filename))752+ write_file(filename, code)753+ log_function('Compiled "%s" as %s' % (name, filename))754 finally:755 if zip:756 zip_file.close()757 571 unmodified linesmodified:src/jinja2/exceptions.py+2 added-2 removed
45 unmodified lines46 If the given name is :class:`Undefined` and no message was47 provided, an :exc:`UndefinedError` is raised.48 """49 50- # looks weird, but removes the warning descriptor that just51- # bogusly warns us about message being deprecated50+ # Silence the Python warning about message being deprecated since51+ # it's not valid here.52 message = None53 54 def __init__(self, name, message=None):55 IOError.__init__(self, name)122 unmodified linesmodified:src/jinja2/filters.py+1 added-11 removed
1 unmodified line2 """Built-in template filters used with the ``|`` operator."""3 import math4 import random5 import re6-import warnings6 from collections import namedtuple7 from itertools import chain8 from itertools import groupby9 605 unmodified lines615 rv = Markup(rv)616 return rv617 618 620-def do_indent(s, width=4, first=False, blank=False, indentfirst=None):619+def do_indent(s, width=4, first=False, blank=False):620 """Return a copy of the string with each line indented by 4 spaces. The621 first line and blank lines are not indented by default.622 623 :param width: Number of spaces to indent by.4 unmodified lines628 Blank lines are not indented by default.629 630 Rename the ``indentfirst`` argument to ``first``.631 """633- if indentfirst is not None:634- warnings.warn(635- "The 'indentfirst' argument is renamed to 'first' and will"636- " be removed in version 3.0.",637- DeprecationWarning,638- stacklevel=2,639- )640- first = indentfirst641-632 indention = u" " * width633 newline = u"\n"634 635 if isinstance(s, Markup):737 unmodified linesmodified:src/jinja2/sandbox.py-6 removed
2 unmodified lines3 Useful when the template itself comes from an untrusted source.4 """5 import operator6 import types7-import warnings7 from collections import deque8 from string import Formatter9 10 from markupsafe import EscapeFormatter34 unmodified lines45 46 #: unsafe attributes on async generators47 UNSAFE_ASYNC_GENERATOR_ATTRIBUTES = {"ag_code", "ag_frame"}48 50-# make sure we don't warn in python 2.6 about stuff we don't care about51-warnings.filterwarnings(52- "ignore", "the sets module", DeprecationWarning, module=__name__53-)54-49 _mutable_set_types = (set,)50 _mutable_mapping_types = (dict,)51 _mutable_sequence_types = (list,)52 451 unmodified linesmodified:src/jinja2/utils.py-55 removed
1 # -*- coding: utf-8 -*-2 import json3 import os4 import re5-import warnings5 from collections import deque6 from random import choice7 from random import randrange8 from threading import Lock454 unmodified lines463 result = [(key, self._mapping[key]) for key in list(self._queue)]464 result.reverse()465 return result466 468- def iteritems(self):469- """Iterate over all items."""470- warnings.warn(471- "'iteritems()' will be removed in version 3.0. Use"472- " 'iter(cache.items())' instead.",473- DeprecationWarning,474- stacklevel=2,475- )476- return iter(self.items())477-467 def values(self):468 """Return a list of all values."""469 return [x[1] for x in self.items()]470 482- def itervalue(self):483- """Iterate over all values."""484- warnings.warn(485- "'itervalue()' will be removed in version 3.0. Use"486- " 'iter(cache.values())' instead.",487- DeprecationWarning,488- stacklevel=2,489- )490- return iter(self.values())491-492- def itervalues(self):493- """Iterate over all values."""494- warnings.warn(495- "'itervalues()' will be removed in version 3.0. Use"496- " 'iter(cache.values())' instead.",497- DeprecationWarning,498- stacklevel=2,499- )500- return iter(self.values())501-471 def keys(self):472 """Return a list of all keys ordered by most recent usage."""473 return list(self)474 506- def iterkeys(self):507- """Iterate over all keys in the cache dict, ordered by508- the most recent usage.509- """510- warnings.warn(511- "'iterkeys()' will be removed in version 3.0. Use"512- " 'iter(cache.keys())' instead.",513- DeprecationWarning,514- stacklevel=2,515- )516- return iter(self)517-475 def __iter__(self):476 return reversed(tuple(self._queue))477 478 def __reversed__(self):190 unmodified lines669 exec("async def _():\n async for _ in ():\n yield _")670 have_async_gen = True671 except SyntaxError:672 have_async_gen = False716-717-718-def soft_unicode(s):719- from markupsafe import soft_unicode720-721- warnings.warn(722- "'jinja2.utils.soft_unicode' will be removed in version 3.0."723- " Use 'markupsafe.soft_unicode' instead.",724- DeprecationWarning,725- stacklevel=2,726- )727- return soft_unicode(s)modified:tests/test_loader.py+2 added-4 removed
189 unmodified lines190 @pytest.mark.moduleloader191 class TestModuleLoader(object):192 archive = None193 194- def compile_down(self, prefix_loader, zip="deflated", py_compile=False):194+ def compile_down(self, prefix_loader, zip="deflated"):195 log = []196 self.reg_env = Environment(loader=prefix_loader)197 if zip is not None:198 fd, self.archive = tempfile.mkstemp(suffix=".zip")199 os.close(fd)200 else:201 self.archive = tempfile.mkdtemp()202- self.reg_env.compile_templates(203- self.archive, zip=zip, log_function=log.append, py_compile=py_compile204- )202+ self.reg_env.compile_templates(self.archive, zip=zip, log_function=log.append)203 self.mod_env = Environment(loader=loaders.ModuleLoader(self.archive))204 return "".join(log)205 206 def teardown(self):169 unmodified linesmodified:tests/test_utils.py-7 removed
29 unmodified lines30 d["d"] = 431 assert len(d) == 332 assert "a" in d and "c" in d and "d" in d and "b" not in d33 34- def test_itervalue_deprecated(self):35- cache = LRUCache(3)36- cache["a"] = 137- cache["b"] = 238- with pytest.deprecated_call():39- cache.itervalue()40-34 def test_itervalues(self):35 cache = LRUCache(3)36 cache["b"] = 137 cache["a"] = 2164 unmodified linesmodified:CHANGES.rst+2 added
6 unmodified lines7 8 - Drop support for Python 2.7 and 3.5.9 - Bump MarkupSafe dependency to >=1.1.10 - Bump Babel optional dependency to >=2.1.11+- Remove code that was marked deprecated.12+-13 14 15 2.11.216 ------748 unmodified linesmodified:setup.cfg-1 removed
7 unmodified lines8 [tool:pytest]9 testpaths = tests10 filterwarnings =11 error12- ignore:the sets module:DeprecationWarning:jinja2.sandbox12 13 [coverage:run]14 branch = True15 source =29 unmodified lines