Opened 4 years ago

Closed 20 months ago

Last modified 20 months ago

#12825 closed defect (fixed)

`Graphviz.render()` does not work with the default value for `filename`

Reported by: ebouaziz@… Owned by: Jun Omae
Priority: normal Component: GraphvizPlugin
Severity: normal Keywords:
Cc: Trac Release:


Traceback (most recent call last):
  File "/somepath/trac/trac/mimeview/", line 795, in render
    rendered_content, filename, url)
  File "/somepath/trac-plugins/graphviz-plugin/graphviz/", line 200, in render
    ext = filename.split('.')[1]
AttributeError: 'NoneType' object has no attribute 'split'

The default value for filename is None: graphvizplugin/trunk/graphviz/

Trac version is 1.1.3

Attachments (0)

Change History (7)

comment:1 Changed 20 months ago by anonymous

Still a problem with Trac 1.3.3dev, graphviz plugin

comment:2 Changed 20 months ago by Jun Omae

Could you try the following patch?

  • graphvizplugin/trunk/graphviz/

    diff --git a/graphvizplugin/trunk/graphviz/ b/graphvizplugin/trunk/graphviz/
    index b2e8385e0..6a3d6bca5 100644
    a b class Graphviz(Component): 
    198198        return 0
    200200    def render(self, context, mimetype, content, filename=None, url=None):
    201         ext = filename.split('.')[1]
    202         name = 'graphviz' if ext == 'graphviz' else 'graphviz.%s' % ext
     201        ext = filename.split('.')[1] if filename else None
     202        name = 'graphviz' if not ext or ext == 'graphviz' \
     203               else 'graphviz.%s' % ext
    203204        text = if hasattr(content, 'read') else content
    204205        return self.expand_macro(context, name, text)

comment:3 Changed 20 months ago by anonymous

Seems to work. (But I don't know the exact scenario where filename is None. I just found the error in the logfile without much context.)

comment:4 Changed 20 months ago by Ryan J Ollos

In 17295: Avoid AttributeError

Patch by Jun Omae.

Refs #12825.

comment:5 Changed 20 months ago by Ryan J Ollos

In 17296: Avoid AttributeError

Merge of r17295 from 1.0 branch.

Refs #12825.

comment:6 Changed 20 months ago by Ryan J Ollos

Resolution: fixed
Status: newclosed

In 17297: Avoid AttributeError

Merge of r17296 from 1.2 branch.

Fixes #12825.

comment:7 Changed 20 months ago by Ryan J Ollos

Owner: changed from Christian Boos to Jun Omae

Modify Ticket

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

Add Comment

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

Note: See TracTickets for help on using tickets.