summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/re.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/re.py b/Lib/re.py
index 3fb9408..e67d142 100644
--- a/Lib/re.py
+++ b/Lib/re.py
@@ -66,8 +66,9 @@ def escape(pattern):
alphanum=string.letters+'_'+string.digits
for char in pattern:
if char not in alphanum:
- result.append('\\')
- result.append(char)
+ if char == '\000': result.append(r'\000')
+ else: result.append('\\' + char)
+ else: result.append(char)
return string.join(result, '')
def compile(pattern, flags=0):