mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Patch 1280, by Alexandre Vassalotti.
Make PyString's indexing and iteration return integers. (I changed a few of Alexandre's decisions -- GvR.)
This commit is contained in:
parent
21431e85d5
commit
75a902db78
9 changed files with 43 additions and 51 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue