[ python-Bugs-1403410 ] TypeError unsubscriptable object caused by warnings.py

SourceForge.net noreply at sourceforge.net
Thu Jan 12 00:01:49 CET 2006


Bugs item #1403410, was opened at 2006-01-12 00:01
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1403410&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: FreyP (freyp_haufe)
Assigned to: Nobody/Anonymous (nobody)
Summary: TypeError unsubscriptable object caused by warnings.py

Initial Comment:
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?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1403410&group_id=5470


More information about the Python-bugs-list mailing list