Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0595ed2

Browse files
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.
1 parent 78d84d8 commit 0595ed2

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

Lib/calendar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def prweek(self, theweek, width):
267267
"""
268268
Print a single week (no newline).
269269
"""
270-
print(self.formatweek(theweek, width), end=' ')
270+
print(self.formatweek(theweek, width), end='')
271271

272272
def formatday(self, day, weekday, width):
273273
"""
@@ -371,7 +371,7 @@ def formatyear(self, theyear, w=2, l=1, c=6, m=3):
371371

372372
def pryear(self, theyear, w=0, l=0, c=6, m=3):
373373
"""Print a year's calendar."""
374-
print(self.formatyear(theyear, w, l, c, m))
374+
print(self.formatyear(theyear, w, l, c, m), end='')
375375

376376

377377
class HTMLCalendar(Calendar):

Lib/test/test_calendar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ def test_prweek(self):
404404
with support.captured_stdout() as out:
405405
week = [(1,0), (2,1), (3,2), (4,3), (5,4), (6,5), (7,6)]
406406
calendar.TextCalendar().prweek(week, 1)
407-
self.assertEqual(out.getvalue().strip(), "1 2 3 4 5 6 7")
407+
self.assertEqual(out.getvalue(), " 1 2 3 4 5 6 7")
408408

409409
def test_prmonth(self):
410410
with support.captured_stdout() as out:
@@ -414,7 +414,7 @@ def test_prmonth(self):
414414
def test_pryear(self):
415415
with support.captured_stdout() as out:
416416
calendar.TextCalendar().pryear(2004)
417-
self.assertEqual(out.getvalue().strip(), result_2004_text.strip())
417+
self.assertEqual(out.getvalue(), result_2004_text)
418418

419419
def test_format(self):
420420
with support.captured_stdout() as out:

Misc/NEWS

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ Core and Builtins
9797
Library
9898
-------
9999

100-
- Issue #28255: calendar.TextCalendar().prmonth() no longer prints a space
100+
- Issue #28255: calendar.TextCalendar.prweek() no longer prints a space after
101+
a weeks's calendar. calendar.TextCalendar.pryear() no longer prints redundant
102+
newline after a year's calendar. Based on patch by Xiang Zhang.
103+
104+
- Issue #28255: calendar.TextCalendar.prmonth() no longer prints a space
101105
at the start of new line after printing a month's calendar. Patch by
102106
Xiang Zhang.
103107

0 commit comments

Comments
 (0)