mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Force use of non-unicode constants in compiled templates. Fixes a problem with regular expression character classes and probably other things.
This commit is contained in:
parent
06ae93270f
commit
3c04f699c3
@ -294,11 +294,11 @@ class _CompileParser(_Parser):
|
|||||||
self.parent_book, self.parent_locals, *args)
|
self.parent_book, self.parent_locals, *args)
|
||||||
elif self.token_is_constant():
|
elif self.token_is_constant():
|
||||||
# String or number
|
# String or number
|
||||||
v = self.token()
|
v = unicode(self.token())
|
||||||
if self.compile_text:
|
if self.compile_text:
|
||||||
tv = v.replace("\\", "\\\\")
|
tv = v.replace("\\", "\\\\")
|
||||||
tv = tv.replace("'", "\\'")
|
tv = tv.replace("'", "\\'")
|
||||||
self.compile_text += "\targs[%d].append('%s')\n"%(level, tv)
|
self.compile_text += "\targs[%d].append(unicode('%s'))\n"%(level, tv)
|
||||||
return v
|
return v
|
||||||
else:
|
else:
|
||||||
self.error(_('expression is not function or constant'))
|
self.error(_('expression is not function or constant'))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user