[Checkins] SVN: zope.schema/branches/jinty-native_string/src/zope/schema/ Change URI to a NativeString

Brian Sutherland cvs-admin at zope.org
Mon Apr 9 10:30:39 UTC 2012


Log message for revision 125117:
  Change URI to a NativeString

Changed:
  U   zope.schema/branches/jinty-native_string/src/zope/schema/README.txt
  U   zope.schema/branches/jinty-native_string/src/zope/schema/_field.py

-=-
Modified: zope.schema/branches/jinty-native_string/src/zope/schema/README.txt
===================================================================
--- zope.schema/branches/jinty-native_string/src/zope/schema/README.txt	2012-04-09 10:25:20 UTC (rev 125116)
+++ zope.schema/branches/jinty-native_string/src/zope/schema/README.txt	2012-04-09 10:30:35 UTC (rev 125117)
@@ -65,7 +65,7 @@
 is to define some data:
 
   >>> title = u('Zope 3 Website')
-  >>> url = b('http://dev.zope.org/Zope3')
+  >>> url = 'http://dev.zope.org/Zope3'
 
 Now we, get the fields from the interface:
 
@@ -91,7 +91,7 @@
   ...
   WrongType: (u'http://zope.org/foo', <type 'str'>, 'url')
 
-  >>> url_bound.validate(b('foo.bar'))
+  >>> url_bound.validate('foo.bar')
   Traceback (most recent call last):
   ...
   InvalidURI: foo.bar

Modified: zope.schema/branches/jinty-native_string/src/zope/schema/_field.py
===================================================================
--- zope.schema/branches/jinty-native_string/src/zope/schema/_field.py	2012-04-09 10:25:20 UTC (rev 125116)
+++ zope.schema/branches/jinty-native_string/src/zope/schema/_field.py	2012-04-09 10:30:35 UTC (rev 125117)
@@ -602,27 +602,26 @@
 _isuri = r"[a-zA-z0-9+.-]+:" # scheme
 _isuri += r"\S*$" # non space (should be pickier)
 
-_isuri_bytes = re.compile(_isuri.encode('ascii')).match
 _isuri = re.compile(_isuri).match
 
 @implementer(IURI, IFromUnicode)
-class URI(BytesLine):
+class URI(NativeStringLine):
     """URI schema field
     """
 
     def _validate(self, value):
         """
         >>> uri = URI(__name__='test')
-        >>> uri.validate(b("http://www.python.org/foo/bar"))
-        >>> uri.validate(b("DAV:"))
-        >>> uri.validate(b("www.python.org/foo/bar"))
+        >>> uri.validate("http://www.python.org/foo/bar")
+        >>> uri.validate("DAV:")
+        >>> uri.validate("www.python.org/foo/bar")
         Traceback (most recent call last):
         ...
         InvalidURI: www.python.org/foo/bar
         """
 
         super(URI, self)._validate(value)
-        if _isuri_bytes(value):
+        if _isuri(value):
             return
 
         raise InvalidURI(value)
@@ -641,7 +640,7 @@
         ...
         InvalidURI: http://www.python.org/ foo/bar
         """
-        v = value.strip().encode('ascii')
+        v = value.strip()
         self.validate(v)
         return v
 



More information about the checkins mailing list