﻿id,summary,reporter,owner,description,type,status,priority,component,severity,resolution,keywords,cc,release
10709,Exception while rendering a diff file,rjollos,ejucovy,"I was investigating [https://issues.apache.org/bloodhound/ticket/308#comment:3 Bloodhound issue #308], and trying to determine why `.patch` files rendered with syntax highlighting, but `.diff` files did not. The issue I'm reporting here appears to be unrelated. During the rendering of `.diff` files I saw the following traceback:
{{{
Traceback (most recent call last):
  File ""/home/user/Workspace/bloodhound/trac/trac/web/main.py"", line 497, in _dispatch_request
    dispatcher.dispatch(req)
  File ""/home/user/Workspace/bloodhound/trac/trac/web/main.py"", line 236, in dispatch
    self._post_process_request(req)
  File ""/home/user/Workspace/bloodhound/trac/trac/web/main.py"", line 340, in _post_process_request
    f.post_process_request(req, *(None,)*extra_arg_count)
  File ""/home/user/Workspace/trac-hacks/permredirectplugin/trunk/permredirect/filter.py"", line 59, in post_process_request
    if issubclass(exctype, PermissionError):
TypeError: issubclass() arg 1 must be a class
}}}

Full traceback is attached. To reproduce, attach a file ending in `.diff` to a ticket and then view the file. You may be able to reproduce under other circumstances as well ... I haven't investigated thoroughly.

I'm not sure what the correct fix is, but the following patch makes the exception go away:
{{{
#!patch
Index: permredirectplugin/trunk/permredirect/filter.py
===================================================================
--- permredirectplugin/trunk/permredirect/filter.py	(revision 12442)
+++ permredirectplugin/trunk/permredirect/filter.py	(working copy)
@@ -56,7 +56,7 @@
                 ref_url = ref_url + ""?"" + req.query_string
             login_url = req.href.login(referer=ref_url)
 
-            if issubclass(exctype, PermissionError):
+            if exctype and issubclass(exctype, PermissionError):
                 req.redirect(login_url)
             
             try:
}}}",defect,closed,normal,PermRedirectPlugin,normal,fixed,,,1.0
