[Python-Dev] Deprecating string exceptions (original) (raw)
Jeremy Hylton jeremy@zope.com
Fri, 5 Apr 2002 18:51:48 -0500
- Previous message: [Python-Dev] Array Enhancements
- Next message: [Python-Dev] Deprecating string exceptions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"MvL" == Martin v Loewis <martin@v.loewis.de> writes:
MvL> http://python.org/sf/518846 reports that new-style classes MvL> cannot be used as exceptions. I think it is desirable that this MvL> is fixed, but I also believe that it conflicts with string MvL> exceptions. So I would like to propose that string exceptions MvL> are deprecated for Python 2.3, in order to remove them in MvL> Python 2.4, simultaneously allowing arbitrary objects as MvL> exceptions.
I didn't read most of this length thread the first time through, but I did run into the bug today in my own code and tried to fix it. I added a patch to 518846 that allows instances of new style classes, where the check is implemented by checking Py_TPFLAGS_HEAPTYPE, which is only defined for objects created by class statements (I think).
This doesn't seem to cause any change in the behavior of string-based exceptions. I don't think it's necessary to have "except str:" catch string-based exceptions, because they're supported solely for backwards compatibility.
There was also some discussion of making exceptions inherit from Exception, but I think that's a separate issue.
Any reason not to commit the patch?
Jeremy
- Previous message: [Python-Dev] Array Enhancements
- Next message: [Python-Dev] Deprecating string exceptions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]