Alexander Belopolsky <[EMAIL PROTECTED]> added the comment:
I thought some more about this issue and the current behavior seems
wrong and potentially dangerous. Consider the following code:
class x:
pass
class y(x):
pass
try:
raise y
except y:
print "a"
except:
print "b"
It prints 'b'. Now, suppose in preparation for 3.0 transition someone
adds "__metaclass__ = type" to the module with that code. The result:
it prints 'a'. Since the difference in behavior is in error handling
code, which in my experience is often not thoroughly tested, the bug
introduced by a seemingly innocuous move from old to new style classes
is likely to trigger in the worst possible moment. (For example a wrong
roll-back logic is applied after a failed database commit.)
My understanding is that the current logic of bypassing the subclass
check in PyErr_GivenExceptionMatches in the case of new style class
which is not a subclass of BaseException, is designed to support string
exceptions. Maybe a better choice would be to exclude only string
subclasses from a subclass check.
I will submit a patch if others agree that this approach is worth
considering.
__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2291>
__________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com