On 10/15/07, Christian Heimes <<a href="mailto:lists@cheimes.de">lists@cheimes.de</a>> wrote:<br>> I'm working on the renaming of str8 -> bytes and bytes -> buffer.<br>> PyBytes (old bytes, new buffer) can take a string together with an
<br>> encoding and an optional error argument:<br>> <br>> <br>> >>> bytes(source="abc", encoding="ascii", errors="replace")<br>> b'abc'<br>> >>> str(b"abc", encoding="ascii")
<br>> 'abc'<br><br>Correct.<br><br>> IMO this should work<br>> >>> str8("abc", encoding="ascii")<br>> Traceback (most recent call last):<br>> File "<stdin>", line 1, in <module>
<br>> TypeError: 'encoding' is an invalid keyword argument for this function<br><br>Yes, this should work. (I thought it already did but was wrong. ;-)<br><br>> And this should break with a type error<br>> >>> str8("abc")
<br>> b'abc'<br><br>Correct.<br><br>> PyString' constructor doesn't take strings (PyUnicode). I like to add<br>> the support for strings to it. It makes the API of str, bytes and buffer<br>> consistent and fixes a *lot* of broken code and tests.
<br><br>Right.<br><br>> Are you confused by the name changes? I'm sometimes confused so I made a<br>> table:<br>> <br><span style="font-family: courier new,monospace;">> c name | old | new | repr</span>
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">> ------------------------------</span><span style="font-family: courier new,monospace;">-------------</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">> PyUnicode | str | - | ''</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">> PyString | str8 | bytes | b''
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">> PyBytes | bytes | buffer | buffer(b'')</span><br style="font-family: courier new,monospace;"><br>I'd rewrite this as follows:
<br><br><span style="font-family: courier new,monospace;">C name | 2.x | 3.0a1 | 3.0a2 |<br>----------+--------------+------------+---------------------+<br>PyUnicode | unicode u"" | str "" | str "" |
<br>PyString | str "" | str8 s"" | bytes "" |<br>PyBytes | N/A | bytes b"" | buffer buffer(b"") |<br></span><span style="font-family: courier new,monospace;">
----------+--------------+------------+---------------------+<br></span><br>Seems worth adding to the PEP. I'll do that.<br><span style="font-family: courier new,monospace;"><br></span>-- <br>--Guido van Rossum (home page:
<a href="http://www.python.org/~guido/">http://www.python.org/~guido/</a>)<br><br>