We recently hit a problem with use of Python 2.4 under
Zope.
#The problem is that warnings.py expects that function
warn_explicit is called with either module or filename
beeing a string.
This is not always true, especially when the warning is
caused by a Python script, e.g. a non-ASCII character
without encoding declaration
causing a "Non-ASCII character ... in file ... on line
..., but no encoding declared; see ..."
the slice operation 'if module[-3:].lower() == ".py":'
in line 64 (Python 2.4.1) or 67 (Python 2.4.2)
causes a TypeError: unsubscriptable object because both
module and filename are None.
The original warning message that would be very helpful
gets lost and is replaced by a misterious TypeError
that is hard to find unless debugging and stepping into
the Python runtime.
There would be a simple fix by modifing the assignment
in the line above from
module = filename
to
module = filename or "(unknown)"
we found also bugtracker entry [ 890010 ] "Odd warning
behaviors" that is similar but
has a completely different focus. Could someone please
fix this problem either with the fix above
or something better?
|