Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: Dev

Deprecation Warning

 

 

Zope dev RSS feed   Index | Next | Previous | View Threaded


vyshakh.krishnan at gmail

Jul 23, 2008, 5:03 AM

Post #1 of 10 (527 views)
Permalink
Deprecation Warning

Hi everybody,


While porting Zope2 on Python2.5, I am now trying to remove the
deprecation warnings.Most of them are due to the raising of string
exceptions. One of such warnings in the module Products is

/home/zope/ztrunk25/lib/python/OFS/SimpleItem.py:248:
DeprecationWarning: raising a string exception is deprecated
raise error_type, v, tb

These warnings can be removed by changing these string exceptions to
class based exceptions.
Can anyone suggest how these changes can be made?


With regards
Vyshakh
_______________________________________________
Zope-Dev maillist - Zope-Dev[at]zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


regebro at gmail

Jul 23, 2008, 7:14 AM

Post #2 of 10 (510 views)
Permalink
Re: Deprecation Warning [In reply to]

On Wed, Jul 23, 2008 at 14:03, vyshakh krishnan
<vyshakh.krishnan[at]gmail.com> wrote:
> Hi everybody,
>
>
> While porting Zope2 on Python2.5, I am now trying to remove the
> deprecation warnings.Most of them are due to the raising of string
> exceptions. One of such warnings in the module Products is
>
> /home/zope/ztrunk25/lib/python/OFS/SimpleItem.py:248:
> DeprecationWarning: raising a string exception is deprecated
> raise error_type, v, tb
>
> These warnings can be removed by changing these string exceptions to
> class based exceptions.
> Can anyone suggest how these changes can be made?

Well, typically you create classes based on Exception or
BaseException, and use them instead.
Maybe you could expand a bit on what your worries are?

--
Lennart Regebro: Zope and Plone consulting.
http://www.colliberty.com/
+33 661 58 14 64
_______________________________________________
Zope-Dev maillist - Zope-Dev[at]zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


tseaver at palladion

Jul 23, 2008, 8:42 AM

Post #3 of 10 (507 views)
Permalink
Re: Deprecation Warning [In reply to]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

vyshakh krishnan wrote:
> Hi everybody,
>
>
> While porting Zope2 on Python2.5, I am now trying to remove the
> deprecation warnings.Most of them are due to the raising of string
> exceptions. One of such warnings in the module Products is
>
> /home/zope/ztrunk25/lib/python/OFS/SimpleItem.py:248:
> DeprecationWarning: raising a string exception is deprecated
> raise error_type, v, tb
>
> These warnings can be removed by changing these string exceptions to
> class based exceptions.
> Can anyone suggest how these changes can be made?

That code is not in the Products module: it is inside OFS.SimpleItem's
'raise_standardErrorMessage' method. Note that the method explicitly
converts the error_type to a string above: that is the source of the
DeprecationWarning, almost certainly, as there should be no remaining
traces of explicitly-created string exceptions anywhere in the Zope
codebase.


Tres.
- --
===================================================================
Tres Seaver +1 540-429-0999 tseaver[at]palladion.com
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIh1FR+gerLs4ltQ4RAt7AAJ96zocnGl6fMw6qKfLn59/bV6/ZyQCcCdL+
Vqw6L0yBM1eQ4z0D3yxS0kM=
=2F4j
-----END PGP SIGNATURE-----

_______________________________________________
Zope-Dev maillist - Zope-Dev[at]zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


vyshakh.krishnan at gmail

Jul 23, 2008, 11:26 AM

Post #4 of 10 (507 views)
Permalink
Deprecation Warning [In reply to]

Hello everyone,

Since the deprecation warning is due to the conversion of error_type
into string by 'raise_standardErrorMessage' method, is it still
necessary to use new user defined Exception class or do we want to
modify the function
'raise_standardErrorMessage' .
_______________________________________________
Zope-Dev maillist - Zope-Dev[at]zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


regebro at gmail

Jul 23, 2008, 3:04 PM

Post #5 of 10 (498 views)
Permalink
Re: Deprecation Warning [In reply to]

On Wed, Jul 23, 2008 at 20:26, vyshakh krishnan
<vyshakh.krishnan[at]gmail.com> wrote:
> Hello everyone,
>
> Since the deprecation warning is due to the conversion of error_type
> into string by 'raise_standardErrorMessage' method, is it still
> necessary to use new user defined Exception class or do we want to
> modify the function
> 'raise_standardErrorMessage' .

We want to NOT raise a string. But an Exception object. That's pretty
much it. As earlier: please share your worries about this. It sounds
like a rather trivial code change, but you don't seem to think so, and
we can help better if you explain why.

--
Lennart Regebro: Zope and Plone consulting.
http://www.colliberty.com/
+33 661 58 14 64
_______________________________________________
Zope-Dev maillist - Zope-Dev[at]zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


tseaver at palladion

Jul 23, 2008, 3:32 PM

Post #6 of 10 (496 views)
Permalink
Re: Deprecation Warning [In reply to]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lennart Regebro wrote:
> On Wed, Jul 23, 2008 at 20:26, vyshakh krishnan
> <vyshakh.krishnan[at]gmail.com> wrote:
>> Hello everyone,
>>
>> Since the deprecation warning is due to the conversion of error_type
>> into string by 'raise_standardErrorMessage' method, is it still
>> necessary to use new user defined Exception class or do we want to
>> modify the function
>> 'raise_standardErrorMessage' .
>
> We want to NOT raise a string. But an Exception object. That's pretty
> much it. As earlier: please share your worries about this. It sounds
> like a rather trivial code change, but you don't seem to think so, and
> we can help better if you explain why.

