Christian Heimes added the comment:
Here is an updated patch that fixes an error in httplib that was causing
the xmlrpc test suite to block.
Added file: http://bugs.python.org/file8695/py3k-pep3137_remove_str_bytes2.patch
__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1392>
__________________________________
Index: Objects/bytesobject.c
===================================================================
--- Objects/bytesobject.c (Revision 58857)
+++ Objects/bytesobject.c (Arbeitskopie)
@@ -923,6 +923,14 @@
}
static PyObject *
+bytes_str(PyObject *op)
+{
+ PyErr_SetString(PyExc_TypeError,
+ "str() argument must not be a buffer instance.");
+ return NULL;
+}
+
+static PyObject *
bytes_richcompare(PyObject *self, PyObject *other, int op)
{
Py_ssize_t self_size, other_size;
@@ -3063,7 +3071,7 @@
&bytes_as_mapping, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
- (reprfunc)bytes_repr, /* tp_str */
+ bytes_str, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
&bytes_as_buffer, /* tp_as_buffer */
Index: Objects/stringobject.c
===================================================================
--- Objects/stringobject.c (Revision 58857)
+++ Objects/stringobject.c (Arbeitskopie)
@@ -679,6 +679,14 @@
return PyString_Repr(op, 1);
}
+static PyObject *
+string_str(PyObject *op)
+{
+ PyErr_SetString(PyExc_TypeError,
+ "str() argument must not be a byte instance.");
+ return NULL;
+}
+
static Py_ssize_t
string_length(PyStringObject *a)
{
@@ -3090,13 +3098,13 @@
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_compare */
- string_repr, /* tp_repr */
+ (reprfunc)string_repr, /* tp_repr */
0, /* tp_as_number */
&string_as_sequence, /* tp_as_sequence */
&string_as_mapping, /* tp_as_mapping */
(hashfunc)string_hash, /* tp_hash */
0, /* tp_call */
- string_repr, /* tp_str */
+ string_str, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
&string_as_buffer, /* tp_as_buffer */
Index: Lib/httplib.py
===================================================================
--- Lib/httplib.py (Revision 58857)
+++ Lib/httplib.py (Arbeitskopie)
@@ -827,6 +827,7 @@
if self.port == HTTP_PORT:
self.putheader('Host', host_enc)
else:
+ host_enc = host_enc.decode("ascii")
self.putheader('Host', "%s:%s" % (host_enc, self.port))
# note: we are assuming that clients will not attempt to set these
Index: Lib/test/test_xmlrpc.py
===================================================================
--- Lib/test/test_xmlrpc.py (Revision 58857)
+++ Lib/test/test_xmlrpc.py (Arbeitskopie)
@@ -6,6 +6,7 @@
import xmlrpclib
import SimpleXMLRPCServer
import threading
+import traceback
import mimetools
from test import test_support
@@ -328,6 +329,9 @@
except xmlrpclib.ProtocolError as e:
# protocol error; provide additional information in test output
self.fail("%s\n%s" % (e, e.headers))
+ except:
+ traceback.print_exc(file=sys.stderr)
+ raise
def test_introspection2(self):
try:
Index: Lib/test/test_bytes.py
===================================================================
--- Lib/test/test_bytes.py (Revision 58857)
+++ Lib/test/test_bytes.py (Arbeitskopie)
@@ -86,16 +86,22 @@
self.assertRaises(ValueError, buffer, [sys.maxint+1])
self.assertRaises(ValueError, buffer, [10**100])
- def test_repr_str(self):
- for f in str, repr:
- self.assertEqual(f(buffer()), "buffer(b'')")
- self.assertEqual(f(buffer([0])), "buffer(b'\\x00')")
- self.assertEqual(f(buffer([0, 1, 254, 255])),
- "buffer(b'\\x00\\x01\\xfe\\xff')")
- self.assertEqual(f(b"abc"), "b'abc'")
- self.assertEqual(f(b"'"), '''b"'"''')
- self.assertEqual(f(b"'\""), r"""b'\'"'""")
+ def test_repr(self):
+ self.assertEqual(repr(buffer()), "buffer(b'')")
+ self.assertEqual(repr(buffer([0])), "buffer(b'\\x00')")
+ self.assertEqual(repr(buffer([0, 1, 254, 255])),
+ "buffer(b'\\x00\\x01\\xfe\\xff')")
+ self.assertEqual(repr(b"abc"), "b'abc'")
+ self.assertEqual(repr(b"'"), '''b"'"''')
+ self.assertEqual(repr(b"'\""), r"""b'\'"'""")
+ def test_str(self):
+ self.assertRaises(TypeError, str, buffer())
+ self.assertRaises(TypeError, str, buffer([0]))
+ self.assertRaises(TypeError, str, buffer([0, 1, 254, 255]))
+ self.assertRaises(TypeError, str, b"abc")
+ self.assertRaises(TypeError, str, b"'")
+ self.assertRaises(TypeError, str, b"'\"")
def test_compare(self):
b1 = buffer([1, 2, 3])
@@ -370,11 +376,6 @@
b = buffer(buf)
self.assertEqual(b, buffer(sample))
- def test_to_str(self):
- self.assertEqual(str(b''), "b''")
- self.assertEqual(str(b'x'), "b'x'")
- self.assertEqual(str(b'\x80'), "b'\\x80'")
-
def test_from_int(self):
b = buffer(0)
self.assertEqual(b, buffer())
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com