[Checkins] SVN: zope.schema/branches/tseaver-test_cleanup/src/zope/schema/_bootstrapfields.py Remove ancient BBB hackery.
Tres Seaver
cvs-admin at zope.org
Mon Apr 23 21:58:48 UTC 2012
Log message for revision 125247:
Remove ancient BBB hackery.
Changed:
U zope.schema/branches/tseaver-test_cleanup/src/zope/schema/_bootstrapfields.py
-=-
Modified: zope.schema/branches/tseaver-test_cleanup/src/zope/schema/_bootstrapfields.py
===================================================================
--- zope.schema/branches/tseaver-test_cleanup/src/zope/schema/_bootstrapfields.py 2012-04-23 21:58:40 UTC (rev 125246)
+++ zope.schema/branches/tseaver-test_cleanup/src/zope/schema/_bootstrapfields.py 2012-04-23 21:58:44 UTC (rev 125247)
@@ -381,26 +381,20 @@
class Bool(Field):
"""A field representing a Bool."""
- _type = type(True)
+ _type = bool
- if _type is not type(1):
- # Python 2.2.1 and newer 2.2.x releases, True and False are
- # integers, and bool() returns either 1 or 0. We need to
- # support using integers here so we don't invalidate schema
- # that were perfectly valid with older versions of Python.
+ def _validate(self, value):
+ # Convert integers to bools to they don't get mis-flagged
+ # by the type check later.
+ if isinstance(value, int):
+ value = bool(value)
+ Field._validate(self, value)
- def _validate(self, value):
- # Convert integers to bools to they don't get mis-flagged
- # by the type check later.
- if isinstance(value, int):
- value = bool(value)
- Field._validate(self, value)
+ def set(self, object, value):
+ if isinstance(value, int):
+ value = bool(value)
+ Field.set(self, object, value)
- def set(self, object, value):
- if isinstance(value, int):
- value = bool(value)
- Field.set(self, object, value)
-
def fromUnicode(self, str):
"""
>>> b = Bool()
More information about the checkins
mailing list