Exactly: I made a pass through the code in November 2003 ripping out
string exceptions, but must have missed this one[1].

Please just change the 'raise_standardErrorMessage' method to avoid
converting 'error_type' to a string; then, if anything is actually
passing 'error_type' as a string, we should fix *that* code.

[1] $ CVSROOT=""ext:cvs.zope.org:/cvs-reposotiry" \
cvs diff -r tseaver-strexp_delenda-base \
-r tseaver-strexp_delenda-branch


Tres.
- --
===================================================================
Tres Seaver +1 540-429-0999 tseaver[at]palladion.com
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIh7GI+gerLs4ltQ4RAn4iAJ9DC8tVOBLbGhsQxtxni5gjTPLrNQCgkv6u
nh0Wr9O4Cs2CePPM5MnhJ3o=
=a32S
-----END PGP SIGNATURE-----

_______________________________________________
Zope-Dev maillist - Zope-Dev[at]zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


vyshakh.krishnan at gmail

Jul 28, 2008, 10:23 AM

Post #7 of 10 (444 views)
Permalink
Deprecation Warning [In reply to]

Hi Everyone,


The deprecation warning while testing Product module is

/home/zope/ztrunk25/lib/python/OFS/SimpleItem.py:248:
DeprecationWarning: raising a string exception is deprecated
raise error_type, v, tb



Is it enough to define a new sub class of Exception which accept
error_type,v as arguments and just print these messages to fix this
warning?

Many of the the warnings in other modules are found similar to this warning.


regards
vyshakh
_______________________________________________
Zope-Dev maillist - Zope-Dev[at]zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


tseaver at palladion

Jul 28, 2008, 11:39 AM

Post #8 of 10 (445 views)
Permalink
Re: Deprecation Warning [In reply to]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

vyshakh krishnan wrote:
> Hi Everyone,
>
>
> The deprecation warning while testing Product module is
>
> /home/zope/ztrunk25/lib/python/OFS/SimpleItem.py:248:
> DeprecationWarning: raising a string exception is deprecated
> raise error_type, v, tb
>
>
>
> Is it enough to define a new sub class of Exception which accept
> error_type,v as arguments and just print these messages to fix this
> warning?

First, remove the forced conversion of 'error_type' to a string. Does
that make the warning go away?

> Many of the the warnings in other modules are found similar to this warning.

Please enumerate them.


Tres.
- --
===================================================================
Tres Seaver +1 540-429-0999 tseaver[at]palladion.com
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIjhJj+gerLs4ltQ4RArauAKDDLVHNc936dYCXUI4v9Ec22/sbfQCfcMHq
+N2ioO1db1R86IYZAFONNSY=
=cLbS
-----END PGP SIGNATURE-----

_______________________________________________
Zope-Dev maillist - Zope-Dev[at]zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


vyshakh.krishnan at gmail

Jul 29, 2008, 4:08 AM

Post #9 of 10 (435 views)
Permalink
Re: Deprecation Warning [In reply to]

On Tue, Jul 29, 2008 at 12:09 AM, Tres Seaver <tseaver[at]palladion.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> vyshakh krishnan wrote:
>> Hi Everyone,
>>
>>
>> The deprecation warning while testing Product module is
>>
>> /home/zope/ztrunk25/lib/python/OFS/SimpleItem.py:248:
>> DeprecationWarning: raising a string exception is deprecated
>> raise error_type, v, tb
>>
>>
>>
>> Is it enough to define a new sub class of Exception which accept
>> error_type,v as arguments and just print these messages to fix this
>> warning?
>
> First, remove the forced conversion of 'error_type' to a string. Does
> that make the warning go away?
>

I have tried to remove this forced conversion and came to notice that
following code is doing this conversion of error_type from <class
'zExceptions.NotFound'> to string


/home/zope/ztrunk25/lib/python/OFS/SimpleItem.py(186)
if hasattr(error_type, '__name__'):
error_type=error_type.__name__

But I couldn't make proper type cast here.
Can anybody help me in doing so?

>> Many of the the warnings in other modules are found similar to this warning.
>
> Please enumerate them.
>
>
> Tres.
> - --
> ===================================================================
> Tres Seaver +1 540-429-0999 tseaver[at]palladion.com
> Palladion Software "Excellence by Design" http://palladion.com
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFIjhJj+gerLs4ltQ4RArauAKDDLVHNc936dYCXUI4v9Ec22/sbfQCfcMHq
> +N2ioO1db1R86IYZAFONNSY=
> =cLbS
> -----END PGP SIGNATURE-----
>

regards
vyshakh
_______________________________________________
Zope-Dev maillist - Zope-Dev[at]zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


chris at simplistix

Aug 1, 2008, 12:23 AM

Post #10 of 10 (374 views)
Permalink
Re: Re: Deprecation Warning [In reply to]

vyshakh,

vyshakh krishnan wrote:
>>> Many of the the warnings in other modules are found similar to this warning.
>> Please enumerate them.

Please read and respond to all points raised in mails.
Unless I missed something, we're still waiting to see the full list of
the warnings in other modules.

cheers,

Chris

--
Simplistix - Content Management, Zope & Python Consulting
- http://www.simplistix.co.uk
_______________________________________________
Zope-Dev maillist - Zope-Dev[at]zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )

Zope dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.