Terry J. Reedy <tjre...@udel.edu> added the comment: 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 http://hg.python.org/cpython/rev/2993f566c82e 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)? ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue13532> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com