Skip to content

Commit a2918d4

Browse files
committed
fix: cgitb crashes if there is no line number set.
I am not sure why: context.position[0] is None when an exception happens while processing templates. This causes a second exception because of a print statement matching %d to None. The second exception blows away any chance at getting useful info. So fix it by passing line number -1. Hopefully people will recognize that as bogus and interpret it as no line number was available. Fixing the underlying cause (in ZopeTAL???) would be better though.
1 parent a8a2610 commit a2918d4

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGES.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ Fixed:
100100
request.client.additional_headers) to application/json and return
101101
json from the template. This json could access the 1i18n functions
102102
for a javascript helper. (John Rouillard)
103+
- when template processing raises an exception the line number is
104+
sometimes missing. This causes cgitb to raise a second exception
105+
which clobbers the info about the template issue. As a stop-gap set
106+
the line number to -1 so the original traceback can be seen. This
107+
could be a bug in ZopeTAL. (John Rouillard)
103108

104109
Features:
105110

roundup/cgi/cgitb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def pt_html(context=5, i18n=None):
104104
</table></li>
105105
''') % {
106106
'info': info,
107-
'line': context.position[0],
107+
'line': context.position[0] or -1,
108108
'globals': niceDict(' ', context.global_vars),
109109
'locals': niceDict(' ', context.local_vars)
110110
})

0 commit comments

Comments
 (0)