Edgewall Software
Modify

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#12748 closed defect (fixed)

ERROR: Macro Image(,) failed: IndexError: pop from empty list

Reported by: Ryan J Ollos Owned by: Ryan J Ollos
Priority: normal Milestone: 1.2.1
Component: wiki system Version:
Severity: normal Keywords: imagemacro
Cc: Branch:
Release Notes:

Fixed error when calling Image macro with no arguments: [[Image(,)]].

API Changes:
Internal Changes:

Description

2017-03-26 19:02:18,394 Trac[formatter] ERROR: Macro Image(,) failed:
Traceback (most recent call last):
  File "build/bdist.linux-x86_64/egg/trac/wiki/formatter.py", line 793, in _macro_formatter
    return macro.ensure_inline(macro.process(args))
  File "build/bdist.linux-x86_64/egg/trac/wiki/formatter.py", line 362, in process
    text = self.processor(text)
  File "build/bdist.linux-x86_64/egg/trac/wiki/formatter.py", line 349, in _macro_processor
    text)
  File "build/bdist.linux-x86_64/egg/trac/wiki/macros.py", line 539, in expand_macro
    filespec = args.pop(0)
IndexError: pop from empty list

Proposed fix:

  • trac/wiki/macros.py

    diff --git a/trac/wiki/macros.py b/trac/wiki/macros.py
    index ff502b567..71ec10467 100644
    a b class ImageMacro(WikiMacroBase):  
    538538    _quoted_re = re.compile("(?:[\"'])(.*)(?:[\"'])$")
    539539
    540540    def expand_macro(self, formatter, name, content):
     541        args = None
    541542        if content:
    542543            content = stripws(content)
    543         if not content:
     544            # parse arguments
     545            # we expect the 1st argument to be a filename (filespec)
     546            args = [stripws(arg) for arg
     547                                 in self._split_args_re.split(content)[1::2]]
     548        if not args:
    544549            return ''
    545         # parse arguments
    546         # we expect the 1st argument to be a filename (filespec)
    547         args = [stripws(arg) for arg
    548                              in self._split_args_re.split(content)[1::2]]
    549550        # strip unicode white-spaces and ZWSPs are copied from attachments
    550551        # section (#10668)
    551552        filespec = args.pop(0)

Attachments (0)

Change History (4)

comment:1 by Ryan J Ollos, 7 years ago

Owner: set to Ryan J Ollos
Release Notes: modified (diff)
Status: newassigned

comment:2 by Ryan J Ollos, 7 years ago

Resolution: fixed
Status: assignedclosed

Committed to 1.2-stable in r15711, merged to trunk in r15712.

comment:3 by markus@…, 7 years ago

Hi, the problem seems to persist in Version 1.2.2. This is the traceback I get when I try to upload an image:

Datei "build/bdist.linux-x86_64/egg/trac/web/main.py", Zeile 623, in _dispatch_request

dispatcher.dispatch(req)

Datei "build/bdist.linux-x86_64/egg/trac/web/main.py", Zeile 259, in dispatch

iterable=chrome.use_chunked_encoding)

Datei "build/bdist.linux-x86_64/egg/trac/web/chrome.py", Zeile 1165, in render_template

encoding='utf-8')

Datei "/home/markusbarth/webapps/acco3/lib/python2.7/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/core.py", Zeile 184, in render

return encode(generator, method=method, encoding=encoding, out=out)

Datei "/home/markusbarth/webapps/acco3/lib/python2.7/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/output.py", Zeile 58, in encode

for chunk in iterator:

Datei "/home/markusbarth/webapps/acco3/lib/python2.7/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/output.py", Zeile 350, in call

for kind, data, pos in stream:

Datei "/home/markusbarth/webapps/acco3/lib/python2.7/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/output.py", Zeile 829, in call

for kind, data, pos in stream:

Datei "/home/markusbarth/webapps/acco3/lib/python2.7/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/output.py", Zeile 669, in call

for kind, data, pos in stream:

