comparison roundup/cgi/TAL/TALInterpreter.py @ 5377:12fe83f90f0d

Python 3 preparation: use repr() instead of ``. Tool-generated patch.
author Joseph Myers <jsm@polyomino.org.uk>
date Tue, 24 Jul 2018 21:36:02 +0000
parents 8c2402a78bb0
children 35ea9b1efc14
comparison
equal deleted inserted replaced
5376:64b05e24dbd8 5377:12fe83f90f0d
74 text = text.replace(string, subst) 74 text = text.replace(string, subst)
75 except UnicodeError: 75 except UnicodeError:
76 # subst contains high-bit chars... 76 # subst contains high-bit chars...
77 # As we have no way of knowing the correct encoding, 77 # As we have no way of knowing the correct encoding,
78 # substitue something instead of raising an exception. 78 # substitue something instead of raising an exception.
79 subst = `subst`[1:-1] 79 subst = repr(subst)[1:-1]
80 text = text.replace(string, subst) 80 text = text.replace(string, subst)
81 return text 81 return text
82 82
83 83
84 class AltTALGenerator(TALGenerator): 84 class AltTALGenerator(TALGenerator):
177 assert self.scopeLevel == scopeLevel 177 assert self.scopeLevel == scopeLevel
178 178
179 def pushMacro(self, macroName, slots, entering=1): 179 def pushMacro(self, macroName, slots, entering=1):
180 if len(self.macroStack) >= self.stackLimit: 180 if len(self.macroStack) >= self.stackLimit:
181 raise METALError("macro nesting limit (%d) exceeded " 181 raise METALError("macro nesting limit (%d) exceeded "
182 "by %s" % (self.stackLimit, `macroName`)) 182 "by %s" % (self.stackLimit, repr(macroName)))
183 self.macroStack.append([macroName, slots, entering, self.i18nContext]) 183 self.macroStack.append([macroName, slots, entering, self.i18nContext])
184 184
185 def popMacro(self): 185 def popMacro(self):
186 return self.macroStack.pop() 186 return self.macroStack.pop()
187 187
653 if macro is self.Default: 653 if macro is self.Default:
654 macro = block 654 macro = block
655 else: 655 else:
656 if not isCurrentVersion(macro): 656 if not isCurrentVersion(macro):
657 raise METALError("macro %s has incompatible version %s" % 657 raise METALError("macro %s has incompatible version %s" %
658 (`macroName`, `getProgramVersion(macro)`), 658 (repr(macroName), repr(getProgramVersion(macro))),
659 self.position) 659 self.position)
660 mode = getProgramMode(macro) 660 mode = getProgramMode(macro)
661 if mode != (self.html and "html" or "xml"): 661 if mode != (self.html and "html" or "xml"):
662 raise METALError("macro %s has incompatible mode %s" % 662 raise METALError("macro %s has incompatible mode %s" %
663 (`macroName`, `mode`), self.position) 663 (repr(macroName), repr(mode)), self.position)
664 self.pushMacro(macroName, compiledSlots) 664 self.pushMacro(macroName, compiledSlots)
665 prev_source = self.sourceFile 665 prev_source = self.sourceFile
666 self.interpret(macro) 666 self.interpret(macro)
667 if self.sourceFile != prev_source: 667 if self.sourceFile != prev_source:
668 self.engine.setSourceFile(prev_source) 668 self.engine.setSourceFile(prev_source)

Roundup Issue Tracker: http://roundup-tracker.org/