[Python-3000-checkins] r58773 - in python/branches/py3k-pep3137/Lib: encodings/idna.py encodings/punycode.py string.py test/string_tests.py test/test_xml_etree.py test/test_xml_etree_c.py

christian.heimes python-3000-checkins at python.org
Fri Nov 2 16:59:05 CET 2007


Author: christian.heimes
Date: Fri Nov  2 16:59:04 2007
New Revision: 58773

Modified:
   python/branches/py3k-pep3137/Lib/encodings/idna.py
   python/branches/py3k-pep3137/Lib/encodings/punycode.py
   python/branches/py3k-pep3137/Lib/string.py
   python/branches/py3k-pep3137/Lib/test/string_tests.py
   python/branches/py3k-pep3137/Lib/test/test_xml_etree.py
   python/branches/py3k-pep3137/Lib/test/test_xml_etree_c.py
Log:
Fixed some more unit tests and removed some warnings. The removal of the implicit str() in str.join() needs some extra tests

Modified: python/branches/py3k-pep3137/Lib/encodings/idna.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/encodings/idna.py	(original)
+++ python/branches/py3k-pep3137/Lib/encodings/idna.py	Fri Nov  2 16:59:04 2007
@@ -151,7 +151,7 @@
             raise UnicodeError("unsupported error handling "+errors)
 
         if not input:
-            return buffer(), 0
+            return b'', 0
 
         result = buffer()
         labels = dots.split(input)
@@ -165,7 +165,7 @@
                 # Join with U+002E
                 result.extend(b'.')
             result.extend(ToASCII(label))
-        return result+trailing_dot, len(input)
+        return bytes(result+trailing_dot), len(input)
 
     def decode(self, input, errors='strict'):
 
@@ -228,7 +228,7 @@
 
         result += trailing_dot
         size += len(trailing_dot)
-        return (result, size)
+        return (bytes(result), size)
 
 class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
     def _buffer_decode(self, input, errors, final):

Modified: python/branches/py3k-pep3137/Lib/encodings/punycode.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/encodings/punycode.py	(original)
+++ python/branches/py3k-pep3137/Lib/encodings/punycode.py	Fri Nov  2 16:59:04 2007
@@ -18,7 +18,7 @@
         else:
             extended.add(c)
     extended = sorted(extended)
-    return base, extended
+    return bytes(base), extended
 
 def selective_len(str, max):
     """Return the length of str, considering only characters below max."""
@@ -84,7 +84,7 @@
         t = T(j, bias)
         if N < t:
             result.append(digits[N])
-            return result
+            return bytes(result)
         result.append(digits[t + ((N - t) % (36 - t))])
         N = (N - t) // (36 - t)
         j += 1
@@ -113,7 +113,7 @@
         s = generate_generalized_integer(delta, bias)
         result.extend(s)
         bias = adapt(delta, points==0, baselen+points+1)
-    return result
+    return bytes(result)
 
 def punycode_encode(text):
     base, extended = segregate(text)

Modified: python/branches/py3k-pep3137/Lib/string.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/string.py	(original)
+++ python/branches/py3k-pep3137/Lib/string.py	Fri Nov  2 16:59:04 2007
@@ -53,7 +53,7 @@
         raise ValueError("maketrans arguments must have same length")
     if not (isinstance(frm, bytes) and isinstance(to, bytes)):
         raise TypeError("maketrans arguments must be bytes objects")
-    L = bytes(range(256))
+    L = buffer(range(256))
     for i, c in enumerate(frm):
         L[c] = to[i]
     return L

Modified: python/branches/py3k-pep3137/Lib/test/string_tests.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/test/string_tests.py	(original)
+++ python/branches/py3k-pep3137/Lib/test/string_tests.py	Fri Nov  2 16:59:04 2007
@@ -992,14 +992,14 @@
         self.checkequal('abc', 'a', 'join', ('abc',))
         self.checkequal('z', 'a', 'join', UserList(['z']))
         self.checkequal('a.b.c', '.', 'join', ['a', 'b', 'c'])
-        self.checkequal('a.b.3', '.', 'join', ['a', 'b', 3])
+        self.assertRaises(TypeError, '.'.join, ['a', 'b', 3])
         for i in [5, 25, 125]:
             self.checkequal(((('a' * i) + '-') * i)[:-1], '-', 'join',
                  ['a' * i] * i)
             self.checkequal(((('a' * i) + '-') * i)[:-1], '-', 'join',
                  ('a' * i,) * i)
 
-        self.checkequal(str(BadSeq1()), ' ', 'join', BadSeq1())
+        #self.checkequal(str(BadSeq1()), ' ', 'join', BadSeq1())
         self.checkequal('a b c', ' ', 'join', BadSeq2())
 
         self.checkraises(TypeError, ' ', 'join')

Modified: python/branches/py3k-pep3137/Lib/test/test_xml_etree.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/test/test_xml_etree.py	(original)
+++ python/branches/py3k-pep3137/Lib/test/test_xml_etree.py	Fri Nov  2 16:59:04 2007
@@ -184,7 +184,7 @@
     >>> print(ET.tostring(element))
     <html><body>text</body></html>
     >>> print(repr(ET.tostring(element, "ascii")))
-    b'<?xml version=\'1.0\' encoding=\'ascii\'?>\n<html><body>text</body></html>'
+    b"<?xml version='1.0' encoding='ascii'?>\n<html><body>text</body></html>"
     >>> _, ids = ET.XMLID("<html><body>text</body></html>")
     >>> len(ids)
     0

Modified: python/branches/py3k-pep3137/Lib/test/test_xml_etree_c.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/test/test_xml_etree_c.py	(original)
+++ python/branches/py3k-pep3137/Lib/test/test_xml_etree_c.py	Fri Nov  2 16:59:04 2007
@@ -176,7 +176,7 @@
     >>> print(ET.tostring(element))
     <html><body>text</body></html>
     >>> print(repr(ET.tostring(element, "ascii")))
-    b'<?xml version=\'1.0\' encoding=\'ascii\'?>\n<html><body>text</body></html>'
+    b"<?xml version='1.0' encoding='ascii'?>\n<html><body>text</body></html>"
     >>> _, ids = ET.XMLID("<html><body>text</body></html>")
     >>> len(ids)
     0


More information about the Python-3000-checkins mailing list