- 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
testpaths = tests
filterwarnings =
error
- ignore:the sets module:DeprecationWarning:jinja2.sandbox
[coverage:run]
branch = True
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()
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
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
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
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)
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()
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):
import math
import random
import re
-import warnings
from collections import namedtuple
from itertools import chain
from itertools import groupby
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.
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"
"""
import operator
import types
-import warnings
from collections import deque
from string import Formatter
#: 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,)
import json
import os
import re
-import warnings
from collections import deque
from random import choice
from random import randrange
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))
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)
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:
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)
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