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 @@ ...@@ -86,7 +86,9 @@
Common definitions used by TAL and METAL compilation an transformation. 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 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 XMLNS_NS = "http://www.w3.org/2000/xmlns/" # URI for XML NS declarations
...@@ -195,23 +197,22 @@ def isCurrentVersion(program): ...@@ -195,23 +197,22 @@ def isCurrentVersion(program):
def getProgramMode(program): def getProgramMode(program):
version = getProgramVersion(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): len(program[1]) == 2):
opcode, mode = program[1] opcode, mode = program[1]
if opcode == "mode": if opcode == "mode":
return mode return mode[0]
return None return None
def getProgramVersion(program): def getProgramVersion(program):
if (isinstance(program, type([])) and len(program) >= 2 and if (isinstance(program, ListType) and len(program) >= 2 and
isinstance(program[0], type(())) and len(program[0]) == 2): isinstance(program[0], TupleType) and len(program[0]) == 2):
opcode, version = program[0] opcode, version = program[0]
if opcode == "version": if opcode == "version":
return version return version[0]
return None return None
import cgi import cgi
_cgi = cgi def quote(s, escape=cgi.escape):
return '"%s"' % escape(s, 1)
del cgi 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