supressing warning message?

Discussion in 'Python' started by Mark Harrison, Jul 29, 2004.

  1. Due to some uninteresting configuration management issues, I'm
    running a mismatched python library and getting this message
    dumped to stderr.

    > /.../lib/site-python/Sybase/Sybase.py:20:
    > RuntimeWarning: Python C API version mismatch for module sybasect:
    > This Python has API version 1011, module sybasect has version 1012.


    While I'm straightening the the CM, everything seems to work well, except
    for the warning being printed. Is there a way to intercept or
    supress this?

    Many TIA!
    Mark

    --
    Mark Harrison
    Pixar Animation Studios
    Mark Harrison, Jul 29, 2004
    #1
    1. Advertising

  2. Mark Harrison

    Jeff Epler Guest

    While I haven't tested this to be sure, "RuntimeWarning" suggests that
    this message is coming from the regular warnings machinery. Routines in
    the "warnings" module let you silence these warnings.

    http://docs.python.org/lib/module-warnings.html

    Here's a brute-force way to silence all warnings:
    import warnings; warnings.filterwarnings('ignore')
    you might want to use something a little more targeted.

    Jeff

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.4 (GNU/Linux)

    iD8DBQFBCFT1Jd01MZaTXX0RAsFwAKCjrtYu/dW2terK5youEgfMBYLFdwCgjNOK
    +f4IbOWEv/LRChWqT2DbqpA=
    =uYPK
    -----END PGP SIGNATURE-----
    Jeff Epler, Jul 29, 2004
    #2
    1. Advertising

  3. Jeff Epler wrote:
    > Here's a brute-force way to silence all warnings:
    > import warnings; warnings.filterwarnings('ignore')
    > you might want to use something a little more targeted.


    Now I'm doing this, and it works perfectly:

    warnings.filterwarnings('ignore')
    import Sybase
    warnings.filterwarnings('always')

    Thanks!
    Mark
    Mark Harrison, Jul 29, 2004
    #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. Herb Stull

    Supressing Menu and Toolbars on Webpage

    Herb Stull, Feb 25, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    491
    Eric Lawrence [MSFT]
    Feb 25, 2004
  2. Dave

    Supressing sign extension

    Dave, Oct 9, 2004, in forum: C++
    Replies:
    4
    Views:
    686
    Alf P. Steinbach
    Oct 10, 2004
  3. Michael B Allen

    Supressing Unused Parameter Warnings

    Michael B Allen, May 7, 2004, in forum: C Programming
    Replies:
    11
    Views:
    1,003
    CBFalconer
    May 8, 2004
  4. Jp Calderone

    Supressing PyChecker warnings

    Jp Calderone, Jan 16, 2004, in forum: Python
    Replies:
    1
    Views:
    457
    Rene Pijlman
    Jan 16, 2004
  5. SunX

    supressing '\n' at the end

    SunX, Nov 6, 2004, in forum: Python
    Replies:
    2
    Views:
    291
    George Yoshida
    Nov 6, 2004
Loading...

Share This Page