Skip to content

Commit

Permalink
pythongh-103636: raise warning for January and February attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Agent-Hellboy committed Apr 25, 2023
1 parent c8c3956 commit 175dadf
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Lib/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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]

Expand Down

0 comments on commit 175dadf

Please sign in to comment.