This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients Ramchandra Apte, loewis, orsenthil, python-dev, roger.serwy, serhiy.storchaka, terry.reedy
Date 2012-07-09.20:45:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Thanks Martin. I was thinking of adding special-casing inside the rpcproxy class, but the wrapping is pretty clean and clear. Works great in 3.3 Win7-64.

The 2.7 message 'expected a character buffer object' is technically correct*, but opaque, especially to beginners. I actually prefer the 3.x style message, except that 'str' should be expanded to 'string'. (We especially should not say 'character buffer object' until we test for exactly that.)

*My impression is that 2.7 unicode is not a character buffer object, but gets auto converted to str/bytes, which is.

On the technically correct front, bytearray in 2.7 is a character buffer object that .write() can write, but it is not a subclass of basestring. So the widened test in the followup patch
should be widened further.

-        if not isinstance(s, basestring):
-             raise TypeError('must be str, not ' + type(s).__name__)

+        if not isinstance(s, (basestring, bytearray)):
+             raise TypeError('must be string, not ' + type(s).__name__)

Are there any other 'character buffer' classes that should be included? What *is* the test that 2.7 .write() uses to determine what is such? Can it even be written in Python (rather than C)?
Date User Action Args
2012-07-09 20:45:14terry.reedysetrecipients: + terry.reedy, loewis, orsenthil, roger.serwy, python-dev, Ramchandra Apte, serhiy.storchaka
2012-07-09 20:45:14terry.reedysetmessageid: <>
2012-07-09 20:45:13terry.reedylinkissue13532 messages
2012-07-09 20:45:13terry.reedycreate