By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,361 Members | 1,727 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,361 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
7 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
"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.