[ python-Bugs-1510580 ] Setting category fails with -W switch
SourceForge.net
noreply at sourceforge.net
Thu Jun 22 18:13:10 CEST 2006
Bugs item #1510580, was opened at 2006-06-22 05:20
Message generated for change (Comment added) made by bcannon
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1510580&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.5
Status: Open
Resolution: None
Priority: 5
Submitted By: A.M. Kuchling (akuchling)
Assigned to: Brett Cannon (bcannon)
Summary: Setting category fails with -W switch
Initial Comment:
This command reports an "invalid warning category"
error, but it shouldn't.
./python -W'ignore:Not importing directory:ImportWarning'
I think the change to new-style exceptions exposed this
problem. warnings.py contains the following code to
trigger this error:
if (not isinstance(cat, types.ClassType) or
not issubclass(cat, Warning)):
raise _OptionError("invalid warning category:
%r" % (category,))
The new-style exceptions mean that the first
isinstance() now returns False. I think there may be
two fixes needed. First, I think it should be
"isinstance(cat, types.ClassType) or isinstance(cat,
type)".
Second issue: hould the warnings.py code use "and"
instead of "or"? Surely if issubclass(cat, Warning) is
True, the category is certainly OK; no?
----------------------------------------------------------------------
>Comment By: Brett Cannon (bcannon)
Date: 2006-06-22 09:13
Message:
Logged In: YES
user_id=357491
Turns out Armin's r47061 checkin fixed it; for some reason I
had not rebuilt. Doing a distclean and re-running tests
before committing the change.
----------------------------------------------------------------------
Comment By: Brett Cannon (bcannon)
Date: 2006-06-22 09:05
Message:
Logged In: YES
user_id=357491
Well, the docs for warnings
(http://docs.python.org/dev/lib/warning-categories.html) say
that a category must subclass Warning. So I removed the
ClassType check entirely, and that causes test_exceptions to
segfault. Lovely.
I will try to look at this Friday.
----------------------------------------------------------------------
Comment By: A.M. Kuchling (akuchling)
Date: 2006-06-22 06:50
Message:
Logged In: YES
user_id=11375
Once the problem is fixed, the attached patch adds some
tests for warning parsing.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1510580&group_id=5470
More information about the Python-bugs-list
mailing list