Why doesn't "filterwarnings" suppress this message?

Discussion in 'Python' started by John Nagle, Jan 28, 2010.

  1. John Nagle

    John Nagle Guest

    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
     
    John Nagle, Jan 28, 2010
    #1
    1. Advertising

  2. John Nagle

    Peter Otten Guest

    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
     
    Peter Otten, Jan 28, 2010
    #2
    1. Advertising

  3. John Nagle

    John Nagle Guest

    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?
     
    John Nagle, Jan 29, 2010
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Samik R
    Replies:
    4
    Views:
    3,096
    Samik R
    Dec 30, 2005
  2. Christian Seberino
    Replies:
    0
    Views:
    356
    Christian Seberino
    Oct 21, 2003
  3. Ian Bicking
    Replies:
    0
    Views:
    393
    Ian Bicking
    Oct 22, 2003
  4. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,138
    Smokey Grindel
    Dec 2, 2006
  5. Jim Freeze
    Replies:
    3
    Views:
    131
    WATANABE Hirofumi
    Feb 17, 2004
Loading...

Share This Page