[issue18662] re.escape should not escape the hyphen

2013-08-06 Thread Matthew Barnett
Matthew Barnett added the comment: I can think of a real disadvantage with the current behaviour: it messes up Unicode graphemes. For example: >>> print('हिन्दी') हिन्दी >>> print(re.escape('हिन्दी')) \ह\ि\न\्\द\ी Of course, that's only a problem if you need to print it out or write it to a

[issue18662] re.escape should not escape the hyphen

2013-08-06 Thread Ezio Melotti
Changes by Ezio Melotti : -- stage: -> committed/rejected ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http

[issue18662] re.escape should not escape the hyphen

2013-08-06 Thread James Laver
James Laver added the comment: I looked up quotemeta with perldoc and you're right, it will quote the hyphen. Given that python's regex engine correctly deals with unnecessarily quoted characters, I suppose this is fine. -- resolution: -> wont fix status: open -> closed _

[issue18662] re.escape should not escape the hyphen

2013-08-05 Thread Ezio Melotti
Ezio Melotti added the comment: In #2650 re.escape() was updated to match Perl's behavior. I don't think there's any actual reason to change it -- it brings no benefits and it might break some code (even if admittedly it's not very likely). -- type: behavior -> enhancement versions:

[issue18662] re.escape should not escape the hyphen

2013-08-05 Thread James Laver
James Laver added the comment: Quite right, it does say that in the documentation. The documentation is perfectly correct, but the behaviour is wrong in my opinion and as you suggest, we should be escaping metacharacters only. -- ___ Python tracker

[issue18662] re.escape should not escape the hyphen

2013-08-05 Thread Matthew Barnett
Matthew Barnett added the comment: The help says: """>>> help(re.escape) Help on function escape in module re: escape(pattern) Escape all the characters in pattern except ASCII letters, numbers and '_'. """ The complementary approach is to escape _only_ the metacharacters. -- ___

[issue18662] re.escape should not escape the hyphen

2013-08-05 Thread James Laver
New submission from James Laver: Traceback (most recent call last): File "/Users/jlaver/retest.py", line 6, in test_escape self.assertEquals(re.escape('-'), '-') AssertionError: '\\-' != '-' The only place you can do bad things with hyphens is in a character class. I fail to see how you'd