From: David Lord Date: Mon, 27 Jan 2020 22:28:14 +0000 (-0800) Subject: remove deprecated code X-Git-Tag: 3.0.0a1~2^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b0015c72d5acbf93b9d99a1ce6167889338db85b;p=thirdparty%2Fjinja.git remove deprecated code --- diff --git a/CHANGES.rst b/CHANGES.rst index 2253fe9c..afd43e5f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -8,6 +8,8 @@ Unreleased - Drop support for Python 2.7 and 3.5. - Bump MarkupSafe dependency to >=1.1. - Bump Babel optional dependency to >=2.1. +- Remove code that was marked deprecated. +- 2.11.2 diff --git a/setup.cfg b/setup.cfg index 2769e96a..9dff382c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -9,7 +9,6 @@ universal = true testpaths = tests filterwarnings = error - ignore:the sets module:DeprecationWarning:jinja2.sandbox [coverage:run] branch = True diff --git a/src/jinja2/asyncsupport.py b/src/jinja2/asyncsupport.py index 78ba3739..ae4958f6 100644 --- a/src/jinja2/asyncsupport.py +++ b/src/jinja2/asyncsupport.py @@ -249,16 +249,4 @@ class AsyncLoopContext(LoopContext): return rv, self -async def make_async_loop_context(iterable, undefined, recurse=None, depth0=0): - import warnings - - warnings.warn( - "This template must be recompiled with at least Jinja 2.11, or" - " it will fail in 3.0.", - DeprecationWarning, - stacklevel=2, - ) - return AsyncLoopContext(iterable, undefined, recurse, depth0) - - patch_all() diff --git a/src/jinja2/environment.py b/src/jinja2/environment.py index 3f75816c..63ac0c8b 100644 --- a/src/jinja2/environment.py +++ b/src/jinja2/environment.py @@ -15,8 +15,6 @@ from ._compat import encode_filename from ._compat import implements_iterator from ._compat import implements_to_string from ._compat import iteritems -from ._compat import PY2 -from ._compat import PYPY from ._compat import reraise from ._compat import string_types from ._compat import text_type @@ -689,7 +687,6 @@ class Environment(object): zip="deflated", log_function=None, ignore_errors=True, - py_compile=False, ): """Finds all the templates the loader can find, compiles them and stores them in `target`. If `zip` is `None`, instead of in a @@ -706,11 +703,6 @@ class Environment(object): syntax errors to abort the compilation you can set `ignore_errors` to `False` and you will get an exception on syntax errors. - If `py_compile` is set to `True` .pyc files will be written to the - target instead of standard .py files. This flag does not do anything - on pypy and Python 3 where pyc files are not picked up by itself and - don't give much benefit. - .. versionadded:: 2.4 """ from .loaders import ModuleLoader @@ -720,27 +712,6 @@ class Environment(object): def log_function(x): pass - if py_compile: - if not PY2 or PYPY: - import warnings - - warnings.warn( - "'py_compile=True' has no effect on PyPy or Python" - " 3 and will be removed in version 3.0", - DeprecationWarning, - stacklevel=2, - ) - py_compile = False - else: - import imp - import marshal - - py_header = imp.get_magic() + u"\xff\xff\xff\xff".encode("iso-8859-15") - - # Python 3.3 added a source filesize to the header - if sys.version_info >= (3, 3): - py_header += u"\x00\x00\x00\x00".encode("iso-8859-15") - def write_file(filename, data): if zip: info = ZipInfo(filename) @@ -778,13 +749,8 @@ class Environment(object): filename = ModuleLoader.get_module_filename(name) - if py_compile: - c = self._compile(code, encode_filename(filename)) - write_file(filename + "c", py_header + marshal.dumps(c)) - log_function('Byte-compiled "%s" as %s' % (name, filename + "c")) - else: - write_file(filename, code) - log_function('Compiled "%s" as %s' % (name, filename)) + write_file(filename, code) + log_function('Compiled "%s" as %s' % (name, filename)) finally: if zip: zip_file.close() diff --git a/src/jinja2/exceptions.py b/src/jinja2/exceptions.py index 0bf2003e..ac62c3b4 100644 --- a/src/jinja2/exceptions.py +++ b/src/jinja2/exceptions.py @@ -47,8 +47,8 @@ class TemplateNotFound(IOError, LookupError, TemplateError): provided, an :exc:`UndefinedError` is raised. """ - # looks weird, but removes the warning descriptor that just - # bogusly warns us about message being deprecated + # Silence the Python warning about message being deprecated since + # it's not valid here. message = None def __init__(self, name, message=None): diff --git a/src/jinja2/filters.py b/src/jinja2/filters.py index 1af7ac88..963c03ab 100644 --- a/src/jinja2/filters.py +++ b/src/jinja2/filters.py @@ -3,7 +3,6 @@ import math import random import re -import warnings from collections import namedtuple from itertools import chain from itertools import groupby @@ -617,7 +616,7 @@ def do_urlize( return rv -def do_indent(s, width=4, first=False, blank=False, indentfirst=None): +def do_indent(s, width=4, first=False, blank=False): """Return a copy of the string with each line indented by 4 spaces. The first line and blank lines are not indented by default. @@ -630,15 +629,6 @@ def do_indent(s, width=4, first=False, blank=False, indentfirst=None): Rename the ``indentfirst`` argument to ``first``. """ - if indentfirst is not None: - warnings.warn( - "The 'indentfirst' argument is renamed to 'first' and will" - " be removed in version 3.0.", - DeprecationWarning, - stacklevel=2, - ) - first = indentfirst - indention = u" " * width newline = u"\n" diff --git a/src/jinja2/sandbox.py b/src/jinja2/sandbox.py index 3bb01455..4629143b 100644 --- a/src/jinja2/sandbox.py +++ b/src/jinja2/sandbox.py @@ -4,7 +4,6 @@ Useful when the template itself comes from an untrusted source. """ import operator import types -import warnings from collections import deque from string import Formatter @@ -47,11 +46,6 @@ UNSAFE_COROUTINE_ATTRIBUTES = {"cr_frame", "cr_code"} #: unsafe attributes on async generators UNSAFE_ASYNC_GENERATOR_ATTRIBUTES = {"ag_code", "ag_frame"} -# make sure we don't warn in python 2.6 about stuff we don't care about -warnings.filterwarnings( - "ignore", "the sets module", DeprecationWarning, module=__name__ -) - _mutable_set_types = (set,) _mutable_mapping_types = (dict,) _mutable_sequence_types = (list,) diff --git a/src/jinja2/utils.py b/src/jinja2/utils.py index e3285e8e..7e1ad911 100644 --- a/src/jinja2/utils.py +++ b/src/jinja2/utils.py @@ -2,7 +2,6 @@ import json import os import re -import warnings from collections import deque from random import choice from random import randrange @@ -465,56 +464,14 @@ class LRUCache(object): result.reverse() return result - def iteritems(self): - """Iterate over all items.""" - warnings.warn( - "'iteritems()' will be removed in version 3.0. Use" - " 'iter(cache.items())' instead.", - DeprecationWarning, - stacklevel=2, - ) - return iter(self.items()) - def values(self): """Return a list of all values.""" return [x[1] for x in self.items()] - def itervalue(self): - """Iterate over all values.""" - warnings.warn( - "'itervalue()' will be removed in version 3.0. Use" - " 'iter(cache.values())' instead.", - DeprecationWarning, - stacklevel=2, - ) - return iter(self.values()) - - def itervalues(self): - """Iterate over all values.""" - warnings.warn( - "'itervalues()' will be removed in version 3.0. Use" - " 'iter(cache.values())' instead.", - DeprecationWarning, - stacklevel=2, - ) - return iter(self.values()) - def keys(self): """Return a list of all keys ordered by most recent usage.""" return list(self) - def iterkeys(self): - """Iterate over all keys in the cache dict, ordered by - the most recent usage. - """ - warnings.warn( - "'iterkeys()' will be removed in version 3.0. Use" - " 'iter(cache.keys())' instead.", - DeprecationWarning, - stacklevel=2, - ) - return iter(self) - def __iter__(self): return reversed(tuple(self._queue)) @@ -713,15 +670,3 @@ try: have_async_gen = True except SyntaxError: have_async_gen = False - - -def soft_unicode(s): - from markupsafe import soft_unicode - - warnings.warn( - "'jinja2.utils.soft_unicode' will be removed in version 3.0." - " Use 'markupsafe.soft_unicode' instead.", - DeprecationWarning, - stacklevel=2, - ) - return soft_unicode(s) diff --git a/tests/test_loader.py b/tests/test_loader.py index 4aa6511e..ef51bb56 100644 --- a/tests/test_loader.py +++ b/tests/test_loader.py @@ -191,7 +191,7 @@ class TestFileSystemLoader(object): class TestModuleLoader(object): archive = None - def compile_down(self, prefix_loader, zip="deflated", py_compile=False): + def compile_down(self, prefix_loader, zip="deflated"): log = [] self.reg_env = Environment(loader=prefix_loader) if zip is not None: @@ -199,9 +199,7 @@ class TestModuleLoader(object): os.close(fd) else: self.archive = tempfile.mkdtemp() - self.reg_env.compile_templates( - self.archive, zip=zip, log_function=log.append, py_compile=py_compile - ) + self.reg_env.compile_templates(self.archive, zip=zip, log_function=log.append) self.mod_env = Environment(loader=loaders.ModuleLoader(self.archive)) return "".join(log) diff --git a/tests/test_utils.py b/tests/test_utils.py index 58165efb..6ddd1a41 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -31,13 +31,6 @@ class TestLRUCache(object): assert len(d) == 3 assert "a" in d and "c" in d and "d" in d and "b" not in d - def test_itervalue_deprecated(self): - cache = LRUCache(3) - cache["a"] = 1 - cache["b"] = 2 - with pytest.deprecated_call(): - cache.itervalue() - def test_itervalues(self): cache = LRUCache(3) cache["b"] = 1