Hi, I find a few string exceptions leftover in Zope 2.13 code. However, they are not allowed anymore in Python 2.6. I guess that the remaining string exceptions are in dead/semidead code. What practice has been followed until now regarding fixing those exceptions ? Regards -- Godefroid Chapelle (aka __gotcha) http://bubblenet.be
Hi. On Fri, Feb 25, 2011 at 11:58 AM, Godefroid Chapelle <gotcha@bubblenet.be> wrote:
I find a few string exceptions leftover in Zope 2.13 code.
What practice has been followed until now regarding fixing those exceptions ?
Just upgrade them to new-style exception classes. Since string exceptions cannot possibly work anymore, we cannot make things worse by fixing them. Hanno
Le 25/02/11 12:03, Hanno Schlichting a écrit :
I find a few string exceptions leftover in Zope 2.13 code.
What practice has been followed until now regarding fixing those exceptions ?
Just upgrade them to new-style exception classes. Since string exceptions cannot possibly work anymore, we cannot make things worse by fixing them.
Hanno
What about deciding to kill that code ? I guess it is a bit early because not enough people did migrate to 2.12 or later. Where should those fixes happen ? 2.13 branch and trunk I suppose -- Godefroid Chapelle (aka __gotcha) http://bubblenet.be
On 25 February 2011 11:14, Godefroid Chapelle <gotcha@bubblenet.be> wrote:
Le 25/02/11 12:03, Hanno Schlichting a écrit :
I find a few string exceptions leftover in Zope 2.13 code.
What practice has been followed until now regarding fixing those exceptions ?
Just upgrade them to new-style exception classes. Since string exceptions cannot possibly work anymore, we cannot make things worse by fixing them.
Hanno
What about deciding to kill that code ?
I guess it is a bit early because not enough people did migrate to 2.12 or later.
These statements now raise a TypeError instead of a string exceotion, which in most cases should be functionally equivalent. There's no guarantee that the code is dead.
Where should those fixes happen ?
2.13 branch and trunk I suppose
This seems sensible. Laurence
On Fri, Feb 25, 2011 at 12:14 PM, Godefroid Chapelle <gotcha@bubblenet.be> wrote:
Where should those fixes happen ?
2.13 branch and trunk I suppose
+1 - if you really feel like it you could backport to 2.12 branch as well (as it only supports Python 2.6 too). Hanno
Am 25.02.2011, 12:26 Uhr, schrieb Hanno Schlichting <hanno@hannosch.eu>:
+1 - if you really feel like it you could backport to 2.12 branch as well (as it only supports Python 2.6 too).
- 1 against backporting unless you are experiencing the errors on a 2.12 based system. Charlie -- Charlie Clark Managing Director Clark Consulting & Research German Office Helmholtzstr. 20 Düsseldorf D- 40215 Tel: +49-211-600-3657 Mobile: +49-178-782-6226
On Fri, Feb 25, 2011 at 12:32 PM, Charlie Clark <charlie.clark@clark-consulting.eu> wrote:
Am 25.02.2011, 12:26 Uhr, schrieb Hanno Schlichting <hanno@hannosch.eu>:
+1 - if you really feel like it you could backport to 2.12 branch as well (as it only supports Python 2.6 too).
- 1 against backporting unless you are experiencing the errors on a 2.12 based system.
Nobody experienced the problems yet, that's why it might be dead code. But the issue affects Zope 2.12 as much as 2.13 - both require a minimum of Python 2.6, which doesn't support string exceptions anymore. Hanno
On Feb 25, 2011, at 6:38 AM, Hanno Schlichting wrote:
On Fri, Feb 25, 2011 at 12:32 PM, Charlie Clark <charlie.clark@clark-consulting.eu> wrote:
Am 25.02.2011, 12:26 Uhr, schrieb Hanno Schlichting <hanno@hannosch.eu>:
+1 - if you really feel like it you could backport to 2.12 branch as well (as it only supports Python 2.6 too).
- 1 against backporting unless you are experiencing the errors on a 2.12 based system.
Nobody experienced the problems yet, that's why it might be dead code.
But the issue affects Zope 2.12 as much as 2.13 - both require a minimum of Python 2.6, which doesn't support string exceptions anymore.
Hanno
FWIW, I'm seeing this sort of error in the Plone 4.0 nightlies with Zope 2.12.16.
... File "/Users/ems174/projects/plone4dev/src/Products.CMFCore/Products/CMFCore/MemberDataTool.py", line 267, in getUser raise 'MemberDataError', "Can't find user data" TypeError: exceptions must be old-style classes or derived from BaseException, not str
Eric
On 25 February 2011 10:58, Godefroid Chapelle <gotcha@bubblenet.be> wrote:
Hi,
I find a few string exceptions leftover in Zope 2.13 code.
However, they are not allowed anymore in Python 2.6.
I guess that the remaining string exceptions are in dead/semidead code.
What practice has been followed until now regarding fixing those exceptions ?
According to this doc, http://docs.python.org/c-api/exceptions.html#deprecation-of-string-exception... "String exceptions are still supported in the interpreter to allow existing code to run unmodified, but this will also change in a future release." It will of course be important to fix these before we move to Python 3.x, but I would expect that the dead/semidead code will not be ported. Laurence
On 25 February 2011 11:03, Laurence Rowe <l@lrowe.co.uk> wrote:
On 25 February 2011 10:58, Godefroid Chapelle <gotcha@bubblenet.be> wrote:
Hi,
I find a few string exceptions leftover in Zope 2.13 code.
However, they are not allowed anymore in Python 2.6.
I guess that the remaining string exceptions are in dead/semidead code.
What practice has been followed until now regarding fixing those exceptions ?
According to this doc, http://docs.python.org/c-api/exceptions.html#deprecation-of-string-exception...
"String exceptions are still supported in the interpreter to allow existing code to run unmodified, but this will also change in a future release."
It will of course be important to fix these before we move to Python 3.x, but I would expect that the dead/semidead code will not be ported.
I take that back, that documentation is incorrect, they have indeed stopped working. Laurence
On Fri, Feb 25, 2011 at 12:05, Laurence Rowe <l@lrowe.co.uk> wrote:
I take that back, that documentation is incorrect, they have indeed stopped working.
You are allowed to catch them, but not raise them. This is so you can have code that runs on old Pythons with old libraries still. But in any case I think we safely can move them to ordinary exceptions.
Le 25/02/11 12:03, Laurence Rowe a écrit :
On 25 February 2011 10:58, Godefroid Chapelle<gotcha@bubblenet.be> wrote:
Hi,
I find a few string exceptions leftover in Zope 2.13 code.
However, they are not allowed anymore in Python 2.6.
I guess that the remaining string exceptions are in dead/semidead code.
What practice has been followed until now regarding fixing those exceptions ?
According to this doc, http://docs.python.org/c-api/exceptions.html#deprecation-of-string-exception...
"String exceptions are still supported in the interpreter to allow existing code to run unmodified, but this will also change in a future release."
It will of course be important to fix these before we move to Python 3.x, but I would expect that the dead/semidead code will not be ported.
Laurence
I just tried to run the code hereunder with Python 2.6.5: def main(): raise "Abc" main() This is what I get : Traceback (most recent call last): File "test.py", line 4, in <module> main() File "test.py", line 2, in main raise "Abc" TypeError: exceptions must be old-style classes or derived from BaseException, not str I am not sure what the documentation above means but it seems to be text that was not fixed... -- Godefroid Chapelle (aka __gotcha) http://bubblenet.be
On 25 February 2011 11:09, Godefroid Chapelle <gotcha@bubblenet.be> wrote:
Le 25/02/11 12:03, Laurence Rowe a écrit :
On 25 February 2011 10:58, Godefroid Chapelle<gotcha@bubblenet.be> wrote:
Hi,
I find a few string exceptions leftover in Zope 2.13 code.
However, they are not allowed anymore in Python 2.6.
I guess that the remaining string exceptions are in dead/semidead code.
What practice has been followed until now regarding fixing those exceptions ?
According to this doc,
http://docs.python.org/c-api/exceptions.html#deprecation-of-string-exception...
"String exceptions are still supported in the interpreter to allow existing code to run unmodified, but this will also change in a future release."
It will of course be important to fix these before we move to Python 3.x, but I would expect that the dead/semidead code will not be ported.
Laurence
I just tried to run the code hereunder with Python 2.6.5:
def main(): raise "Abc"
main()
This is what I get :
Traceback (most recent call last): File "test.py", line 4, in <module> main() File "test.py", line 2, in main raise "Abc" TypeError: exceptions must be old-style classes or derived from BaseException, not str
I am not sure what the documentation above means but it seems to be text that was not fixed...
Reported in http://bugs.python.org/issue11317 Laurence
participants (6)
-
Charlie Clark -
Eric Steele -
Godefroid Chapelle -
Hanno Schlichting -
Laurence Rowe -
Lennart Regebro