@@ -225,13 +225,25 @@ def tell(self):
225225 def seek (self , index ):
226226 self .index , self .next = index
227227
228+ # The following three functions are not used in this module anymore, but we keep
229+ # them here (with DeprecationWarnings) for backwards compatibility.
230+
228231def isident (char ):
232+ import warnings
233+ warnings .warn ('sre_parse.isident() will be removed in 3.5' ,
234+ DeprecationWarning , stacklevel = 2 )
229235 return "a" <= char <= "z" or "A" <= char <= "Z" or char == "_"
230236
231237def isdigit (char ):
238+ import warnings
239+ warnings .warn ('sre_parse.isdigit() will be removed in 3.5' ,
240+ DeprecationWarning , stacklevel = 2 )
232241 return "0" <= char <= "9"
233242
234243def isname (name ):
244+ import warnings
245+ warnings .warn ('sre_parse.isname() will be removed in 3.5' ,
246+ DeprecationWarning , stacklevel = 2 )
235247 # check that group name is a valid string
236248 if not isident (name [0 ]):
237249 return False
@@ -587,7 +599,7 @@ def _parse(source, state):
587599 group = 1
588600 if not name :
589601 raise error ("missing group name" )
590- if not isname ( name ):
602+ if not name . isidentifier ( ):
591603 raise error ("bad character in group name" )
592604 elif sourcematch ("=" ):
593605 # named backreference
@@ -601,7 +613,7 @@ def _parse(source, state):
601613 name = name + char
602614 if not name :
603615 raise error ("missing group name" )
604- if not isname ( name ):
616+ if not name . isidentifier ( ):
605617 raise error ("bad character in group name" )
606618 gid = state .groupdict .get (name )
607619 if gid is None :
@@ -655,7 +667,7 @@ def _parse(source, state):
655667 group = 2
656668 if not condname :
657669 raise error ("missing group name" )
658- if isname ( condname ):
670+ if condname . isidentifier ( ):
659671 condgroup = state .groupdict .get (condname )
660672 if condgroup is None :
661673 raise error ("unknown group name" )
@@ -792,7 +804,7 @@ def literal(literal, p=p, pappend=a):
792804 if index < 0 :
793805 raise error ("negative group number" )
794806 except ValueError :
795- if not isname ( name ):
807+ if not name . isidentifier ( ):
796808 raise error ("bad character in group name" )
797809 try :
798810 index = pattern .groupindex [name ]
0 commit comments