Edgewall Software

Opened 3 years ago

Closed 23 months ago

Last modified 11 months ago

#566 closed defect (fixed)

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@…, jargon@…


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/"
          <h1 i18n:msg="name">text <a>$name</a></h1>
        gettext = lambda s: u'head [1:%(name)s] tail'
        translator = Translator(gettext)
          <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
  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 (1)

ticket566-genshi-0.6.x-r1238.diff (1.5 KB) - added by jomae 3 years ago.

Download all attachments as: .zip

Change History (10)

Changed 3 years ago by jomae

comment:1 Changed 3 years ago by jomae

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

comment:2 Changed 2 years ago by felix.schwarz@…

  • Cc felix.schwarz@… added

comment:3 Changed 23 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.

comment:4 Changed 23 months ago by hodgestar

  • Owner changed from cmlenz to hodgestar
  • Status changed from new to assigned

comment:5 Changed 23 months ago by hodgestar

  • Resolution set to fixed
  • Status changed from assigned to closed

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 :).

comment:6 Changed 21 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?

comment:7 Changed 21 months ago by hodgestar

New releases coming in the next week or so.

comment:8 Changed 15 months ago by dstoecker

Same issue here. Any new release coming?

comment:9 Changed 11 months ago by jargon@…

  • Cc jargon@… added

I'm also affected by this bug. Since Genshi 0.7 apparently will be in the upcoming Debian stable release ("Jessie"), I filed a bug there to cherry-pick r1243: 775746.

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain hodgestar.
The resolution will be deleted. Next status will be 'reopened'.

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

Note: See TracTickets for help on using tickets.