Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Why doesn't "filterwarnings" suppress this message? (http://www.velocityreviews.com/forums/t713166-why-doesnt-filterwarnings-suppress-this-message.html)

John Nagle 01-28-2010 06:38 PM

Why doesn't "filterwarnings" suppress this message?
 
Feedparser isn't supported for Python 3.0, so in Python 2.6, many warning
messages appear. I'm trying, in Python 2.6, to suppress the warning message:

./feedparser\feedparser.py:69: DeprecationWarning:
the sgmllib module has been removed in Python 3.0
import sgmllib, re, sys, copy, urlparse, time, rfc822, types,
cgi, urllib, urllib2

with this warning filter:

warnings.filterwarnings(action='ignore',
category=DeprecationWarning, module='feedparser')

The filter suppresses other deprecation warnings associated with
the feedparser module, but not that one. How do I get rid of that
one?

And no,

warnings.filterwarnings(action='ignore',
category=DeprecationWarning, module='sgmllib')

doesn't do it.

John Nagle

Peter Otten 01-28-2010 07:01 PM

Re: Why doesn't "filterwarnings" suppress this message?
 
John Nagle wrote:

> Feedparser isn't supported for Python 3.0, so in Python 2.6, many
> warning
> messages appear. I'm trying, in Python 2.6, to suppress the warning
> message:
>
> ./feedparser\feedparser.py:69: DeprecationWarning:
> the sgmllib module has been removed in Python 3.0
> import sgmllib, re, sys, copy, urlparse, time, rfc822, types,
> cgi, urllib, urllib2
>
> with this warning filter:
>
> warnings.filterwarnings(action='ignore',
> category=DeprecationWarning, module='feedparser')
>
> The filter suppresses other deprecation warnings associated with
> the feedparser module, but not that one. How do I get rid of that
> one?
>
> And no,
>
> warnings.filterwarnings(action='ignore',
> category=DeprecationWarning, module='sgmllib')
>
> doesn't do it.
>
> John Nagle


I can't confirm that:

$ cat nowarning.py
import sys
if "--off" in sys.argv:
import warnings
warnings.filterwarnings(action="ignore",
category=DeprecationWarning,
module="feedparser")
import feedparser
$ python nowarning.py
$ python -3 nowarning.py
/usr/lib/python2.6/site.py:1: DeprecationWarning: The 'new' module has been
removed in Python 3.0; use the 'types' module instead.
"""Append module search paths for third-party packages to sys.path.
/usr/lib/pymodules/python2.6/feedparser.py:69: DeprecationWarning: the
sgmllib module has been removed in Python 3.0
import sgmllib, re, sys, copy, urlparse, time, rfc822, types, cgi, urllib,
urllib2
/usr/lib/pymodules/python2.6/feedparser.py:69: DeprecationWarning: in 3.x,
rfc822 has been removed in favor of the email package
import sgmllib, re, sys, copy, urlparse, time, rfc822, types, cgi, urllib,
urllib2
$ python -3 nowarning.py --off
/usr/lib/python2.6/site.py:1: DeprecationWarning: The 'new' module has been
removed in Python 3.0; use the 'types' module instead.
"""Append module search paths for third-party packages to sys.path.
$ python -V
Python 2.6.4

Peter

John Nagle 01-29-2010 08:41 AM

Re: Why doesn't "filterwarnings" suppress this message?
 
It turned out to be a loading order issue. That message is generated
at import time, and "filterwarnings" hadn't been called yet.

John Nagle

Peter Otten wrote:
> John Nagle wrote:
>
>> Feedparser isn't supported for Python 3.0, so in Python 2.6, many
>> warning
>> messages appear. I'm trying, in Python 2.6, to suppress the warning
>> message:
>>
>> ./feedparser\feedparser.py:69: DeprecationWarning:
>> the sgmllib module has been removed in Python 3.0
>> import sgmllib, re, sys, copy, urlparse, time, rfc822, types,
>> cgi, urllib, urllib2
>>
>> with this warning filter:
>>
>> warnings.filterwarnings(action='ignore',
>> category=DeprecationWarning, module='feedparser')
>>
>> The filter suppresses other deprecation warnings associated with
>> the feedparser module, but not that one. How do I get rid of that
>> one?



All times are GMT. The time now is 04:17 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.