From: Armin Ronacher Date: Sat, 21 Apr 2007 08:12:43 +0000 (+0200) Subject: [svn] fixed "Deferred" implementation for the c context X-Git-Tag: 2.0rc1~344 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=157d7e5dd5aa6726c87dad40a5317c5ba2458a40;p=jinja2.git [svn] fixed "Deferred" implementation for the c context --HG-- branch : trunk --- diff --git a/docs/src/designerdoc.txt b/docs/src/designerdoc.txt index 1d6cf66..1173763 100644 --- a/docs/src/designerdoc.txt +++ b/docs/src/designerdoc.txt @@ -982,7 +982,7 @@ change. {% call makelist([1, 2, 3, 4, 5, 6]) -%} [[{{ item }}]] - {% endcall %} + {%- endcall %} This will then produce this output: diff --git a/jinja/_native.py b/jinja/_native.py index 4abbb5c..6a9cb73 100644 --- a/jinja/_native.py +++ b/jinja/_native.py @@ -14,6 +14,7 @@ :license: BSD, see LICENSE for more details. """ from jinja.datastructure import Deferred, Undefined +from jinja.exceptions import TemplateRuntimeError class BaseContext(object): diff --git a/jinja/_speedups.c b/jinja/_speedups.c index e57ac3d..108697f 100644 --- a/jinja/_speedups.c +++ b/jinja/_speedups.c @@ -21,8 +21,7 @@ #include /* Set by init_constants to real values */ -static PyObject *Undefined, *TemplateRuntimeError, *FilterNotFound; -static PyTypeObject *DeferredType; +static PyObject *Undefined, *Deferred, *TemplateRuntimeError; /** * Internal struct used by BaseContext to store the @@ -61,10 +60,8 @@ init_constants(void) return 0; } Undefined = PyObject_GetAttrString(datastructure, "Undefined"); - PyObject *deferred = PyObject_GetAttrString(datastructure, "Deferred"); - DeferredType = deferred->ob_type; + Deferred = PyObject_GetAttrString(datastructure, "Deferred"); TemplateRuntimeError = PyObject_GetAttrString(exceptions, "TemplateRuntimeError"); - FilterNotFound = PyObject_GetAttrString(exceptions, "FilterNotFound"); Py_DECREF(datastructure); Py_DECREF(exceptions); return 1; @@ -272,10 +269,10 @@ BaseContext_getitem(BaseContext *self, PyObject *item) continue; } Py_INCREF(result); - if (PyObject_TypeCheck(result, DeferredType)) { + if (PyObject_IsInstance(result, Deferred)) { PyObject *args = PyTuple_New(2); - if (!args || !PyTuple_SetItem(args, 0, (PyObject*)self) || - !PyTuple_SetItem(args, 1, item)) + if (!args || PyTuple_SetItem(args, 0, (PyObject*)self) || + PyTuple_SetItem(args, 1, item)) return NULL; PyObject *resolved = PyObject_CallObject(result, args);