views:

175

answers:

2

hi, when I use MySQLdb get this message:

/var/lib/python-support/python2.6/MySQLdb/__init__.py:34: DeprecationWarning: the sets module is deprecated from sets import ImmutableSet

I try filter the warning with

import warnings 
warnings.filterwarnings("ignore", message="the sets module is deprecated from sets import ImmutableSet")

but, I not get changes.
any suggestion?
Many thanks.

+1  A: 

What release of MySQLdb are you using? I think the current one (1.2.3c1) should have it fixed see this bug (marked as fixed as of Oct 2008, 1.2 branch).

Alex Martelli
I have __version__ = "1.2.2", maybe this is the problem.
JuanPablo
@juanpablo, maybe, though it's weird since you do have the last full-release (that "c1" means "release candidate 1" for 1.2.3) and the 1.2 branch SHOULD have fixed the problem 1+ year ago. The bug report I point to includes a simple fix to the relevant .py files, maybe you want to do those small edits yourself and fix the problem (which is better than just suppressing warnings!-), basically you need to skip that import and bind the `frozenset` built-in to that `ImmutableSet` old, obsolete, deprecated name!
Alex Martelli
+1  A: 

From python documentation: you could filter your warning this way, so that if other warnings are caused by an other part of your code, there would still be displayed:

import warnings
with warnings.catch_warnings():
    warnings.simplefilter("ignore", DeprecationWarning)
    import MySQLdb
[...]

but as said by Alex Martelli, the best solution would be to update MySQLdb so that it doesn't use deprecated modules.

MatToufoutu