Author: pjenvey
Date: 2008-10-08 23:49:53 -0600 (Wed, 08 Oct 2008)
New Revision: 3620
Modified:
FormEncode/trunk/docs/news.txt
FormEncode/trunk/formencode/validators.py
Log:
more set vs sets to quiet 2.6 deprecation warnings
Modified: FormEncode/trunk/docs/news.txt
===================================================================
--- FormEncode/trunk/docs/news.txt 2008-10-07 16:48:37 UTC (rev 3619)
+++ FormEncode/trunk/docs/news.txt 2008-10-09 05:49:53 UTC (rev 3620)
@@ -44,6 +44,8 @@
* Look in ``/usr/share/locale`` for locale files, in addition to the
normal locations.
+* Quiet Python 2.6 deprecation warnings.
+
1.0.1
-----
Modified: FormEncode/trunk/formencode/validators.py
===================================================================
--- FormEncode/trunk/formencode/validators.py 2008-10-07 16:48:37 UTC (rev
3619)
+++ FormEncode/trunk/formencode/validators.py 2008-10-09 05:49:53 UTC (rev
3620)
@@ -32,10 +32,14 @@
from interfaces import *
from api import *
sha1 = random = None
+
+warnings.simplefilter('ignore', DeprecationWarning)
+import sets
+warnings.resetwarnings()
try:
- import sets
-except ImportError:
- sets = None
+ set
+except NameError:
+ set = sets.Set
import cgi
@@ -1185,7 +1189,7 @@
one result. It's equivalent to ForEach(convertToList=True).
If you give ``use_set=True``, then it will return an actual
- ``sets.Set`` object.
+ ``set`` object.
::
@@ -1197,11 +1201,11 @@
['this', 'that']
>>> s = Set(use_set=True)
>>> s.to_python(None)
- Set([])
+ set([])
>>> s.to_python('this')
- Set(['this'])
+ set(['this'])
>>> s.to_python(('this',))
- Set(['this'])
+ set(['this'])
"""
use_set = False
@@ -1210,18 +1214,18 @@
def _to_python(self, value, state):
if self.use_set:
- if isinstance(value, sets.Set):
+ if isinstance(value, (set, sets.Set)):
return value
elif isinstance(value, (list, tuple)):
- return sets.Set(value)
+ return set(value)
elif value is None:
- return sets.Set()
+ return set()
else:
- return sets.Set([value])
+ return set([value])
else:
if isinstance(value, list):
return value
- elif sets and isinstance(value, sets.Set):
+ elif sets and isinstance(value, (set, sets.Set)):
return list(value)
elif isinstance(value, tuple):
return list(value)
@@ -1232,7 +1236,7 @@
def empty_value(self, value):
if self.use_set:
- return sets.Set([])
+ return set()
else:
return []
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
FormEncode-CVS mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/formencode-cvs