Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
gh-103636: raise warning for January and February attribute
  • Loading branch information
Agent-Hellboy committed Apr 25, 2023
commit 175dadf4e8f23ec026e676be73fddee69a3b181a
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']:
Comment thread
Agent-Hellboy marked this conversation as resolved.
Outdated
warnings.warn(f"The '{name}' attribute is going to be deprecated use '{name.upper()}' instead",
Comment thread
Agent-Hellboy marked this conversation as resolved.
Outdated
DeprecationWarning,
stacklevel=2)
Comment thread
merwok marked this conversation as resolved.
Outdated
if name == 'January':
return JANUARY
else:
return FEBRUARY
Comment thread
Agent-Hellboy marked this conversation as resolved.
Outdated

raise AttributeError(f"module {__name__} has no attribute {name}")
Comment thread
Agent-Hellboy marked this conversation as resolved.
Outdated

# Constants for months
@global_enum
class Month(IntEnum):
Expand Down Expand Up @@ -71,6 +84,7 @@ class Day(IntEnum):


Comment thread
merwok marked this conversation as resolved.


Comment thread
Agent-Hellboy marked this conversation as resolved.
Outdated
# 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