mirror of
https://github.com/python/cpython.git
synced 2025-08-13 05:19:08 +00:00
#2650: Refactor re.escape and its tests.
This commit is contained in:
parent
72de205895
commit
4664563f34
2 changed files with 58 additions and 13 deletions
|
@ -207,8 +207,7 @@ def escape(pattern):
|
|||
"Escape all non-alphanumeric characters in pattern."
|
||||
s = list(pattern)
|
||||
alphanum = _alphanum
|
||||
for i in range(len(pattern)):
|
||||
c = pattern[i]
|
||||
for i, c in enumerate(pattern):
|
||||
if c not in alphanum:
|
||||
if c == "\000":
|
||||
s[i] = "\\000"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue