Edgewall Software
Modify

Opened 8 years ago

Closed 8 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, 8 years ago

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

comment:2 by Ryan J Ollos, 8 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:

...
  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)
Last edited 7 years ago by Jun Omae (previous) (diff)

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.