Opened 17 years ago
Closed 17 years ago
#181 closed defect (fixed)
Variables in outer scopes not visible in python code blocks in for loops in python 2.3
Reported by: | jondreads@… | Owned by: | cmlenz |
---|---|---|---|
Priority: | minor | Milestone: | 0.5 |
Component: | Documentation | Version: | 0.4.4 |
Keywords: | Cc: |
Description
Example code:
>>> from genshi.template import MarkupTemplate >>> print MarkupTemplate(""" ... <div xmlns:py="http://genshi.edgewall.org/" py:for="i in range(2)"> ... <div py:for="j in range(2)"> ... <?python ... print i, j ... ?> ... ${i} ${j} ... </div> ... </div> ... """).generate().render()
In python 2.5 and 2.4 on Windows, using genshi 0.4.4 the output is:
0 0 0 1 1 0 1 1 <div> <div> 0 0 </div><div> 0 1 </div> </div><div> <div> 1 0 </div><div> 1 1 </div> </div>
On python 2.3, using 0.4.4 the output is:
undefined 0 undefined 1 undefined 0 undefined 1 <div> <div> 0 0 </div><div> 0 1 </div> </div><div> <div> 1 0 </div><div> 1 1 </div> </div>
Change History (2)
comment:1 Changed 17 years ago by cmlenz
- Component changed from General to Documentation
- Priority changed from major to minor
- Status changed from new to assigned
comment:2 Changed 17 years ago by cmlenz
- Resolution set to fixed
- Status changed from assigned to closed
Warning added to docs in [808].
Note: See
TracTickets for help on using
tickets.
Yeah, this doesn't work in Python 2.3 because the exec statement requires a real dict object, not something pretending to be a dict, like the template context.
I think this can simply not be properly supported on Python 2.3, so I'll just add a note to the docs.