2323SPECIAL_CHARS = ".\\ [{()*+?^$|"
2424REPEAT_CHARS = "*+?{"
2525
26- DIGITS = string .digits
26+ DIGITS = tuple ( string .digits )
2727
28- OCTDIGITS = "01234567"
29- HEXDIGITS = "0123456789abcdefABCDEF"
28+ OCTDIGITS = tuple ( "01234567" )
29+ HEXDIGITS = tuple ( "0123456789abcdefABCDEF" )
3030
3131WHITESPACE = string .whitespace
3232
@@ -188,13 +188,13 @@ def _class_escape(source, escape):
188188 return code
189189 try :
190190 if escape [1 :2 ] == "x" :
191- while source .next and source . next in HEXDIGITS :
191+ while source .next in HEXDIGITS :
192192 escape = escape + source .get ()
193193 escape = escape [2 :]
194194 # FIXME: support unicode characters!
195195 return LITERAL , chr (int (escape [- 4 :], 16 ) & 0xff )
196196 elif str (escape [1 :2 ]) in OCTDIGITS :
197- while source .next and source . next in OCTDIGITS :
197+ while source .next in OCTDIGITS :
198198 escape = escape + source .get ()
199199 escape = escape [1 :]
200200 # FIXME: support unicode characters!
@@ -215,20 +215,20 @@ def _escape(source, escape, state):
215215 return code
216216 try :
217217 if escape [1 :2 ] == "x" :
218- while source .next and source . next in HEXDIGITS :
218+ while source .next in HEXDIGITS :
219219 escape = escape + source .get ()
220220 escape = escape [2 :]
221221 # FIXME: support unicode characters!
222222 return LITERAL , chr (int (escape [- 4 :], 16 ) & 0xff )
223- elif str ( escape [1 :2 ]) in DIGITS :
223+ elif escape [1 :2 ] in DIGITS :
224224 while 1 :
225225 group = _group (escape , state )
226226 if group :
227227 if (not source .next or
228228 not _group (escape + source .next , state )):
229229 return GROUP , group
230230 escape = escape + source .get ()
231- elif source .next and source . next in OCTDIGITS :
231+ elif source .next in OCTDIGITS :
232232 escape = escape + source .get ()
233233 else :
234234 break
@@ -372,10 +372,10 @@ def _parse(source, state, flags=0):
372372 elif this == "{" :
373373 min , max = 0 , MAXREPEAT
374374 lo = hi = ""
375- while source .next and source . next in DIGITS :
375+ while source .next in DIGITS :
376376 lo = lo + source .get ()
377377 if source .match ("," ):
378- while source .next and source . next in DIGITS :
378+ while source .next in DIGITS :
379379 hi = hi + source .get ()
380380 else :
381381 hi = lo
0 commit comments