Open gugupy opened 6 days ago
I think it'd make sense to raise IllegalMonthError
in both cases. Would you like to send a PR?
@Zheaoli Also add the validation for arguments, right after get options. Because the same issue happening for cli.
if options.month is not None and options.month not in range(1, 13):
parser.error(IllegalMonthError(options.month).__str__())
sys.exit(1)
I think it'd make sense to raise
IllegalMonthError
in both cases. Would you like to send a PR?
Yes, but @Zheaoli already did it.
@Zheaoli For future reference, it's a good idea to let an issue author send a PR if asked, especially for first time contributors.
Bug report
Bug description:
In the calendar module,
IllegalMonthError
is not handled properly. For months greater than 12, an IndexError is raised instead.formatmonthname
do not raise IndexError for negative integer because list support negative integer indexing.CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs