Skip to content

Commit 175dadf

Browse files
committed
pythongh-103636: raise warning for January and February attribute
1 parent c8c3956 commit 175dadf

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Lib/calendar.py

+14
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from enum import IntEnum, global_enum
1111
import locale as _locale
1212
from itertools import repeat
13+
import warnings
1314

1415
__all__ = ["IllegalMonthError", "IllegalWeekdayError", "setfirstweekday",
1516
"firstweekday", "isleap", "leapdays", "weekday", "monthrange",
@@ -41,6 +42,18 @@ def __str__(self):
4142
return "bad weekday number %r; must be 0 (Monday) to 6 (Sunday)" % self.weekday
4243

4344

45+
def __getattr__(name):
46+
if name in ['January','February']:
47+
warnings.warn(f"The '{name}' attribute is going to be deprecated use '{name.upper()}' instead",
48+
DeprecationWarning,
49+
stacklevel=2)
50+
if name == 'January':
51+
return JANUARY
52+
else:
53+
return FEBRUARY
54+
55+
raise AttributeError(f"module {__name__} has no attribute {name}")
56+
4457
# Constants for months
4558
@global_enum
4659
class Month(IntEnum):
@@ -71,6 +84,7 @@ class Day(IntEnum):
7184

7285

7386

87+
7488
# Number of days per month (except for February in leap years)
7589
mdays = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
7690

0 commit comments

Comments
 (0)