From: Guido van Rossum Date: Thu, 19 Feb 1998 21:18:56 +0000 (+0000) Subject: Fix for literal null bytes -- these must be replaced by the four X-Git-Tag: v1.5.1~641 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b1908846af1c70e77917d56798daa8242d80d2b5;p=python Fix for literal null bytes -- these must be replaced by the four characters \, 0, 0, 0. --- diff --git a/Lib/re.py b/Lib/re.py index 3fb9408367..e67d142ff1 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):