[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 be in the situation of wanting to use escape()d data in a 
character class. Even if I could think of a reason to do that, it's decidedly 
not the usual case.

It's http://bugs.python.org/issue2650 all over again, just with a different 
character (in that case, underscore).

While we're at it, what else shouldn't it be escaping?

--
components: Regular Expressions
files: rebugtest.py
messages: 194495
nosy: ezio.melotti, jjl, mrabarnett
priority: normal
severity: normal
status: open
title: re.escape should not escape the hyphen
type: behavior
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 
3.4, Python 3.5
Added file: http://bugs.python.org/file31166/rebugtest.py

___
Python tracker 
<http://bugs.python.org/issue18662>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 
<http://bugs.python.org/issue18662>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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

___
Python tracker 
<http://bugs.python.org/issue18662>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com