summaryrefslogtreecommitdiffstats
path: root/Lib/dos-8x3/sre_pars.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2000-09-05 04:49:50 (GMT)
committerGuido van Rossum <guido@python.org>2000-09-05 04:49:50 (GMT)
commite2ab1451cf4f5fb4b3ce6cb2e1598fab4a2f9eed (patch)
tree4ae42008f3ae9b480550c4a542fe08a91af6916e /Lib/dos-8x3/sre_pars.py
parent10912854a29185fe41eba93be6e87bdd75278acb (diff)
downloadcpython-e2ab1451cf4f5fb4b3ce6cb2e1598fab4a2f9eed.zip
cpython-e2ab1451cf4f5fb4b3ce6cb2e1598fab4a2f9eed.tar.gz
cpython-e2ab1451cf4f5fb4b3ce6cb2e1598fab4a2f9eed.tar.bz2
The usual.
Diffstat (limited to 'Lib/dos-8x3/sre_pars.py')
-rw-r--r--Lib/dos-8x3/sre_pars.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/Lib/dos-8x3/sre_pars.py b/Lib/dos-8x3/sre_pars.py
index a50191e..55de24c 100644
--- a/Lib/dos-8x3/sre_pars.py
+++ b/Lib/dos-8x3/sre_pars.py
@@ -15,9 +15,9 @@ from sre_constants import *
MAXREPEAT = 65535
SPECIAL_CHARS = ".\\[{()*+?^$|"
-REPEAT_CHARS = "*+?{"
+REPEAT_CHARS = "*+?{"
-DIGITS = tuple("012345689")
+DIGITS = tuple("0123456789")
OCTDIGITS = tuple("01234567")
HEXDIGITS = tuple("0123456789abcdefABCDEF")
@@ -259,13 +259,12 @@ def _escape(source, escape, state):
# hexadecimal escape
while source.next in HEXDIGITS and len(escape) < 4:
escape = escape + source.get()
- escape = escape[2:]
- if len(escape) != 2:
- raise error, "bogus escape: %s" % repr("\\" + escape)
- return LITERAL, int(escape, 16) & 0xff
+ if len(escape) != 4:
+ raise ValueError
+ return LITERAL, int(escape[2:], 16) & 0xff
elif escape[1:2] == "0":
# octal escape
- while source.next in OCTDIGITS and len(escape) < 5:
+ while source.next in OCTDIGITS and len(escape) < 4:
escape = escape + source.get()
return LITERAL, int(escape[1:], 8) & 0xff
elif escape[1:2] in DIGITS:
@@ -273,7 +272,8 @@ def _escape(source, escape, state):
here = source.tell()
if source.next in DIGITS:
escape = escape + source.get()
- if escape[2] in OCTDIGITS and source.next in OCTDIGITS:
+ if (escape[1] in OCTDIGITS and escape[2] in OCTDIGITS and
+ source.next in OCTDIGITS):
# got three octal digits; this is an octal escape
escape = escape + source.get()
return LITERAL, int(escape[1:], 8) & 0xff
@@ -281,7 +281,7 @@ def _escape(source, escape, state):
group = _group(escape, state.groups)
if group:
return GROUPREF, group
- raise error, "bogus escape: %s" % repr(escape)
+ raise ValueError
if len(escape) == 2:
return LITERAL, ord(escape[1])
except ValueError: