[Python-3000-checkins] r58744 - in python/branches/py3k-pep3137/Lib: encodings/idna.py encodings/punycode.py test/test_binascii.py test/test_compile.py test/test_datetime.py test/test_exceptions.py test/test_float.py test/test_marshal.py test/testcodec.py
christian.heimes
python-3000-checkins at python.org
Thu Nov 1 16:38:24 CET 2007
Author: christian.heimes
Date: Thu Nov 1 16:38:23 2007
New Revision: 58744
Modified:
python/branches/py3k-pep3137/Lib/encodings/idna.py
python/branches/py3k-pep3137/Lib/encodings/punycode.py
python/branches/py3k-pep3137/Lib/test/test_binascii.py
python/branches/py3k-pep3137/Lib/test/test_compile.py
python/branches/py3k-pep3137/Lib/test/test_datetime.py
python/branches/py3k-pep3137/Lib/test/test_exceptions.py
python/branches/py3k-pep3137/Lib/test/test_float.py
python/branches/py3k-pep3137/Lib/test/test_marshal.py
python/branches/py3k-pep3137/Lib/test/testcodec.py
Log:
A couple of smaller fixes for unit tests and encodings that were broken by the rename of str8 -> bytes, bytes -> buffer.
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 Thu Nov 1 16:38:23 2007
@@ -151,9 +151,9 @@
raise UnicodeError("unsupported error handling "+errors)
if not input:
- return b"", 0
+ return buffer(), 0
- result = b""
+ result = buffer()
labels = dots.split(input)
if labels and not labels[-1]:
trailing_dot = b'.'
@@ -216,7 +216,7 @@
if labels:
trailing_dot = b'.'
- result = b""
+ result = buffer()
size = 0
for label in labels:
if size:
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 Thu Nov 1 16:38:23 2007
@@ -10,7 +10,7 @@
def segregate(str):
"""3.1 Basic code point segregation"""
- base = b""
+ base = buffer()
extended = set()
for c in str:
if ord(c) < 128:
@@ -18,7 +18,7 @@
else:
extended.add(c)
extended = sorted(extended)
- return (base, extended)
+ return base, extended
def selective_len(str, max):
"""Return the length of str, considering only characters below max."""
@@ -78,7 +78,7 @@
digits = b"abcdefghijklmnopqrstuvwxyz0123456789"
def generate_generalized_integer(N, bias):
"""3.3 Generalized variable-length integers"""
- result = b""
+ result = buffer()
j = 0
while 1:
t = T(j, bias)
@@ -107,7 +107,7 @@
def generate_integers(baselen, deltas):
"""3.4 Bias adaptation"""
# Punycode parameters: initial bias = 72, damp = 700, skew = 38
- result = b""
+ result = buffer()
bias = 72
for points, delta in enumerate(deltas):
s = generate_generalized_integer(delta, bias)
Modified: python/branches/py3k-pep3137/Lib/test/test_binascii.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/test/test_binascii.py (original)
+++ python/branches/py3k-pep3137/Lib/test/test_binascii.py Thu Nov 1 16:38:23 2007
@@ -56,7 +56,7 @@
a = binascii.b2a_base64(b)
lines.append(a)
- fillers = bytes()
+ fillers = buffer()
valid = b"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/"
for i in range(256):
if i not in valid:
@@ -64,7 +64,7 @@
def addnoise(line):
noise = fillers
ratio = len(line) // len(noise)
- res = bytes()
+ res = buffer()
while line and noise:
if len(line) // len(noise) > ratio:
c, line = line[0], line[1:]
@@ -72,7 +72,7 @@
c, noise = noise[0], noise[1:]
res.append(c)
return res + noise + line
- res = bytes()
+ res = buffer()
for line in map(addnoise, lines):
b = binascii.a2b_base64(line)
res += b
Modified: python/branches/py3k-pep3137/Lib/test/test_compile.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/test/test_compile.py (original)
+++ python/branches/py3k-pep3137/Lib/test/test_compile.py Thu Nov 1 16:38:23 2007
@@ -157,7 +157,7 @@
s256 = "".join(["\n"] * 256 + ["spam"])
co = compile(s256, 'fn', 'exec')
self.assertEqual(co.co_firstlineno, 257)
- self.assertEqual(co.co_lnotab, str8())
+ self.assertEqual(co.co_lnotab, bytes())
def test_literals_with_leading_zeroes(self):
for arg in ["077787", "0xj", "0x.", "0e", "090000000000000",
Modified: python/branches/py3k-pep3137/Lib/test/test_datetime.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/test/test_datetime.py (original)
+++ python/branches/py3k-pep3137/Lib/test/test_datetime.py Thu Nov 1 16:38:23 2007
@@ -1111,7 +1111,7 @@
# This shouldn't blow up because of the month byte alone. If
# the implementation changes to do more-careful checking, it may
# blow up because other fields are insane.
- self.theclass(bytes(base[:2] + chr(ord_byte) + base[3:], "ascii"))
+ self.theclass(buffer(base[:2] + chr(ord_byte) + base[3:], "ascii"))
#############################################################################
# datetime tests
Modified: python/branches/py3k-pep3137/Lib/test/test_exceptions.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/test/test_exceptions.py (original)
+++ python/branches/py3k-pep3137/Lib/test/test_exceptions.py Thu Nov 1 16:38:23 2007
@@ -278,7 +278,7 @@
try:
e = exc(*args)
except:
- print("\nexc=%r, args=%r" % (exc, args))
+ print("\nexc=%r, args=%r" % (exc, args), file=sys.stderr)
raise
else:
# Verify module name
Modified: python/branches/py3k-pep3137/Lib/test/test_float.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/test/test_float.py (original)
+++ python/branches/py3k-pep3137/Lib/test/test_float.py Thu Nov 1 16:38:23 2007
@@ -40,14 +40,14 @@
'chicken', 'unknown')
BE_DOUBLE_INF = b'\x7f\xf0\x00\x00\x00\x00\x00\x00'
-LE_DOUBLE_INF = bytes(reversed(BE_DOUBLE_INF))
+LE_DOUBLE_INF = bytes(reversed(buffer(BE_DOUBLE_INF)))
BE_DOUBLE_NAN = b'\x7f\xf8\x00\x00\x00\x00\x00\x00'
-LE_DOUBLE_NAN = bytes(reversed(BE_DOUBLE_NAN))
+LE_DOUBLE_NAN = bytes(reversed(buffer(BE_DOUBLE_NAN)))
BE_FLOAT_INF = b'\x7f\x80\x00\x00'
-LE_FLOAT_INF = bytes(reversed(BE_FLOAT_INF))
+LE_FLOAT_INF = bytes(reversed(buffer(BE_FLOAT_INF)))
BE_FLOAT_NAN = b'\x7f\xc0\x00\x00'
-LE_FLOAT_NAN = bytes(reversed(BE_FLOAT_NAN))
+LE_FLOAT_NAN = bytes(reversed(buffer(BE_FLOAT_NAN)))
# on non-IEEE platforms, attempting to unpack a bit pattern
# representing an infinity or a NaN should raise an exception.
Modified: python/branches/py3k-pep3137/Lib/test/test_marshal.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/test/test_marshal.py (original)
+++ python/branches/py3k-pep3137/Lib/test/test_marshal.py Thu Nov 1 16:38:23 2007
@@ -39,7 +39,7 @@
# we're running the test on a 32-bit box, of course.
def to_little_endian_string(value, nbytes):
- b = bytes()
+ b = buffer()
for i in range(nbytes):
b.append(value & 0xff)
value >>= 8
Modified: python/branches/py3k-pep3137/Lib/test/testcodec.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/test/testcodec.py (original)
+++ python/branches/py3k-pep3137/Lib/test/testcodec.py Thu Nov 1 16:38:23 2007
@@ -36,7 +36,7 @@
decoding_map = codecs.make_identity_dict(range(256))
decoding_map.update({
0x78: "abc", # 1-n decoding mapping
- str8(b"abc"): 0x0078,# 1-n encoding mapping
+ b"abc": 0x0078,# 1-n encoding mapping
0x01: None, # decoding mapping to <undefined>
0x79: "", # decoding mapping to <remove character>
})
More information about the Python-3000-checkins
mailing list