]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
remove deprecated code
authorDavid Lord <davidism@gmail.com>
Mon, 27 Jan 2020 22:28:14 +0000 (14:28 -0800)
committerDavid Lord <davidism@gmail.com>
Wed, 5 Feb 2020 16:37:40 +0000 (08:37 -0800)
CHANGES.rst
setup.cfg
src/jinja2/asyncsupport.py
src/jinja2/environment.py
src/jinja2/exceptions.py
src/jinja2/filters.py
src/jinja2/sandbox.py
src/jinja2/utils.py
tests/test_loader.py
tests/test_utils.py

index 2253fe9c8893d9e2f0ddd27d00aba8e3e8d63e75..afd43e5f1e7e59c1ea663a4526c4ce87bbe52e8e 100644 (file)
@@ -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
index 2769e96ade5505d4fe01ed0802b497925a543e9b..9dff382cf9154f202f77224a4a236c3667fdd39e 100644 (file)
--- 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
index 78ba3739d8dee1e644f96e32f833279d941c3f65..ae4958f6dae72785dbb786ac98c47a3f24c6d656 100644 (file)
@@ -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()
index 3f75816c8ad246efb933a3604dd4097aefb9bd9c..63ac0c8bed27d13050f19caea0958a3cc1a0db83 100644 (file)
@@ -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()
index 0bf2003e30e2a24a54640359bb04f3e98b26e3f6..ac62c3b482aeb95f8d14fa841afc529846ba1fb7 100644 (file)
@@ -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):
index 1af7ac88a7c9aeea80b979982818addc5444612f..963c03ab547f90cffd86de41150111fea1a7cf70 100644 (file)
@@ -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"
 
index 3bb01455530adc4fe6f43ee0bc274d3f41186616..4629143baad144f1049dcc6bb3582ede1cbf1d2a 100644 (file)
@@ -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,)
index e3285e8edb45daf70b7612d8ad256f29ff09f456..7e1ad9117e77726277e2da0f7ead5bb58616e08f 100644 (file)
@@ -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)
index 4aa6511ef2a57fe00d0822c77b56ec6bd6ff25ee..ef51bb568d6be662cfa1576311e1f0d577ec8953 100644 (file)
@@ -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)
 
index 58165efbf09bc9e53bd5c391c5ce25cd7f31146b..6ddd1a412cdd5d343230ef279b1872427941ec1d 100644 (file)
@@ -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