Skip to content
Myr

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

10 files+9 added−134 removed

modified:src/jinja2/asyncsupport.py-12 removed
247 unmodified lines
248 self._current = rv249 return rv, self250251252async def make_async_loop_context(iterable, undefined, recurse=None, depth0=0):253 import warnings254255 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)262263252patch_all()
modified:src/jinja2/environment.py+2 added-36 removed
13 unmodified lines
14from ._compat import encode_filename15from ._compat import implements_iterator16from ._compat import implements_to_string17from ._compat import iteritems18from ._compat import PY219from ._compat import PYPY18from ._compat import reraise19from ._compat import string_types20from ._compat import text_type21from .compiler import CodeGenerator
664 unmodified lines
686 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 lines
702 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.705709 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.713706 .. versionadded:: 2.4707 """708 from .loaders import ModuleLoader709
1 unmodified line
711712 def log_function(x):713 pass714723 if py_compile:724 if not PY2 or PYPY:725 import warnings726727 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 marshal737738 py_header = imp.get_magic() + u"\xff\xff\xff\xff".encode("iso-8859-15")739740 # 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")743715 def write_file(filename, data):716 if zip:717 info = ZipInfo(filename)718 info.external_attr = 0o755 << 16
29 unmodified lines
748 continue749750 filename = ModuleLoader.get_module_filename(name)751781 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 lines
modified:src/jinja2/exceptions.py+2 added-2 removed
45 unmodified lines
46 If the given name is :class:`Undefined` and no message was47 provided, an :exc:`UndefinedError` is raised.48 """4950 # 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 = None5354 def __init__(self, name, message=None):55 IOError.__init__(self, name)
122 unmodified lines
modified:src/jinja2/filters.py+1 added-11 removed
1 unmodified line
2"""Built-in template filters used with the ``|`` operator."""3import math4import random5import re6import warnings6from collections import namedtuple7from itertools import chain8from itertools import groupby9
605 unmodified lines
615 rv = Markup(rv)616 return rv617618620def do_indent(s, width=4, first=False, blank=False, indentfirst=None):619def 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.622623 :param width: Number of spaces to indent by.
4 unmodified lines
628 Blank lines are not indented by default.629630 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 = indentfirst641632 indention = u" " * width633 newline = u"\n"634635 if isinstance(s, Markup):
737 unmodified lines
modified:src/jinja2/sandbox.py-6 removed
2 unmodified lines
3Useful when the template itself comes from an untrusted source.4"""5import operator6import types7import warnings7from collections import deque8from string import Formatter910from markupsafe import EscapeFormatter
34 unmodified lines
4546#: unsafe attributes on async generators47UNSAFE_ASYNC_GENERATOR_ATTRIBUTES = {"ag_code", "ag_frame"}4850# make sure we don't warn in python 2.6 about stuff we don't care about51warnings.filterwarnings(52 "ignore", "the sets module", DeprecationWarning, module=__name__53)5449_mutable_set_types = (set,)50_mutable_mapping_types = (dict,)51_mutable_sequence_types = (list,)52
451 unmodified lines
modified:src/jinja2/utils.py-55 removed
1# -*- coding: utf-8 -*-2import json3import os4import re5import warnings5from collections import deque6from random import choice7from random import randrange8from threading import Lock
454 unmodified lines
463 result = [(key, self._mapping[key]) for key in list(self._queue)]464 result.reverse()465 return result466468 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())477467 def values(self):468 """Return a list of all values."""469 return [x[1] for x in self.items()]470482 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())491492 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())501471 def keys(self):472 """Return a list of all keys ordered by most recent usage."""473 return list(self)474506 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)517475 def __iter__(self):476 return reversed(tuple(self._queue))477478 def __reversed__(self):
190 unmodified lines
669 exec("async def _():\n async for _ in ():\n yield _")670 have_async_gen = True671except SyntaxError:672 have_async_gen = False716717718def soft_unicode(s):719 from markupsafe import soft_unicode720721 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 lines
190@pytest.mark.moduleloader191class TestModuleLoader(object):192 archive = None193194 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)205206 def teardown(self):
169 unmodified lines
modified:tests/test_utils.py-7 removed
29 unmodified lines
30 d["d"] = 431 assert len(d) == 332 assert "a" in d and "c" in d and "d" in d and "b" not in d3334 def test_itervalue_deprecated(self):35 cache = LRUCache(3)36 cache["a"] = 137 cache["b"] = 238 with pytest.deprecated_call():39 cache.itervalue()4034 def test_itervalues(self):35 cache = LRUCache(3)36 cache["b"] = 137 cache["a"] = 2
164 unmodified lines
modified:CHANGES.rst+2 added
6 unmodified lines
78- 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-1314152.11.216------
748 unmodified lines
modified:setup.cfg-1 removed
7 unmodified lines
8[tool:pytest]9testpaths = tests10filterwarnings =11 error12 ignore:the sets module:DeprecationWarning:jinja2.sandbox1213[coverage:run]14branch = True15source =
29 unmodified lines