Commit b9635b0a authored by Fred Drake's avatar Fred Drake

Bump the version number of the generated byte-code; it looks a bit

different now!

Use saved type objects when calling isinstance() instead of calling
type() each time.

getProgramMode(), getProgramVersion():
    Update to the new byte-code format.

quote():
    Change the way cgi.escape() is referenced to avoid runtime
    lookups.
parent 45a73765
......@@ -86,7 +86,9 @@
Common definitions used by TAL and METAL compilation an transformation.
"""
TAL_VERSION = "1.3"
from types import ListType, TupleType
TAL_VERSION = "1.4"
XML_NS = "http://www.w3.org/XML/1998/namespace" # URI for XML namespace
XMLNS_NS = "http://www.w3.org/2000/xmlns/" # URI for XML NS declarations
......@@ -195,23 +197,22 @@ def isCurrentVersion(program):
def getProgramMode(program):
version = getProgramVersion(program)
if (version == TAL_VERSION and isinstance(program[1], type(())) and
if (version == TAL_VERSION and isinstance(program[1], TupleType) and
len(program[1]) == 2):
opcode, mode = program[1]
if opcode == "mode":
return mode
return mode[0]
return None
def getProgramVersion(program):
if (isinstance(program, type([])) and len(program) >= 2 and
isinstance(program[0], type(())) and len(program[0]) == 2):
if (isinstance(program, ListType) and len(program) >= 2 and
isinstance(program[0], TupleType) and len(program[0]) == 2):
opcode, version = program[0]
if opcode == "version":
return version
return version[0]
return None
import cgi
_cgi = cgi
def quote(s, escape=cgi.escape):
return '"%s"' % escape(s, 1)
del cgi
def quote(s):
return '"%s"' % _cgi.escape(s, 1)
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