Edgewall Software

Ticket #566 (closed defect: fixed)

Opened 18 months ago

Last modified 6 weeks ago

IndexError: pop from empty list with i18n:msg on Genshi 0.6.1

Reported by: jomae Owned by: hodgestar
Priority: major Milestone: 0.6.2
Component: Template processing Version: 0.6
Keywords: Cc: felix.schwarz@…

Description

This issue is originally reported at  trac:#11184.

When an element with i18n:msg attribute has last element which has $var as contents and it is translated with "aaa [1:%(name)s] zzz", got IndexError: pop from empty list.

    def test_translate_i18n_msg_ticket_404_regression(self):
        tmpl = MarkupTemplate("""<html xmlns:py="http://genshi.edgewall.org/"
            xmlns:i18n="http://genshi.edgewall.org/i18n">
          <h1 i18n:msg="name">text <a>$name</a></h1>
        </html>""")
        gettext = lambda s: u'head [1:%(name)s] tail'
        translator = Translator(gettext)
        translator.setup(tmpl)
        self.assertEqual("""<html>
          <h1>head <a>NAME</a> tail</h1>
        </html>""", tmpl.generate(name='NAME').render())
Traceback (most recent call last):
  File "genshi/filters/tests/i18n.py", line 918, in test_translate_i18n_msg_ticket_404_regression
    self.assertEqual("""<html>
  File "/home/jun66j5/src/genshi/hg/genshi/core.py", line 183, in render
    return encode(generator, method=method, encoding=encoding, out=out)
  File "/home/jun66j5/src/genshi/hg/genshi/output.py", line 57, in encode
    return _encode(''.join(list(iterator)))
  File "/home/jun66j5/src/genshi/hg/genshi/output.py", line 241, in __call__
    for kind, data, pos in stream:
  File "/home/jun66j5/src/genshi/hg/genshi/output.py", line 669, in __call__
    for kind, data, pos in stream:
  File "/home/jun66j5/src/genshi/hg/genshi/output.py", line 774, in __call__
    for kind, data, pos in chain(stream, [(None, None, None)]):
  File "/home/jun66j5/src/genshi/hg/genshi/output.py", line 594, in __call__
    for ev in stream:
  File "/home/jun66j5/src/genshi/hg/genshi/core.py", line 288, in _ensure
    for event in stream:
  File "/home/jun66j5/src/genshi/hg/genshi/template/base.py", line 617, in _include
    for event in stream:
  File "/home/jun66j5/src/genshi/hg/genshi/template/markup.py", line 326, in _match
    for event in stream:
  File "/home/jun66j5/src/genshi/hg/genshi/template/base.py", line 557, in _flatten
    for kind, data, pos in stream:
  File "/home/jun66j5/src/genshi/hg/genshi/filters/i18n.py", line 177, in _generate
    for event in msgbuf.translate(gettext(msgbuf.format())):
  File "/home/jun66j5/src/genshi/hg/genshi/filters/i18n.py", line 1044, in translate
    events = self.events[order].pop(0)
IndexError: pop from empty list

Attachments

ticket566-genshi-0.6.x-r1238.diff Download (1.5 KB) - added by jomae 18 months ago.

Change History

Changed 18 months ago by jomae

Changed 18 months ago by jomae

I created the patch, ticket566-genshi-0.6.x-r1238.diff Download. All tests pass.

Changed 14 months ago by felix.schwarz@…

  • cc felix.schwarz@… added

Changed 10 months ago by dstoecker

Any reason not to apply this? I've the same issue  http://trac.edgewall.org/ticket/11184. I have 0.7 installed.

Changed 10 months ago by hodgestar

  • status changed from new to assigned
  • owner changed from cmlenz to hodgestar

Changed 10 months ago by hodgestar

  • status changed from assigned to closed
  • resolution set to fixed

Fix in r1242 with a very slightly revised patch. Backported to 0.7.x and 0.6.x in r1243 and r1244 respectively. Thanks for the patch (and the prodding by various people :).

Changed 8 months ago by derhelge

Is it possible to update  http://ftp.edgewall.com/pub/genshi/Genshi-0.7.tar.gz and also the complete download-page?

Changed 8 months ago by hodgestar

New releases coming in the next week or so.

Changed 6 weeks ago by dstoecker

Same issue here. Any new release coming?

Add/Change #566 (IndexError: pop from empty list with i18n:msg on Genshi 0.6.1)

Author


E-mail address and user name can be saved in the Preferences.


Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.