diff --git a/Lib/calendar.py b/Lib/calendar.py index c219f0c218d9fa..addbeec6162609 100644 --- a/Lib/calendar.py +++ b/Lib/calendar.py @@ -10,6 +10,7 @@ from enum import IntEnum, global_enum import locale as _locale from itertools import repeat +import warnings __all__ = ["IllegalMonthError", "IllegalWeekdayError", "setfirstweekday", "firstweekday", "isleap", "leapdays", "weekday", "monthrange", @@ -41,6 +42,18 @@ def __str__(self): return "bad weekday number %r; must be 0 (Monday) to 6 (Sunday)" % self.weekday +def __getattr__(name): + if name in ['January','February']: + warnings.warn(f"The '{name}' attribute is going to be deprecated use '{name.upper()}' instead", + DeprecationWarning, + stacklevel=2) + if name == 'January': + return JANUARY + else: + return FEBRUARY + + raise AttributeError(f"module {__name__} has no attribute {name}") + # Constants for months @global_enum class Month(IntEnum): @@ -71,6 +84,7 @@ class Day(IntEnum): + # Number of days per month (except for February in leap years) mdays = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]