Opened 17 years ago
Last modified 17 years ago
#227 reopened defect
syntax error on os.walk
Reported by: | mats_a@… | Owned by: | cmlenz |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | Template processing | Version: | devel |
Keywords: | Cc: |
Description
<?python
import os
for root,dirs,files in os.walk():
print root
?>
This should work fine, but it throws a template syntax error
...[snip]...
File "build/bdist.linux-i686/egg/genshi/template/loader.py", line 259, in _instantiate
allow_exec=self.allow_exec)
File "build/bdist.linux-i686/egg/genshi/template/base.py", line 373, in init
self.stream = list(self._prepare(self._parse(source, encoding)))
File "build/bdist.linux-i686/egg/genshi/template/markup.py", line 206, in _parse
pos[2] + (err.offset or 0))
TemplateSyntaxError?: invalid syntax (/home/mats/documents/....../myfile.html, line 54)
Change History (2)
comment:1 Changed 17 years ago by cmlenz
- Component changed from General to Template processing
- Milestone 0.5 deleted
- Resolution set to worksforme
- Status changed from new to closed
comment:2 Changed 17 years ago by mats_a@…
- Resolution worksforme deleted
- Status changed from closed to reopened
Reopening. I actually had a root element (otherwise wouldn't Genshi fail to work at all?).
It just seems that a syntax error is being thrown for no reason. It works perfectly fine in a python interpreter.
This <?python ... ?> block was inside of a <head py:match="head"></head> tag using the normal Genshi example.
Further testing:
- No syntax error results if it is NOT put in the <head> tag, but rather as a child of <html>. This seems to be a workaround for those who are interested.
- file is not defined inside a Genshi template (another bug?)
- You might need to do os.walk(somepath) (that is however not the issue)
An XML document needs a root element. If you just have that PI in a template, that's not well-formed XML.
After adding a root element, this works fine for me, so I'm closing this as worksforme. Please reopen if you actually had a root element, and it didn't work.