Commit f45ffcd0 authored by Guido van Rossum's avatar Guido van Rossum

When doing macro expansion, add two tests:

- that the TALcode version of the macro is the same as that of the
  main program;

- that the mode (html or xml) of the macro is the same as that of the
  main program.

If either of these tests fails, raise METALError().
parent bb8d3f09
......@@ -96,7 +96,8 @@ try:
except ImportError:
from StringIO import StringIO
from TALDefs import quote, TAL_VERSION
from TALDefs import quote, TAL_VERSION, METALError
from TALDefs import isCurrentVersion, getProgramVersion, getProgramMode
from TALGenerator import TALGenerator
BOOLEAN_HTML_ATTRS = [
......@@ -377,6 +378,14 @@ class TALInterpreter:
self.interpret(block)
return
macro = self.engine.evaluateMacro(macroExpr)
if not isCurrentVersion(macro):
raise METALError("macro %s has incompatible version %s" %
(`macroName`, `getProgramVersion(macro)`),
self.position)
mode = getProgramMode(macro)
if mode != (self.html and "html" or "xml"):
raise METALError("macro %s has incompatible mode %s" %
(`macroName`, `mode`), self.position)
save = self.slots, self.currentMacro
self.slots = compiledSlots
self.currentMacro = macroName
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment