[issue17087] Improve the repr for regular expression match objects

2013-11-25 Thread Roundup Robot
Roundup Robot added the comment: New changeset 4ba7a29fe02c by Ezio Melotti in branch 'default': #13592, #17087: add whatsnew entry about regex/match object repr improvements. http://hg.python.org/cpython/rev/4ba7a29fe02c -- ___ Python tracker

[issue17087] Improve the repr for regular expression match objects

2013-10-20 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Thanks all participants for the discussion. -- resolution: -> fixed stage: patch review -> committed/rejected status: open -> closed ___ Python tracker _

[issue17087] Improve the repr for regular expression match objects

2013-10-20 Thread Roundup Robot
Roundup Robot added the comment: New changeset 29764a7bd6ba by Serhiy Storchaka in branch 'default': Issue #17087: Improved the repr for regular expression match objects. http://hg.python.org/cpython/rev/29764a7bd6ba -- nosy: +python-dev ___ Python tr

[issue17087] Improve the repr for regular expression match objects

2013-10-20 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: LGTM (except unrelated empty line at the end of Modules/_sre.c). -- ___ Python tracker ___ ___ Pyt

[issue17087] Improve the repr for regular expression match objects

2013-10-18 Thread Claudiu.Popa
Claudiu.Popa added the comment: Added patch based on Serhiy's, which addresses your comments. It drops the group count and renames group0 to `match`. -- Added file: http://bugs.python.org/file32216/sre_repr6.patch ___ Python tracker

[issue17087] Improve the repr for regular expression match objects

2013-10-18 Thread Ezio Melotti
Ezio Melotti added the comment: I discussed this briefly with Serhiy on IRC and I think the repr can be improved. Currently it looks like: >>> re.compile(r'[/\\]([.]svn)').match('/.svn') <_sre.SRE_Match object: groups=1, span=(0, 5), group0='/.svn'> One problem is that the group count doesn't i

[issue17087] Improve the repr for regular expression match objects

2013-10-17 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Well. Here is a patch. I have changed repr() a little. repr() now contains match type qualified name (_sre.SRE_Match). "groups" now equals len(m.groups()). "span" representation now contains a comma (as repr(m.span())). Raymond, Ezio, is it good to you? ---

[issue17087] Improve the repr for regular expression match objects

2013-10-16 Thread Claudiu.Popa
Claudiu.Popa added the comment: I could use self->pattern->logical_size, but it seems that I still need the call to getstring for bytes & co, to obtain the view to the underlying buffer (otherwise the group0 part from the repr will contain random bytes). I didn't find a simpler way to achieve

[issue17087] Improve the repr for regular expression match objects

2013-10-16 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It is too complicated (and perhaps erroneous). Why not use just self->pattern->logical_charsize? -- ___ Python tracker ___ __

[issue17087] Improve the repr for regular expression match objects

2013-10-16 Thread Claudiu.Popa
Claudiu.Popa added the comment: Latest patch attached. -- Added file: http://bugs.python.org/file32144/sre_repr5.patch ___ Python tracker ___

[issue17087] Improve the repr for regular expression match objects

2013-10-16 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Use correct first argument to getslice(). -- ___ Python tracker ___ ___ Python-bugs-list mailing l

[issue17087] Improve the repr for regular expression match objects

2013-10-16 Thread Claudiu.Popa
Claudiu.Popa added the comment: Added the new patch, which addresses Serhiy's comments. Also, this approach fails when bytes are involved: >>> import re >>> re.search(b"a", b"a") Assertion failed: (PyUnicode_Check(op)), function _PyUnicode_CheckConsistency, file Objects/unicodeobject.c, line 30

[issue17087] Improve the repr for regular expression match objects

2013-10-16 Thread Claudiu.Popa
Claudiu.Popa added the comment: Serhiy, are there any left issues with my latest patch? It would be nice if we could get this into 3.4. -- ___ Python tracker ___ ___

[issue17087] Improve the repr for regular expression match objects

2013-09-13 Thread Claudiu.Popa
Claudiu.Popa added the comment: Added the new version. -- Added file: http://bugs.python.org/file31746/sre_repr3.patch ___ Python tracker ___

[issue17087] Improve the repr for regular expression match objects

2013-09-13 Thread Claudiu.Popa
Claudiu.Popa added the comment: Here's the new version. I added a few replies on the Rietveld. -- Added file: http://bugs.python.org/file31744/sre_repr2.patch ___ Python tracker

[issue17087] Improve the repr for regular expression match objects

2013-09-13 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Well, then first will commit a simpler patch. I left comments on Rietveld. -- ___ Python tracker ___ _

[issue17087] Improve the repr for regular expression match objects

2013-09-13 Thread Claudiu.Popa
Claudiu.Popa added the comment: Serhiy, at the first glance, that repr doesn't make sense to me, thus it seems a little difficult to comprehend. -- ___ Python tracker ___ __

[issue17087] Improve the repr for regular expression match objects

2013-09-12 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: What about such output? >>> re.search('p((a)|(b))(c)?', 'unpack') Or may be ('p', [['a'], []], ['c']) if you prefer legal Python expression. -- ___ Python tracker

[issue17087] Improve the repr for regular expression match objects

2013-08-20 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- nosy: +serhiy.storchaka stage: needs patch -> patch review ___ Python tracker ___ ___ Python-bugs-lis

[issue17087] Improve the repr for regular expression match objects

2013-08-20 Thread Claudiu.Popa
Claudiu.Popa added the comment: Here's my patch attempt. The repr of a match object has the following format: (groups=\d+, span=(start, end), group0=the entire group or the first X characters, where X is represented by a new constant in sre_constants.h, SRE_MATCH_REPR_SIZE). -- keyword

[issue17087] Improve the repr for regular expression match objects

2013-01-31 Thread Ezio Melotti
Ezio Melotti added the comment: #13592 is indeed the issue I was thinking about, but apparently that's about _sre.SRE_Pattern, so it's not the same thing. > Just showing group(0) should be helpful. Often the interesting group is group(1), so showing only group(0) seems a bit arbitrary. > And

[issue17087] Improve the repr for regular expression match objects

2013-01-30 Thread Raymond Hettinger
Raymond Hettinger added the comment: Just showing group(0) should be helpful. And perhaps the number of groups. If a string is really long, we can truncate it like reprlib does. The main goal is to make it easier to work with match objects at the interactive prompt. They are currently too

[issue17087] Improve the repr for regular expression match objects

2013-01-30 Thread Chris Jerdonek
Chris Jerdonek added the comment: Is this a duplicate of issue 13592? -- nosy: +chris.jerdonek ___ Python tracker ___ ___ Python-bugs-

[issue17087] Improve the repr for regular expression match objects

2013-01-30 Thread Ezio Melotti
Ezio Melotti added the comment: Showing start and stop would be OK, but there might be many groups and they might contain lot of text, so they can't simply be included in the repr as they are. FWIW there was another issue about changing _sre.SRE_Match to something better, but I can't find it r

[issue17087] Improve the repr for regular expression match objects

2013-01-30 Thread Raymond Hettinger
New submission from Raymond Hettinger: Experience teaching Python has shown that people have a hard time learning to work with match objects. A contributing cause is the opaque repr: >>> import re >>> s = 'On 3/14/2013, Python celebrate Pi day.' >>> mo = re.search(r'\d+/\d+/\d+', s