diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2011-04-10 12:59:16 +0300 |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2011-04-10 12:59:16 +0300 |
commit | 88fdeb45ef86385b5ac212929fbbf69711f9245a (patch) | |
tree | b47ec89f01df6c7ce0518ad8fe5e261f4694fec6 /Lib/re.py | |
parent | 344d26c7a08896a1eb54f638e80de0d0fadfad39 (diff) | |
download | cpython-git-88fdeb45ef86385b5ac212929fbbf69711f9245a.tar.gz |
#2650: re.escape() no longer escapes the "_".
Diffstat (limited to 'Lib/re.py')
-rw-r--r-- | Lib/re.py | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -215,12 +215,14 @@ def template(pattern, flags=0): return _compile(pattern, flags|T) _alphanum_str = frozenset( - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890") + "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890") _alphanum_bytes = frozenset( - b"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890") + b"_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890") def escape(pattern): - "Escape all non-alphanumeric characters in pattern." + """ + Escape all the characters in pattern except ASCII letters, numbers and '_'. + """ if isinstance(pattern, str): alphanum = _alphanum_str s = list(pattern) |