Skip to content
Myr

Merge branch '2.11.x'

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 · parents b3a9df3, 07b5c01 · Browse files · 6 files+41 added−15 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

6 files+41 added−15 removed

  • tests:+15 added−0 removed
  • other:+26 added−15 removed

6 files+41 added−15 removed

modified:docs/api.rst+4 added-3 removed
3 unmodified lines
4.. module:: jinja25 :noindex:6 :synopsis: public Jinja API78This document describes the API to Jinja and not the template language. It9will be most useful as reference to those implementing the template interface10to the application and not those who are creating Jinja templates.8This document describes the API to Jinja and not the template language9(for that, see :doc:`/templates`). It will be most useful as reference10to those implementing the template interface to the application and not11those who are creating Jinja templates.1213Basics14------15
856 unmodified lines
modified:src/jinja2/debug.py+1 added-4 removed
236 unmodified lines
237238 class _CTraceback(ctypes.Structure):239 _fields_ = [240 # Extra PyObject slots when compiled with Py_TRACE_REFS.241 (242 "PyObject_HEAD",243 ctypes.c_byte * (32 if hasattr(sys, "getobjects") else 16),244 ),241 ("PyObject_HEAD", ctypes.c_byte * object().__sizeof__()),242 # Only care about tb_next as an object, not a traceback.243 ("tb_next", ctypes.py_object),244 ]245
16 unmodified lines
modified:src/jinja2/loaders.py+2 added-2 removed
230 unmodified lines
231 template directory is assumed to only be in one namespace232 contributor. Zip files contributing to a namespace are not233 supported.234235 .. versionchanged:: 2.11.0235 .. versionchanged:: 3.0236 No longer uses ``setuptools`` as a dependency.237238 .. versionchanged:: 2.11.0238 .. versionchanged:: 3.0239 Limited PEP 420 namespace package support.240 """241242 def __init__(self, package_name, package_path="templates", encoding="utf-8"):
320 unmodified lines
modified:src/jinja2/utils.py+7 added-6 removed
156 unmodified lines
157 if obj is None:158 return "None"159 elif obj is Ellipsis:160 return "Ellipsis"161 # __builtin__ in 2.x, builtins in 3.x162 if obj.__class__.__module__ in ("__builtin__", "builtins"):163 name = obj.__class__.__name__164 else:165 name = f"{obj.__class__.__module__}.{obj.__class__.__name__}"166 return f"{name} object"161162 cls = type(obj)163164 if cls.__module__ == "builtins":165 return f"{cls.__name__} object"166167 return f"{cls.__module__}.{cls.__name__} object"168169170def pformat(obj):171 """Format an object using :func:`pprint.pformat`.172 """173 from pprint import pformat
492 unmodified lines
modified:tests/test_api.py+15 added
265 unmodified lines
266 def test_undefined_and_special_attributes(self):267 with pytest.raises(AttributeError):268 Undefined("Foo").__dict__269270 def test_undefined_attribute_error(self):271 # Django's LazyObject turns the __class__ attribute into a272 # property that resolves the wrapped function. If that wrapped273 # function raises an AttributeError, printing the repr of the274 # object in the undefined message would cause a RecursionError.275 class Error:276 @property277 def __class__(self):278 raise AttributeError()279280 u = Undefined(obj=Error(), name="hello")281282 with pytest.raises(UndefinedError):283 getattr(u, "recursion", None)284285 def test_logging_undefined(self):286 _messages = []287288 class DebugLogger:
145 unmodified lines
modified:CHANGES.rst+12 added
19 unmodified lines
20 :class:`~unittest.mock.Mock` to be treated as a21 :func:`contextfunction`. :issue:`1145`22- Update ``wordcount`` filter to trigger :class:`Undefined` methods23 by wrapping the input in :func:`soft_str`. :pr:`1160`24- Fix a hang when displaying tracebacks on Python 32-bit.25 :issue:`1162`26- Showing an undefined error for an object that raises27 ``AttributeError`` on access doesn't cause a recursion error.28 :issue:`1177`29- Revert changes to :class:`~loaders.PackageLoader` from 2.10 which30 removed the dependency on setuptools and pkg_resources, and added31 limited support for namespace packages. The changes caused issues32 when using Pytest. Due to the difficulty in supporting Python 2 and33 :pep:`451` simultaneously, the changes are reverted until 3.0.34 :pr:`1182`353637Version 2.11.138--------------3940Released 2020-01-30
735 unmodified lines