472,145 Members | 1,373 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

How to suppress "DeprecationWarning: Old style callback, use cb_func(ok,store) instead"

How do I suppress "DeprecationWarning: Old style callback, use cb_func(ok,
store) instead". A library is triggering this message, the library is being
fixed, but I need to make the message disappear from the output of a CGI
program.

John Nagle
Feb 3 '07 #1
7 7390
John Nagle wrote:
How do I suppress "DeprecationWarning: Old style callback, use
cb_func(ok,
store) instead". A library is triggering this message, the library is
being fixed, but I need to make the message disappear from the output of a
CGI program.
import warnings
warnings.filterwarnings("ignore", message="Old style callback, use
cb_func(ok, store) instead")

Peter

Feb 3 '07 #2
En Sat, 03 Feb 2007 06:12:33 -0300, Peter Otten <__*******@web.de>
escribió:
John Nagle wrote:
> How do I suppress "DeprecationWarning: Old style callback, use
cb_func(ok,
store) instead". A library is triggering this message, the library is
being fixed, but I need to make the message disappear from the output
of a
CGI program.

import warnings
warnings.filterwarnings("ignore", message="Old style callback, use
cb_func(ok, store) instead")
Or you can be more aggressive and filter out all DeprecationWarnings:
warnings.simplefilter("ignore",DeprecationWarning)
(same as using option -Wignore::DeprecationWarning on the python command
line)

--
Gabriel Genellina

Feb 3 '07 #3
On 2007-02-03, Gabriel Genellina <ga******@yahoo.com.arwrote:
En Sat, 03 Feb 2007 06:12:33 -0300, Peter Otten <__*******@web.de>
escribió:
>John Nagle wrote:
>> How do I suppress "DeprecationWarning: Old style callback, use
cb_func(ok,
store) instead". A library is triggering this message, the library is
being fixed, but I need to make the message disappear from the output
of a
CGI program.

import warnings
warnings.filterwarnings("ignore", message="Old style callback, use
cb_func(ok, store) instead")

Or you can be more aggressive and filter out all DeprecationWarnings:
warnings.simplefilter("ignore",DeprecationWarning)
(same as using option -Wignore::DeprecationWarning on the python command
line)
Ah, yes! The null module. Python should have more of these. I
mean "shouldn't". ;)

--
Neil Cerutti
Feb 3 '07 #4
Gabriel Genellina wrote:
En Sat, 03 Feb 2007 06:12:33 -0300, Peter Otten <__*******@web.de>
escribió:
>John Nagle wrote:
>> How do I suppress "DeprecationWarning: Old style callback, use
cb_func(ok,
store) instead". A library is triggering this message, the library is
being fixed, but I need to make the message disappear from the output
of a
CGI program.

import warnings
warnings.filterwarnings("ignore", message="Old style callback, use
cb_func(ok, store) instead")

Or you can be more aggressive and filter out all DeprecationWarnings:
warnings.simplefilter("ignore",DeprecationWarning)
(same as using option -Wignore::DeprecationWarning on the python command
line)
The latter might be interesting for a cgi. I didn't mention it because I
didn't get it to work with my test case (importing sre) and Python's cgi
server. Trying again, I found that you must not quote the -W argument.

#!/usr/local/bin/python2.5 -Wignore:The sre module is deprecated, please
import re.

From that follows that you can pass at most one commandline arg.
If you are using

#!/usr/bin/env python2.5

python2.5 will be that single argument and no options are possible at all.
What might be the reasons for such a seemingly arbitrary limitation?

Peter

Feb 3 '07 #5
Gabriel Genellina wrote:
En Sat, 03 Feb 2007 06:12:33 -0300, Peter Otten <__*******@web.de>
escribió:
>John Nagle wrote:
>> How do I suppress "DeprecationWarning: Old style callback, use
cb_func(ok,
store) instead". A library is triggering this message, the library is
being fixed, but I need to make the message disappear from the
output of a
CGI program.


import warnings
warnings.filterwarnings("ignore", message="Old style callback, use
cb_func(ok, store) instead")
Thanks.

Actually, just copying the message into the string doesn't work; the
matching argument is a regular expression, so "(" has special meaning.
But the general idea is right.

John Nagle
Feb 3 '07 #6
En Sat, 03 Feb 2007 07:35:22 -0300, Peter Otten <__*******@web.de>
escribió:
Gabriel Genellina wrote:
>En Sat, 03 Feb 2007 06:12:33 -0300, Peter Otten <__*******@web.de>
escribió:
>>John Nagle wrote:

import warnings
warnings.filterwarnings("ignore", message="Old style callback, use
cb_func(ok, store) instead")

Or you can be more aggressive and filter out all DeprecationWarnings:
warnings.simplefilter("ignore",DeprecationWarning )
(same as using option -Wignore::DeprecationWarning on the python command
line)

The latter might be interesting for a cgi. I didn't mention it because I
didn't get it to work with my test case (importing sre) and Python's cgi
server. Trying again, I found that you must not quote the -W argument.

#!/usr/local/bin/python2.5 -Wignore:The sre module is deprecated, please
import re.
>From that follows that you can pass at most one commandline arg.
If you are using

#!/usr/bin/env python2.5

python2.5 will be that single argument and no options are possible at
all.
What might be the reasons for such a seemingly arbitrary limitation?
The shell parses that line, not Python, so you should look into its
documentation.

If one needs to disable the warning for all scripts, putting a call to
warnings.simplefilter on sitecustomize.py would help (of course, if one is
allowed to edit that file).

--
Gabriel Genellina

Feb 5 '07 #7
"Gabriel Genellina" <ga******@yahoo.com.arwrote:
En Sat, 03 Feb 2007 07:35:22 -0300, Peter Otten <__*******@web.de>
escribió:
>#!/usr/bin/env python2.5

python2.5 will be that single argument and no options are possible at
all.
What might be the reasons for such a seemingly arbitrary limitation?
The shell parses that line, not Python, so you should look into its
documentation.
Bzzt! In any modestly recent Unix version (meaning fifteen years
old or younger), it has been the kernel that parsed the #! line,
not the shell.

As for *how* the kernel parses that line, it varies between Unix
versions. Linux, at least versions 2.4 and 2.6, takes everything
after the interpreter and passes it as a single argument to the
interpreter, with leading and trailing whitespace stripped. Thus

#! /usr/bin/interpreter foo bar gazonk del

will give the parameter "foo bar gazonk del" to the interpreter.

SunOS 5.10 (aka Solaris 10) on the other hand, splits the line on
whitespace and passes only the first word as parameter, and would
thus give only "foo" to the interpreter for the same #! line.

I seem to remember having used some Unix flavor that allowed
multiple words as arguments, and thus passed the four words
"foo", "bar", "gazonk" and "del" as arguments for the above #!
line, but I don't remember what Unix that was.
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
"Adde parvum parvo magnus acervus erit" ! bellman @ lysator.liu.se
(From The Mythical Man-Month) ! Make Love -- Nicht Wahr!
Feb 6 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

52 posts views Thread by Markus Elfring | last post: by
5 posts views Thread by johnsuth | last post: by
14 posts views Thread by I_AM_DON_AND_YOU? | last post: by
2 posts views Thread by mstearne | last post: by
3 posts views Thread by bulwark_jrm | last post: by
1 post views Thread by George Ter-Saakov | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.