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

SourceForge.net noreply at sourceforge.net
Fri Jan 13 01:39:13 CET 2006


Bugs item #1403410, was opened at 2006-01-12 00:01
Message generated for change (Comment added) made by pterk
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?

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

Comment By: Peter van Kampen (pterk)
Date: 2006-01-13 01:39

Message:
Logged In: YES 
user_id=174455

See patch: 1404357
http://sourceforge.net/tracker/index.php?func=detail&aid=1404357&group_id=5470&atid=305470

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

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