changeset: 104714:4a3892f49e1a user: Serhiy Storchaka date: Tue Oct 25 15:20:58 2016 +0300 files: Lib/calendar.py Lib/test/test_calendar.py Misc/NEWS description: Issue #28255: calendar.TextCalendar.prweek() no longer prints a space after a weeks's calendar. calendar.TextCalendar.pryear() no longer prints redundant newline after a year's calendar. Based on patch by Xiang Zhang. diff -r 049e58f74272 -r 4a3892f49e1a Lib/calendar.py --- a/Lib/calendar.py Tue Oct 25 15:03:59 2016 +0300 +++ b/Lib/calendar.py Tue Oct 25 15:20:58 2016 +0300 @@ -267,7 +267,7 @@ """ Print a single week (no newline). """ - print(self.formatweek(theweek, width), end=' ') + print(self.formatweek(theweek, width), end='') def formatday(self, day, weekday, width): """ @@ -371,7 +371,7 @@ def pryear(self, theyear, w=0, l=0, c=6, m=3): """Print a year's calendar.""" - print(self.formatyear(theyear, w, l, c, m)) + print(self.formatyear(theyear, w, l, c, m), end='') class HTMLCalendar(Calendar): diff -r 049e58f74272 -r 4a3892f49e1a Lib/test/test_calendar.py --- a/Lib/test/test_calendar.py Tue Oct 25 15:03:59 2016 +0300 +++ b/Lib/test/test_calendar.py Tue Oct 25 15:20:58 2016 +0300 @@ -404,7 +404,7 @@ with support.captured_stdout() as out: week = [(1,0), (2,1), (3,2), (4,3), (5,4), (6,5), (7,6)] calendar.TextCalendar().prweek(week, 1) - self.assertEqual(out.getvalue().strip(), "1 2 3 4 5 6 7") + self.assertEqual(out.getvalue(), " 1 2 3 4 5 6 7") def test_prmonth(self): with support.captured_stdout() as out: @@ -414,7 +414,7 @@ def test_pryear(self): with support.captured_stdout() as out: calendar.TextCalendar().pryear(2004) - self.assertEqual(out.getvalue().strip(), result_2004_text.strip()) + self.assertEqual(out.getvalue(), result_2004_text) def test_format(self): with support.captured_stdout() as out: diff -r 049e58f74272 -r 4a3892f49e1a Misc/NEWS --- a/Misc/NEWS Tue Oct 25 15:03:59 2016 +0300 +++ b/Misc/NEWS Tue Oct 25 15:20:58 2016 +0300 @@ -97,7 +97,11 @@ Library ------- -- Issue #28255: calendar.TextCalendar().prmonth() no longer prints a space +- Issue #28255: calendar.TextCalendar.prweek() no longer prints a space after + a weeks's calendar. calendar.TextCalendar.pryear() no longer prints redundant + newline after a year's calendar. Based on patch by Xiang Zhang. + +- Issue #28255: calendar.TextCalendar.prmonth() no longer prints a space at the start of new line after printing a month's calendar. Patch by Xiang Zhang.