Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2)

Side by Side Diff: Lib/sre_parse.py

Issue 12759: "(?P=)" input for Tools/scripts/redemo.py raises unnhandled exception
Patch Set: Created 8 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Lib/test/test_re.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # 1 #
2 # Secret Labs' Regular Expression Engine 2 # Secret Labs' Regular Expression Engine
3 # 3 #
4 # convert re-style regular expression to sre pattern 4 # convert re-style regular expression to sre pattern
5 # 5 #
6 # Copyright (c) 1998-2001 by Secret Labs AB. All rights reserved. 6 # Copyright (c) 1998-2001 by Secret Labs AB. All rights reserved.
7 # 7 #
8 # See the sre.py file for information on usage and redistribution. 8 # See the sre.py file for information on usage and redistribution.
9 # 9 #
10 10
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 self.index, self.next = index 215 self.index, self.next = index
216 216
217 def isident(char): 217 def isident(char):
218 return "a" <= char <= "z" or "A" <= char <= "Z" or char == "_" 218 return "a" <= char <= "z" or "A" <= char <= "Z" or char == "_"
219 219
220 def isdigit(char): 220 def isdigit(char):
221 return "0" <= char <= "9" 221 return "0" <= char <= "9"
222 222
223 def isname(name): 223 def isname(name):
224 # check that group name is a valid string 224 # check that group name is a valid string
225 if name == "":
226 return False
225 if not isident(name[0]): 227 if not isident(name[0]):
226 return False 228 return False
227 for char in name[1:]: 229 for char in name[1:]:
228 if not isident(char) and not isdigit(char): 230 if not isident(char) and not isdigit(char):
229 return False 231 return False
230 return True 232 return True
231 233
232 def _class_escape(source, escape): 234 def _class_escape(source, escape):
233 # handle escape code inside character class 235 # handle escape code inside character class
234 code = ESCAPES.get(escape) 236 code = ESCAPES.get(escape)
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 groups, literals = template 809 groups, literals = template
808 literals = literals[:] 810 literals = literals[:]
809 try: 811 try:
810 for index, group in groups: 812 for index, group in groups:
811 literals[index] = s = g(group) 813 literals[index] = s = g(group)
812 if s is None: 814 if s is None:
813 raise error("unmatched group") 815 raise error("unmatched group")
814 except IndexError: 816 except IndexError:
815 raise error("invalid group reference") 817 raise error("invalid group reference")
816 return sep.join(literals) 818 return sep.join(literals)
OLDNEW
« no previous file with comments | « no previous file | Lib/test/test_re.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+