diff options
author | Guido van Rossum <guido@python.org> | 2007-10-19 22:06:24 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-10-19 22:06:24 (GMT) |
commit | 75a902db7859a4751743e98530c5d96a672641be (patch) | |
tree | a730c966dcfc993a800078004aae3a6094a75a6a /Lib/sre_parse.py | |
parent | 21431e85d505b9698c085c25cbf1b2997a352b85 (diff) | |
download | cpython-75a902db7859a4751743e98530c5d96a672641be.zip cpython-75a902db7859a4751743e98530c5d96a672641be.tar.gz cpython-75a902db7859a4751743e98530c5d96a672641be.tar.bz2 |
Patch 1280, by Alexandre Vassalotti.
Make PyString's indexing and iteration return integers.
(I changed a few of Alexandre's decisions -- GvR.)
Diffstat (limited to 'Lib/sre_parse.py')
-rw-r--r-- | Lib/sre_parse.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py index 22e762b..bf3e23f 100644 --- a/Lib/sre_parse.py +++ b/Lib/sre_parse.py @@ -189,12 +189,18 @@ class Tokenizer: if self.index >= len(self.string): self.next = None return - char = self.string[self.index] - if char[0] == "\\": + char = self.string[self.index:self.index+1] + # Special case for the str8, since indexing returns a integer + # XXX This is only needed for test_bug_926075 in test_re.py + if isinstance(self.string, str8): + char = chr(char) + if char == "\\": try: c = self.string[self.index + 1] except IndexError: raise error("bogus escape (end of line)") + if isinstance(self.string, str8): + char = chr(c) char = char + c self.index = self.index + len(char) self.next = char |