This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: TypeError unsubscriptable object caused by warnings.py
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: freyp_haufe, georg.brandl, pterk
Priority: normal Keywords:

Created on 2006-01-11 23:01 by freyp_haufe, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg27284 - (view) Author: FreyP (freyp_haufe) Date: 2006-01-11 23:01
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?
msg27285 - (view) Author: Peter van Kampen (pterk) Date: 2006-01-13 00:39
Logged In: YES 
user_id=174455

See patch: 1404357
http://sourceforge.net/tracker/index.php?func=detail&aid=1404357&group_id=5470&atid=305470
msg27286 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-01-13 17:01
Logged In: YES 
user_id=1188172

Committed patch as revisions 42028,42029.
History
Date User Action Args
2022-04-11 14:56:14adminsetgithub: 42790
2006-01-11 23:01:49freyp_haufecreate