supressing warning message?

M

Mark Harrison

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
 
J

Jeff Epler

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-----
 
M

Mark Harrison

Jeff said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,832
Latest member
GlennSmall

Latest Threads

Top