Edgewall Software

Opened 16 years ago

Closed 16 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 16 years ago by cmlenz

  • Component changed from General to Documentation
  • Priority changed from major to minor
  • Status changed from new to assigned

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.

comment:2 Changed 16 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.