mirror of
https://github.com/python/cpython.git
synced 2025-08-01 23:53:15 +00:00
Fix a bug when there was a newline in the string expandtabs was called on.
This also catches another condition that can overflow. Will backport.
This commit is contained in:
parent
ba965deea8
commit
5c9a81a3d8
3 changed files with 21 additions and 4 deletions
|
@ -247,8 +247,13 @@ class CommonTest(unittest.TestCase):
|
|||
self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs')
|
||||
self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs', 8)
|
||||
self.checkequal('abc\r\nab\r\ndef\ng\r\nhi', 'abc\r\nab\r\ndef\ng\r\nhi', 'expandtabs', 4)
|
||||
self.checkequal(' a\n b', ' \ta\n\tb', 'expandtabs', 1)
|
||||
|
||||
self.checkraises(TypeError, 'hello', 'expandtabs', 42, 42)
|
||||
# This test is only valid when sizeof(int) == sizeof(void*) == 4.
|
||||
if sys.maxint < (1 << 32) and struct.calcsize('P') == 4:
|
||||
self.checkraises(OverflowError,
|
||||
'\ta\n\tb', 'expandtabs', sys.maxint)
|
||||
|
||||
def test_split(self):
|
||||
self.checkequal(['this', 'is', 'the', 'split', 'function'],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue