Skip to content

Commit 8b7bc06

Browse files
committed
gh-69714: Move the validation to the beginning of the function
No need to process the function. This also helps in supporting CLI testing.
1 parent 2b2c8ef commit 8b7bc06

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Lib/calendar.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,9 @@ def main(args=None):
724724
locale = options.locale, options.encoding
725725

726726
if options.type == "html":
727+
if options.month:
728+
parser.error("incorrect number of arguments")
729+
sys.exit(1)
727730
if options.locale:
728731
cal = LocaleHTMLCalendar(locale=locale)
729732
else:
@@ -735,11 +738,8 @@ def main(args=None):
735738
write = sys.stdout.buffer.write
736739
if options.year is None:
737740
write(cal.formatyearpage(datetime.date.today().year, **optdict))
738-
elif options.month is None:
739-
write(cal.formatyearpage(options.year, **optdict))
740741
else:
741-
parser.error("incorrect number of arguments")
742-
sys.exit(1)
742+
write(cal.formatyearpage(options.year, **optdict))
743743
else:
744744
if options.locale:
745745
cal = LocaleTextCalendar(locale=locale)

0 commit comments

Comments
 (0)