Title: PEP 3137 patch (repr, names, parser)
Type: Stage:
Components: Interpreter Core Versions: Python 3.0
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: alexandre.vassalotti, christian.heimes, gregory.p.smith, gvanrossum
Priority: high Keywords: patch

Created on 2007-10-08 16:39 by christian.heimes, last changed 2007-10-31 23:30 by gvanrossum. This issue is now closed.

File name Uploaded Description Edit
pep3137.patch christian.heimes, 2007-10-08 16:39
change_bytes_repr_for_buffer.patch alexandre.vassalotti, 2007-10-09 03:28
change_string_repr_prefix.patch alexandre.vassalotti, 2007-10-09 03:29
tmp_test_bytes_fix.patch alexandre.vassalotti, 2007-10-09 03:29
py3k-pep3137_harmless.patch christian.heimes, 2007-10-27 04:05
Messages (8)
msg56280 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2007-10-08 16:39
The patches changes:

- change PyString's repr() to return "b'...'"
- change PyBytes's repr() to return "buffer(b'...')"
- change parser so that b"..." returns PyString, not PyBytes
- rename bytes -> buffer, str8 -> bytes

The patch breaks some unit test because some of the infrastructure like
the new buffer() isn't in place yet. I'm not happy with bytes_repr() but
the for loop with *p++ was the easiest way to implement it. Every other
implementation I could think of was either too complicated or wouldn't
work (like memcpy).
msg56282 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2007-10-09 03:28
I am not sure how the parser work, so I can't comment if your change to
it is correct. It would probably a better idea to keep it for later,
when the semantic differences between str8 and bytes objects will be

I think changing b'' to buffer(b''), in the tests, is not a good idea.
These tests will need to be changed again when bytes() will be changed
to str8().

Your changes to PyString and PyBytes look good to me. As I said on the
mailing list, I think the for-loops in bytes_repr() should be changed to:

    while (*quote_prefix)
        *p++ = *quote_prefix++;

I attached updated patches with the above change. I also replaced
bytes() for buffer() in PyBytes's docstrings.
msg56287 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-10-09 17:22
GHave you two agreed yet as to which patch(es) I should look at?
msg56289 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2007-10-09 18:19
Guido van Rossum wrote:
> Guido van Rossum added the comment:
> GHave you two agreed yet as to which patch(es) I should look at?

Please commit Alexandres patch. His patch for bytesobject.c is based on
my patch. It's more complete and a bit better than mine, too. I'm going
to create a new patch for the other tasks later.
msg56294 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-10-09 22:46
I don't think I can check these in yet; right now they are inconsistent.
But I will check them in when they are ready.
msg56806 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-10-26 18:26
Setting to 'high' everything related to PEP 3137.
msg56843 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2007-10-27 04:05
Here is the patch that contains only the harmless parts of the previous
patches. It changes a bunch of doc strings, changes the name of the
types and their repr() and str(). It also adds __builtin__.buffer but it
leaves __builtin__.bytes, __builtin__.str8 and b'' as they are.
msg57006 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-10-31 23:30
I've submitted the 'harmless' patch (and much, much more) in r58741.
I'm closing this now, the rest probably has been implemented one way or
another as well.  If you see something I missed, please open a new issue
with a patch for just that issue.
Date User Action Args
2007-10-31 23:30:20gvanrossumsetstatus: open -> closed
resolution: accepted
messages: + msg57006
2007-10-29 05:16:24gregory.p.smithsetnosy: + gregory.p.smith
2007-10-27 04:05:38christian.heimessetfiles: + py3k-pep3137_harmless.patch
messages: + msg56843
2007-10-26 18:26:19gvanrossumsetpriority: high
messages: + msg56806
2007-10-09 22:46:33gvanrossumsetassignee: gvanrossum
messages: + msg56294
2007-10-09 18:19:06christian.heimessetmessages: + msg56289
2007-10-09 17:22:44gvanrossumsetnosy: + gvanrossum
messages: + msg56287
2007-10-09 03:29:22alexandre.vassalottisetfiles: + tmp_test_bytes_fix.patch
2007-10-09 03:29:05alexandre.vassalottisetfiles: + change_string_repr_prefix.patch
2007-10-09 03:28:28alexandre.vassalottisetfiles: + change_bytes_repr_for_buffer.patch
nosy: + alexandre.vassalotti
messages: + msg56282
2007-10-08 16:53:58loewissetkeywords: + patch
2007-10-08 16:39:20christian.heimescreate