[stringtemplate-interest] Bug in PyST: fails to look for templates in supergroup [patch]
Roman Odaisky
roma at qwertty.com
Wed Aug 13 10:09:23 PDT 2008
Greetings,
I failed to find the proper place to report bugs for the Python version of
StringTemplate, so I’ll report it here.
PyST fails to look for templates in supergroups.
To reproduce:
mkdir -p /tmp/ST/sub
echo '$var:inner()$' >/tmp/ST/outer.st
echo 'it = $it$' >/tmp/ST/sub/inner.st
python <<E
from stringtemplate3 import StringTemplateGroup
stg_sub = StringTemplateGroup("brochure_common", "/tmp/ST/sub")
stg = StringTemplateGroup("brochure", "/tmp/ST", superGroup=stg_sub)
st = stg.getInstanceOf("outer")
st["var"] = "hello"
print str(st) # or unicode(st)
E
I get an error message (why doesn’t PyST propagate the original exception?!).
Expected: “it = hello”.
To fix: grep for “eek”, agree with the comment, place “return None” instead
of “raise”. Though it’s not a proper fix, because it would return None also
in the (rare) case “br.close()” throws an exception.
StringTemplateGroup.lookupTemplate expects loadTemplateFromBeneathRootDir to
return None in case the template file is not found, while the latter throws
an exception instead.
--
WBR
Roman.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2286 bytes
Desc: not available
Url : http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20080813/0fce4964/attachment.bin
More information about the stringtemplate-interest
mailing list