Re: [Python-Dev] Misc re.match() complaint

2013-07-18 Thread Terry Reedy
On 7/18/2013 9:15 AM, Ezio Melotti wrote: In 3.x "string" means "str", "bytes" means "bytes", "bytes-like object" means "any object that supports the buffer protocol" [0] (including bytes). "string and bytes-like object" includes all of them. I don't think we need to introduce new terms. I a

Re: [Python-Dev] Misc re.match() complaint

2013-07-18 Thread Guido van Rossum
On Thu, Jul 18, 2013 at 6:15 AM, Ezio Melotti wrote: > I don't think we need to introduce new terms. +1 -- --Guido van Rossum (python.org/~guido) ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsub

Re: [Python-Dev] Misc re.match() complaint

2013-07-18 Thread Ezio Melotti
Hi, On Wed, Jul 17, 2013 at 6:15 AM, Stephen J. Turnbull wrote: > > BTW, I suggest that Terry's usage of "string" (to mean "str or bytes" > in 3.x, "unicode or str" in 2.x) be adopted, and Guido's "stringish" > be given expanded meaning, including buffer objects. "string" means "str", "bytes" me

Re: [Python-Dev] Misc re.match() complaint

2013-07-17 Thread MRAB
On 17/07/2013 05:15, Stephen J. Turnbull wrote: Terry Reedy writes: > On 7/15/2013 10:20 PM, Guido van Rossum wrote: > > >> Or is this something deeper, that a group *is* a new object in > >> principle? > > > > No, I just think of it as returning "a string" > > That is exactly wha

Re: [Python-Dev] Misc re.match() complaint

