Modify

Opened 2 years ago

Closed 5 weeks ago

Last modified 5 weeks 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:

Description

Traceback (most recent call last):
  File "/somepath/trac/trac/mimeview/api.py", line 795, in render
    rendered_content, filename, url)
  File "/somepath/trac-plugins/graphviz-plugin/graphviz/graphviz.py", 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/graphviz.py#L199

Trac version is 1.1.3

Attachments (0)

Change History (7)

comment:1 Changed 5 weeks ago by anonymous

Still a problem with Trac 1.3.3dev, graphviz plugin 1.3.0.1dev

comment:2 Changed 5 weeks ago by Jun Omae

Could you try the following patch?

  • graphvizplugin/trunk/graphviz/graphviz.py

    diff --git a/graphvizplugin/trunk/graphviz/graphviz.py b/graphvizplugin/trunk/graphviz/graphviz.py
    index b2e8385e0..6a3d6bca5 100644
    a b class Graphviz(Component): 
    198198        return 0
    199199
    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 = content.read() if hasattr(content, 'read') else content
    204205        return self.expand_macro(context, name, text)
    205206

comment:3 Changed 5 weeks 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 5 weeks ago by Ryan J Ollos

In 17295:

1.0.0.8dev: Avoid AttributeError

Patch by Jun Omae.

Refs #12825.

comment:5 Changed 5 weeks ago by Ryan J Ollos

In 17296:

1.0.0.9dev: Avoid AttributeError

Merge of r17295 from 1.0 branch.

Refs #12825.

comment:6 Changed 5 weeks ago by Ryan J Ollos

Resolution: fixed
Status: newclosed

In 17297:

1.3.0.1dev: Avoid AttributeError

Merge of r17296 from 1.2 branch.

Fixes #12825.

comment:7 Changed 5 weeks ago by Ryan J Ollos

Owner: changed from Christian Boos to Jun Omae

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted.

Add Comment


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

 
Note: See TracTickets for help on using tickets.