bpo-27772: Make preceding width with 0 valid in string format. (GH-11270)

Previously it was an error with confusing error message.
This commit is contained in:
Serhiy Storchaka 2021-01-25 11:56:33 +02:00 committed by GitHub
parent 8dfe15625e
commit cf19cc3b92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 3 deletions

View file

@ -1098,6 +1098,12 @@ class UnicodeTest(string_tests.CommonTest,
self.assertEqual('{0:^8s}'.format('result'), ' result ')
self.assertEqual('{0:^9s}'.format('result'), ' result ')
self.assertEqual('{0:^10s}'.format('result'), ' result ')
self.assertEqual('{0:8s}'.format('result'), 'result ')
self.assertEqual('{0:0s}'.format('result'), 'result')
self.assertEqual('{0:08s}'.format('result'), 'result00')
self.assertEqual('{0:<08s}'.format('result'), 'result00')
self.assertEqual('{0:>08s}'.format('result'), '00result')
self.assertEqual('{0:^08s}'.format('result'), '0result0')
self.assertEqual('{0:10000}'.format('a'), 'a' + ' ' * 9999)
self.assertEqual('{0:10000}'.format(''), ' ' * 10000)
self.assertEqual('{0:10000000}'.format(''), ' ' * 10000000)