Datei "/home/markusbarth/webapps/acco3/lib/python2.7/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/output.py", Zeile 774, in call

for kind, data, pos in chain(stream, [(None, None, None)]):

Datei "/home/markusbarth/webapps/acco3/lib/python2.7/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/output.py", Zeile 594, in call

for ev in stream:

Datei "/home/markusbarth/webapps/acco3/lib/python2.7/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/core.py", Zeile 289, in _ensure

for event in stream:

Datei "/home/markusbarth/webapps/acco3/lib/python2.7/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/core.py", Zeile 289, in _ensure

for event in stream:

Datei "build/bdist.linux-x86_64/egg/trac/web/chrome.py", Zeile 1432, in _strip_accesskeys

for kind, data, pos in stream:

Datei "/home/markusbarth/webapps/acco3/lib/python2.7/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/core.py", Zeile 289, in _ensure

for event in stream:

Datei "build/bdist.linux-x86_64/egg/trac/web/chrome.py", Zeile 1421, in _generate

for kind, data, pos in stream:

Datei "/home/markusbarth/webapps/acco3/lib/python2.7/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/template/base.py", Zeile 618, in _include

for event in stream:

Datei "/home/markusbarth/webapps/acco3/lib/python2.7/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/template/markup.py", Zeile 378, in _match

ctxt, start=idx + 1, vars):

Datei "/home/markusbarth/webapps/acco3/lib/python2.7/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/template/markup.py", Zeile 378, in _match

ctxt, start=idx + 1, vars):

Datei "/home/markusbarth/webapps/acco3/lib/python2.7/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/template/markup.py", Zeile 326, in _match

for event in stream:

Datei "/home/markusbarth/webapps/acco3/lib/python2.7/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/template/base.py", Zeile 558, in _flatten

for kind, data, pos in stream:

Datei "/home/markusbarth/webapps/acco3/lib/python2.7/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/core.py", Zeile 289, in _ensure

for event in stream:

Datei "/home/markusbarth/webapps/acco3/lib/python2.7/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/path.py", Zeile 588, in _generate

subevent = next()

Datei "/home/markusbarth/webapps/acco3/lib/python2.7/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/template/base.py", Zeile 618, in _include

for event in stream:

Datei "/home/markusbarth/webapps/acco3/lib/python2.7/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/template/markup.py", Zeile 315, in _strip

event = next()

Datei "/home/markusbarth/webapps/acco3/lib/python2.7/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/template/base.py", Zeile 558, in _flatten

for kind, data, pos in stream:

Datei "/home/markusbarth/webapps/acco3/lib/python2.7/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/core.py", Zeile 289, in _ensure

for event in stream:

Datei "/home/markusbarth/webapps/acco3/lib/python2.7/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/path.py", Zeile 588, in _generate

subevent = next()

Datei "/home/markusbarth/webapps/acco3/lib/python2.7/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/template/base.py", Zeile 618, in _include

for event in stream:

Datei "/home/markusbarth/webapps/acco3/lib/python2.7/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/template/markup.py", Zeile 315, in _strip

event = next()

Datei "/home/markusbarth/webapps/acco3/lib/python2.7/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/template/base.py", Zeile 558, in _flatten

for kind, data, pos in stream:

Datei "/home/markusbarth/webapps/acco3/lib/python2.7/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/filters/i18n.py", Zeile 178, in _generate

for event in msgbuf.translate(gettext(msgbuf.format())):

Datei "/home/markusbarth/webapps/acco3/lib/python2.7/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/filters/i18n.py", Zeile 1051, in translate

events = self.events[order].pop(0)

Version 0, edited 7 years ago by markus@… (next)

in reply to:  3 comment:4 by Jun Omae, 7 years ago

Replying to markus@…:

Hi, the problem seems to persist in Version 1.2.2. This is the traceback I get when I try to upload an image:

No. Your problem is a duplicate of #11184. See TracFaq#Q:WhydoIseeIndexError:popfromemptylistwhentryingtoaddanattachment.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Ryan J Ollos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.