diff --git a/src/jinja2/__init__.py b/src/jinja2/__init__.py index 9c4c9cfc5..8149c702a 100644 --- a/src/jinja2/__init__.py +++ b/src/jinja2/__init__.py @@ -3,6 +3,9 @@ non-XML syntax that supports inline expressions and an optional sandboxed environment. """ +from markupsafe import escape +from markupsafe import Markup + from .bccache import BytecodeCache from .bccache import FileSystemBytecodeCache from .bccache import MemcachedBytecodeCache @@ -34,10 +37,8 @@ from .utils import clear_caches from .utils import contextfunction from .utils import environmentfunction -from .utils import escape from .utils import evalcontextfunction from .utils import is_undefined -from .utils import Markup from .utils import select_autoescape -__version__ = "2.11.0.dev0" +__version__ = "2.11.0rc2" diff --git a/src/jinja2/asyncsupport.py b/src/jinja2/asyncsupport.py index d97e46fcd..78ba3739d 100644 --- a/src/jinja2/asyncsupport.py +++ b/src/jinja2/asyncsupport.py @@ -6,11 +6,12 @@ import inspect from functools import update_wrapper +from markupsafe import Markup + from .environment import TemplateModule from .runtime import LoopContext from .utils import concat from .utils import internalcode -from .utils import Markup from .utils import missing diff --git a/src/jinja2/compiler.py b/src/jinja2/compiler.py index 32dac88cb..cbc0546d2 100644 --- a/src/jinja2/compiler.py +++ b/src/jinja2/compiler.py @@ -5,6 +5,9 @@ from itertools import chain from keyword import iskeyword as is_python_keyword +from markupsafe import escape +from markupsafe import Markup + from . import nodes from ._compat import imap from ._compat import iteritems @@ -22,8 +25,6 @@ from .nodes import EvalContext from .optimizer import Optimizer from .utils import concat -from .utils import escape -from .utils import Markup from .visitor import NodeVisitor operators = { @@ -712,7 +713,7 @@ def visit_Template(self, node, frame=None): assert frame is None, "no root frame allowed" eval_ctx = EvalContext(self.environment, self.name) - from .runtime import __all__ as exported + from .runtime import exported self.writeline("from __future__ import %s" % ", ".join(code_features)) self.writeline("from jinja2.runtime import " + ", ".join(exported)) diff --git a/src/jinja2/defaults.py b/src/jinja2/defaults.py index b5d5f4ef6..8e0e7d771 100644 --- a/src/jinja2/defaults.py +++ b/src/jinja2/defaults.py @@ -42,6 +42,3 @@ "json.dumps_kwargs": {"sort_keys": True}, "ext.i18n.trimmed": False, } - -# export all constants -__all__ = tuple(x for x in locals().keys() if x.isupper()) diff --git a/src/jinja2/environment.py b/src/jinja2/environment.py index 08c5e6a08..bf44b9deb 100644 --- a/src/jinja2/environment.py +++ b/src/jinja2/environment.py @@ -8,6 +8,8 @@ from functools import partial from functools import reduce +from markupsafe import Markup + from . import nodes from ._compat import encode_filename from ._compat import implements_iterator @@ -54,7 +56,6 @@ from .utils import import_string from .utils import internalcode from .utils import LRUCache -from .utils import Markup from .utils import missing # for direct template usage we have up to ten living environments @@ -218,7 +219,7 @@ class Environment(object): `autoescape` If set to ``True`` the XML/HTML autoescaping feature is enabled by default. For more details about autoescaping see - :class:`~jinja2.utils.Markup`. As of Jinja 2.4 this can also + :class:`~markupsafe.Markup`. As of Jinja 2.4 this can also be a callable that is passed the template name and has to return ``True`` or ``False`` depending on autoescape should be enabled by default. diff --git a/src/jinja2/ext.py b/src/jinja2/ext.py index 01aab74a7..9141be4da 100644 --- a/src/jinja2/ext.py +++ b/src/jinja2/ext.py @@ -4,6 +4,8 @@ import re from sys import version_info +from markupsafe import Markup + from . import nodes from ._compat import iteritems from ._compat import string_types @@ -27,7 +29,6 @@ from .runtime import concat from .utils import contextfunction from .utils import import_string -from .utils import Markup # the only real useful gettext functions for a Jinja template. Note # that ugettext must be assigned to gettext as Jinja doesn't support diff --git a/src/jinja2/nodes.py b/src/jinja2/nodes.py index f0e9e0323..9f3edc05f 100644 --- a/src/jinja2/nodes.py +++ b/src/jinja2/nodes.py @@ -6,11 +6,12 @@ import operator from collections import deque +from markupsafe import Markup + from ._compat import izip from ._compat import PY2 from ._compat import text_type from ._compat import with_metaclass -from .utils import Markup _binop_to_func = { "*": operator.mul, diff --git a/src/jinja2/runtime.py b/src/jinja2/runtime.py index d356b0746..527d4b5e4 100644 --- a/src/jinja2/runtime.py +++ b/src/jinja2/runtime.py @@ -4,7 +4,7 @@ from itertools import chain from types import MethodType -from markupsafe import escape +from markupsafe import escape # noqa: F401 from markupsafe import Markup from markupsafe import soft_unicode @@ -17,19 +17,19 @@ from ._compat import string_types from ._compat import text_type from ._compat import with_metaclass -from .exceptions import TemplateNotFound -from .exceptions import TemplateRuntimeError +from .exceptions import TemplateNotFound # noqa: F401 +from .exceptions import TemplateRuntimeError # noqa: F401 from .exceptions import UndefinedError from .nodes import EvalContext from .utils import concat from .utils import evalcontextfunction from .utils import internalcode from .utils import missing -from .utils import Namespace +from .utils import Namespace # noqa: F401 from .utils import object_type_repr # these variables are exported to the template runtime -__all__ = [ +exported = [ "LoopContext", "TemplateReference", "Macro", diff --git a/src/jinja2/sandbox.py b/src/jinja2/sandbox.py index af4a96e68..cfd7993ae 100644 --- a/src/jinja2/sandbox.py +++ b/src/jinja2/sandbox.py @@ -9,6 +9,7 @@ from string import Formatter from markupsafe import EscapeFormatter +from markupsafe import Markup from ._compat import abc from ._compat import PY2 @@ -16,7 +17,6 @@ from ._compat import string_types from .environment import Environment from .exceptions import SecurityError -from .utils import Markup #: maximum number of items a range may produce MAX_RANGE = 100000