[Python-3000-checkins] r58769 - in python/branches/py3k-pep3137: Lib/dumbdbm.py Lib/test/test_exceptions.py Lib/test/test_struct.py Lib/test/test_unicodedata.py Modules/_hashopenssl.c Python/pythonrun.c
christian.heimes
python-3000-checkins at python.org
Fri Nov 2 12:41:45 CET 2007
Author: christian.heimes
Date: Fri Nov 2 12:41:44 2007
New Revision: 58769
Modified:
python/branches/py3k-pep3137/Lib/dumbdbm.py
python/branches/py3k-pep3137/Lib/test/test_exceptions.py
python/branches/py3k-pep3137/Lib/test/test_struct.py
python/branches/py3k-pep3137/Lib/test/test_unicodedata.py
python/branches/py3k-pep3137/Modules/_hashopenssl.c
python/branches/py3k-pep3137/Python/pythonrun.c
Log:
Even more fixes
Modified: python/branches/py3k-pep3137/Lib/dumbdbm.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/dumbdbm.py (original)
+++ python/branches/py3k-pep3137/Lib/dumbdbm.py Fri Nov 2 12:41:44 2007
@@ -163,7 +163,7 @@
if not isinstance(key, bytes):
raise TypeError("keys must be bytes")
key = key.decode("latin-1") # hashable bytes
- if not isinstance(val, (bytes, bytes)):
+ if not isinstance(val, (buffer, bytes)):
raise TypeError("values must be byte strings")
if key not in self._index:
self._addkey(key, self._addval(val))
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 Fri Nov 2 12:41:44 2007
@@ -253,11 +253,11 @@
'ordinal not in range'),
'encoding' : 'ascii', 'object' : 'a',
'start' : 0, 'reason' : 'ordinal not in range'}),
- (UnicodeDecodeError, ('ascii', b'\xff', 0, 1,
+ (UnicodeDecodeError, ('ascii', buffer(b'\xff'), 0, 1,
'ordinal not in range'),
- {'args' : ('ascii', b'\xff', 0, 1,
+ {'args' : ('ascii', buffer(b'\xff'), 0, 1,
'ordinal not in range'),
- 'encoding' : 'ascii', 'object' : b'\xff',
+ 'encoding' : 'ascii', 'object' : buffer(b'\xff'),
'start' : 0, 'reason' : 'ordinal not in range'}),
(UnicodeTranslateError, ("\u3042", 0, 1, "ouch"),
{'args' : ('\u3042', 0, 1, 'ouch'),
Modified: python/branches/py3k-pep3137/Lib/test/test_struct.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/test/test_struct.py (original)
+++ python/branches/py3k-pep3137/Lib/test/test_struct.py Fri Nov 2 12:41:44 2007
@@ -101,7 +101,7 @@
simple_err(struct.unpack, 'iii', s)
simple_err(struct.unpack, 'i', s)
-c = str8(b'a')
+c = b'a'
b = 1
h = 255
i = 65535
@@ -184,9 +184,9 @@
xfmt, n, len(res)))
rev = struct.unpack(xfmt, res)[0]
if isinstance(arg, str):
- # Strings are returned as str8 since you can't know the encoding of
+ # Strings are returned as bytes since you can't know the encoding of
# the string when packed.
- arg = str8(arg, 'latin1')
+ arg = bytes(arg, 'latin1')
if rev != arg and not asy:
raise TestFailed("unpack(%r, %r) -> (%r,) # expected (%r,)" % (
fmt, res, rev, arg))
@@ -428,14 +428,14 @@
def test_p_code():
for code, input, expected, expectedback in [
- ('p','abc', '\x00', str8()),
- ('1p', 'abc', '\x00', str8()),
- ('2p', 'abc', '\x01a', str8(b'a')),
- ('3p', 'abc', '\x02ab', str8(b'ab')),
- ('4p', 'abc', '\x03abc', str8(b'abc')),
- ('5p', 'abc', '\x03abc\x00', str8(b'abc')),
- ('6p', 'abc', '\x03abc\x00\x00', str8(b'abc')),
- ('1000p', 'x'*1000, '\xff' + 'x'*999, str8(b'x'*255))]:
+ ('p','abc', '\x00', b''),
+ ('1p', 'abc', '\x00', b''),
+ ('2p', 'abc', '\x01a', b'a'),
+ ('3p', 'abc', '\x02ab', b'ab'),
+ ('4p', 'abc', '\x03abc', b'abc'),
+ ('5p', 'abc', '\x03abc\x00', b'abc'),
+ ('6p', 'abc', '\x03abc\x00\x00', b'abc'),
+ ('1000p', 'x'*1000, '\xff' + 'x'*999, b'x'*255)]:
expected = bytes(expected, "latin-1")
got = struct.pack(code, input)
if got != expected:
@@ -560,26 +560,26 @@
test_string = b'abcd01234'
fmt = '4s'
s = struct.Struct(fmt)
- for cls in (str, str8, bytes): # XXX + memoryview
+ for cls in (str, buffer, bytes):
if verbose:
print("test_unpack_from using", cls.__name__)
data = cls(test_string)
- if not isinstance(data, (str8, bytes)):
- bytes_data = str8(data, 'latin1')
+ if not isinstance(data, (buffer, bytes)):
+ bytes_data = bytes(data, 'latin1')
else:
bytes_data = data
- vereq(s.unpack_from(data), (str8(b'abcd'),))
- vereq(s.unpack_from(data, 2), (str8(b'cd01'),))
- vereq(s.unpack_from(data, 4), (str8(b'0123'),))
+ vereq(s.unpack_from(data), (b'abcd',))
+ vereq(s.unpack_from(data, 2), (b'cd01',))
+ vereq(s.unpack_from(data, 4), (b'0123',))
for i in range(6):
vereq(s.unpack_from(data, i), (bytes_data[i:i+4],))
for i in range(6, len(test_string) + 1):
simple_err(s.unpack_from, data, i)
- for cls in (str, str8, bytes): # XXX + memoryview
+ for cls in (str, buffer, bytes):
data = cls(test_string)
- vereq(struct.unpack_from(fmt, data), (str8(b'abcd'),))
- vereq(struct.unpack_from(fmt, data, 2), (str8(b'cd01'),))
- vereq(struct.unpack_from(fmt, data, 4), (str8(b'0123'),))
+ vereq(struct.unpack_from(fmt, data), (b'abcd',))
+ vereq(struct.unpack_from(fmt, data, 2), (b'cd01',))
+ vereq(struct.unpack_from(fmt, data, 4), (b'0123',))
for i in range(6):
vereq(struct.unpack_from(fmt, data, i), (bytes_data[i:i+4],))
for i in range(6, len(test_string) + 1):
Modified: python/branches/py3k-pep3137/Lib/test/test_unicodedata.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/test/test_unicodedata.py (original)
+++ python/branches/py3k-pep3137/Lib/test/test_unicodedata.py Fri Nov 2 12:41:44 2007
@@ -176,7 +176,8 @@
def test_east_asian_width(self):
eaw = self.db.east_asian_width
- self.assertRaises(TypeError, eaw, str8(b'a'))
+ self.assertRaises(TypeError, eaw, b'a')
+ self.assertRaises(TypeError, eaw, buffer())
self.assertRaises(TypeError, eaw, '')
self.assertRaises(TypeError, eaw, 'ra')
self.assertEqual(eaw('\x1e'), 'N')
Modified: python/branches/py3k-pep3137/Modules/_hashopenssl.c
==============================================================================
--- python/branches/py3k-pep3137/Modules/_hashopenssl.c (original)
+++ python/branches/py3k-pep3137/Modules/_hashopenssl.c Fri Nov 2 12:41:44 2007
@@ -108,7 +108,7 @@
digest_size = EVP_MD_CTX_size(&temp_ctx);
EVP_DigestFinal(&temp_ctx, digest, NULL);
- retval = PyBytes_FromStringAndSize((const char *)digest, digest_size);
+ retval = PyString_FromStringAndSize((const char *)digest, digest_size);
EVP_MD_CTX_cleanup(&temp_ctx);
return retval;
}
Modified: python/branches/py3k-pep3137/Python/pythonrun.c
==============================================================================
--- python/branches/py3k-pep3137/Python/pythonrun.c (original)
+++ python/branches/py3k-pep3137/Python/pythonrun.c Fri Nov 2 12:41:44 2007
@@ -234,6 +234,7 @@
if (pstderr == NULL)
Py_FatalError("Py_Initialize: can't set preliminary stderr");
PySys_SetObject("stderr", pstderr);
+ PySys_SetObject("__stderr__", pstderr);
_PyImport_Init();
More information about the Python-3000-checkins
mailing list