2013-07-17 Thread Serhiy Storchaka
16.07.13 20:21, Guido van Rossum написав(ла): The situation is most egregious if the target string is a bytearray, where there is currently no way to get the result as an immutable bytes object without an extra copy. (There's no API that lets you create a bytes object directly from a slice of a b

Re: [Python-Dev] Misc re.match() complaint

2013-07-17 Thread Stephen J. Turnbull
Terry Reedy writes: > > "stringish" > > This word is an adjective, not a noun. Ah, a strict grammarian. That trumps any cards I could possibly play. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/pytho

Re: [Python-Dev] Misc re.match() complaint

2013-07-17 Thread Terry Reedy
On 7/17/2013 12:15 AM, Stephen J. Turnbull wrote: Terry Reedy writes: > On 7/15/2013 10:20 PM, Guido van Rossum wrote: > > >> Or is this something deeper, that a group *is* a new object in > >> principle? > > > > No, I just think of it as returning "a string" > > That is exactly w

Re: [Python-Dev] Misc re.match() complaint

2013-07-16 Thread Stephen J. Turnbull
Terry Reedy writes: > On 7/15/2013 10:20 PM, Guido van Rossum wrote: > > >> Or is this something deeper, that a group *is* a new object in > >> principle? > > > > No, I just think of it as returning "a string" > > That is exactly what the doc says it does. See my other post. The problem

Re: [Python-Dev] Misc re.match() complaint

2013-07-16 Thread Guido van Rossum
On Tue, Jul 16, 2013 at 12:55 AM, Antoine Pitrou wrote: > Is there a strong enough use case to change it? I can't say the current > behaviour seems very useful either, but some people may depend on it. This is the crucial question. I personally see the current behavior as an artifact of the (lack

Re: [Python-Dev] Misc re.match() complaint

2013-07-16 Thread Nick Coghlan
On 16 July 2013 19:18, Terry Reedy wrote: > I wonder if the change was an artifact of changing the code to prohibit > mixing Unicode and bytes. I'm pretty sure we the only thing we changed in 3.x is to migrate re to the PEP 3118 buffer API, and the behavioural change Guido is seeing is actually t

Re: [Python-Dev] Misc re.match() complaint

2013-07-16 Thread Terry Reedy
On 7/15/2013 10:20 PM, Guido van Rossum wrote: Or is this something deeper, that a group *is* a new object in principle? No, I just think of it as returning "a string" That is exactly what the doc says it does. See my other post. -- Terry Jan Reedy _

Re: [Python-Dev] Misc re.match() complaint

2013-07-16 Thread Terry Reedy
On 7/15/2013 7:14 PM, Guido van Rossum wrote: In a discussion about mypy I discovered that the Python 3 version of the re module's Match object behaves subtly different from the Python 2 version when the target string (i.e. the haystack, not the needle) is a buffer object. In Python 2, the type

Re: [Python-Dev] Misc re.match() complaint

2013-07-16 Thread Antoine Pitrou
Le Mon, 15 Jul 2013 21:53:42 -0700, Guido van Rossum a écrit : > Hm. I'd still like to change this, but I understand it's debatable... > Is the group() method written in C or Python? Is there a strong enough use case to change it? I can't say the current behaviour seems very useful either, but so

Re: [Python-Dev] Misc re.match() complaint

2013-07-15 Thread Nick Coghlan
On 16 July 2013 14:53, Guido van Rossum wrote: > Hm. I'd still like to change this, but I understand it's debatable... > Is the group() method written in C or Python? If it's in C it should > be simple enough to let it just do a little bit of pointer math and > construct a bytes object from the gi

Re: [Python-Dev] Misc re.match() complaint

2013-07-15 Thread Stephen J. Turnbull
Guido van Rossum writes: > I'm not sure I understand you. :-( My apologies. This: > > Or is this something deeper, that a group *is* a new object in > > principle? > > No, I just think of it as returning "a string" and I think it's most > useful if that is always an immutable object, eve

Re: [Python-Dev] Misc re.match() complaint

2013-07-15 Thread Guido van Rossum
Hm. I'd still like to change this, but I understand it's debatable... Is the group() method written in C or Python? If it's in C it should be simple enough to let it just do a little bit of pointer math and construct a bytes object from the given area of memory -- after all, it must have a pointer

Re: [Python-Dev] Misc re.match() complaint

2013-07-15 Thread Nick Coghlan
On 16 July 2013 12:20, Guido van Rossum wrote: > On Mon, Jul 15, 2013 at 7:03 PM, Stephen J. Turnbull > wrote: >> Or is this something deeper, that a group *is* a new object in >> principle? > > No, I just think of it as returning "a string" and I think it's most > useful if that is always an im

Re: [Python-Dev] Misc re.match() complaint

2013-07-15 Thread Guido van Rossum
On Mon, Jul 15, 2013 at 7:18 PM, MRAB wrote: > On the other hand, I think that it's not unreasonable that the output > is the same type as the input. You could reason that what it's doing is > returning a slice of the input, and that slice should be the same type > as its source. By now I'm prett

Re: [Python-Dev] Misc re.match() complaint

2013-07-15 Thread Guido van Rossum
On Mon, Jul 15, 2013 at 7:03 PM, Stephen J. Turnbull wrote: > Guido van Rossum writes: > > > And I still think that any return type for group() except bytes or str > > is wrong. (Except possibly a subclass of these.) > > I'm not sure I understand. Do you mean in the context of the match > objec

Re: [Python-Dev] Misc re.match() complaint

2013-07-15 Thread MRAB
On 16/07/2013 01:25, Guido van Rossum wrote: On Mon, Jul 15, 2013 at 5:10 PM, MRAB wrote: On 16/07/2013 00:30, Gregory P. Smith wrote: On Mon, Jul 15, 2013 at 4:14 PM, Guido van Rossum mailto:gu...@python.org>> wrote: In a discussion about mypy I discovered that the Python 3 version of

Re: [Python-Dev] Misc re.match() complaint

2013-07-15 Thread Stephen J. Turnbull
Guido van Rossum writes: > And I still think that any return type for group() except bytes or str > is wrong. (Except possibly a subclass of these.) I'm not sure I understand. Do you mean in the context of the match object API, where constructing "(target, match.start(), match.end())" to get a

Re: [Python-Dev] Misc re.match() complaint

2013-07-15 Thread Guido van Rossum
On Mon, Jul 15, 2013 at 5:10 PM, MRAB wrote: > On 16/07/2013 00:30, Gregory P. Smith wrote: >> >> >> On Mon, Jul 15, 2013 at 4:14 PM, Guido van Rossum > > wrote: >> >> In a discussion about mypy I discovered that the Python 3 version of >> the re module's Match obj

Re: [Python-Dev] Misc re.match() complaint

2013-07-15 Thread Nick Coghlan
On 16 Jul 2013 09:17, "Guido van Rossum" wrote: > > Does anyone remember whether this was a conscious decision? I doubt it was a conscious decision - an unfortunate amount of the standard library's handling of the text model change falls into the category of "implementation accident" :( > Is it

Re: [Python-Dev] Misc re.match() complaint

2013-07-15 Thread MRAB
On 16/07/2013 00:30, Gregory P. Smith wrote: On Mon, Jul 15, 2013 at 4:14 PM, Guido van Rossum mailto:gu...@python.org>> wrote: In a discussion about mypy I discovered that the Python 3 version of the re module's Match object behaves subtly different from the Python 2 version when t

Re: [Python-Dev] Misc re.match() complaint

2013-07-15 Thread Guido van Rossum
Ok, created http://bugs.python.org/issue18468. On Mon, Jul 15, 2013 at 4:30 PM, Gregory P. Smith wrote: > > On Mon, Jul 15, 2013 at 4:14 PM, Guido van Rossum wrote: >> >> In a discussion about mypy I discovered that the Python 3 version of >> the re module's Match object behaves subtly different

Re: [Python-Dev] Misc re.match() complaint

2013-07-15 Thread Gregory P. Smith
On Mon, Jul 15, 2013 at 4:14 PM, Guido van Rossum wrote: > In a discussion about mypy I discovered that the Python 3 version of > the re module's Match object behaves subtly different from the Python > 2 version when the target string (i.e. the haystack, not the needle) > is a buffer object. > >

[Python-Dev] Misc re.match() complaint

2013-07-15 Thread Guido van Rossum
In a discussion about mypy I discovered that the Python 3 version of the re module's Match object behaves subtly different from the Python 2 version when the target string (i.e. the haystack, not the needle) is a buffer object. In Python 2, the type of the return value of group() is always either