From 175dadf4e8f23ec026e676be73fddee69a3b181a Mon Sep 17 00:00:00 2001 From: Prince Roshan Date: Tue, 25 Apr 2023 20:23:18 +0530 Subject: [PATCH 01/19] gh-103636: raise warning for January and February attribute --- Lib/calendar.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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] From 97436c88fc14edd528b7baa0f08ea5c51253396f Mon Sep 17 00:00:00 2001 From: Prince Roshan Date: Wed, 26 Apr 2023 09:39:18 +0530 Subject: [PATCH 02/19] add test --- Lib/test/test_calendar.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py index ccfbeede0be949..0210202719de6d 100644 --- a/Lib/test/test_calendar.py +++ b/Lib/test/test_calendar.py @@ -8,6 +8,7 @@ import sys import datetime import os +import warnings # From https://en.wikipedia.org/wiki/Leap_year_starting_on_Saturday result_0_02_text = """\ @@ -490,6 +491,16 @@ def test_format(self): self.assertEqual(out.getvalue().strip(), "1 2 3") class CalendarTestCase(unittest.TestCase): + + def test_deprecation_warning(self): + with warnings.catch_warnings(record=True) as w: + # Access the deprecated attribute + _ = calendar.January + # Check that a DeprecationWarning was issued + self.assertEqual(len(w), 1) + self.assertEqual(w[0].category, DeprecationWarning) + self.assertIn("The 'January' attribute is going to be deprecated use 'JANUARY' instead", str(w[0].message)) + def test_isleap(self): # Make sure that the return is right for a few years, and # ensure that the return values are 1 or 0, not just true or From e6f2a2fcfbea2c65011fdc189cb7557030721858 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Wed, 26 Apr 2023 18:12:15 +0000 Subject: [PATCH 03/19] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20b?= =?UTF-8?q?lurb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2023-04-26-18-12-13.gh-issue-103636.-KvCgO.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2023-04-26-18-12-13.gh-issue-103636.-KvCgO.rst diff --git a/Misc/NEWS.d/next/Library/2023-04-26-18-12-13.gh-issue-103636.-KvCgO.rst b/Misc/NEWS.d/next/Library/2023-04-26-18-12-13.gh-issue-103636.-KvCgO.rst new file mode 100644 index 00000000000000..c80752c2f31b74 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-04-26-18-12-13.gh-issue-103636.-KvCgO.rst @@ -0,0 +1 @@ +module-level attribute January and February is deprecated From 5a4d0a70dc909fa27dd88ba3c598df48ac0305dd Mon Sep 17 00:00:00 2001 From: Prince Roshan Date: Thu, 27 Apr 2023 00:06:20 +0530 Subject: [PATCH 04/19] update docs for depration warning and new additions --- Doc/library/calendar.rst | 88 +++++++++++++++++++++++++++++++++++++++ Doc/whatsnew/3.12.rst | 7 ++++ Lib/calendar.py | 13 +++--- Lib/test/test_calendar.py | 4 +- 4 files changed, 103 insertions(+), 9 deletions(-) diff --git a/Doc/library/calendar.rst b/Doc/library/calendar.rst index 66f59f0e2ced27..10622bd3022bed 100644 --- a/Doc/library/calendar.rst +++ b/Doc/library/calendar.rst @@ -28,6 +28,94 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is 2 BC, and so on. +.. enum:: Day + :type: IntEnum + + This enumeration defines the days of the week as integer constants. + + .. attribute:: MONDAY + + The constant for Monday, with a value of 0. + + .. attribute:: TUESDAY + + The constant for Tuesday, with a value of 1. + + .. attribute:: WEDNESDAY + + The constant for Wednesday, with a value of 2. + + .. attribute:: THURSDAY + + The constant for Thursday, with a value of 3. + + .. attribute:: FRIDAY + + The constant for Friday, with a value of 4. + + .. attribute:: SATURDAY + + The constant for Saturday, with a value of 5. + + .. attribute:: SUNDAY + + The constant for Sunday, with a value of 6. + + +.. enum:: Month + :type: IntEnum + + This enumeration defines the months of the year as integer constants. + + .. attribute:: JANUARY + + The constant for January, with a value of 1. + + .. attribute:: FEBRUARY + + The constant for February, with a value of 2. + + .. attribute:: MARCH + + The constant for March, with a value of 3. + + .. attribute:: APRIL + + The constant for April, with a value of 4. + + .. attribute:: MAY + + The constant for May, with a value of 5. + + .. attribute:: JUNE + + The constant for June, with a value of 6. + + .. attribute:: JULY + + The constant for July, with a value of 7. + + .. attribute:: AUGUST + + The constant for August, with a value of 8. + + .. attribute:: SEPTEMBER + + The constant for September, with a value of 9. + + .. attribute:: OCTOBER + + The constant for October, with a value of 10. + + .. attribute:: NOVEMBER + + The constant for November, with a value of 11. + + .. attribute:: DECEMBER + + The constant for December, with a value of 12. + + .. class:: Calendar(firstweekday=0) Creates a :class:`Calendar` object. *firstweekday* is an integer specifying the diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index 373e31b37cd9dc..cf460a2737c576 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -536,6 +536,11 @@ sys exception instance, rather than to a ``(typ, exc, tb)`` tuple. (Contributed by Irit Katriel in :gh:`103176`.) +calendar +-------- + +* Added Enum for Month and Day + (Contributed by Prince Roshan in :gh:`103636`.) Optimizations ============= @@ -641,6 +646,8 @@ Deprecated Python 3.14, when ``'data'`` filter will become the default. See :ref:`tarfile-extraction-filter` for details. +* :data:`January` and :data:`February` is deprated from :mod:`calendar` + use :data:`JANUARY` and :data:`FEBRUARY` instead Pending Removal in Python 3.13 ------------------------------ diff --git a/Lib/calendar.py b/Lib/calendar.py index addbeec6162609..8e0fe611e0353a 100644 --- a/Lib/calendar.py +++ b/Lib/calendar.py @@ -43,16 +43,17 @@ def __str__(self): def __getattr__(name): - if name in ['January','February']: - warnings.warn(f"The '{name}' attribute is going to be deprecated use '{name.upper()}' instead", + if name in ('January','February'): + warnings.warn(f"The '{name}' attribute is deprecated, use '{name.upper()}' instead", DeprecationWarning, stacklevel=2) if name == 'January': - return JANUARY + return 1 else: - return FEBRUARY + return 2 + + raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - raise AttributeError(f"module {__name__} has no attribute {name}") # Constants for months @global_enum @@ -83,8 +84,6 @@ class Day(IntEnum): SUNDAY = 6 - - # 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] diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py index 0210202719de6d..f358bb9d211a56 100644 --- a/Lib/test/test_calendar.py +++ b/Lib/test/test_calendar.py @@ -495,11 +495,11 @@ class CalendarTestCase(unittest.TestCase): def test_deprecation_warning(self): with warnings.catch_warnings(record=True) as w: # Access the deprecated attribute - _ = calendar.January + calendar.January # Check that a DeprecationWarning was issued self.assertEqual(len(w), 1) self.assertEqual(w[0].category, DeprecationWarning) - self.assertIn("The 'January' attribute is going to be deprecated use 'JANUARY' instead", str(w[0].message)) + self.assertIn("The 'January' attribute is deprecated, use 'JANUARY' instead", str(w[0].message)) def test_isleap(self): # Make sure that the return is right for a few years, and From ddcdc43c850ea54d023c01aefc1811c26ed072b8 Mon Sep 17 00:00:00 2001 From: Prince Roshan Date: Thu, 27 Apr 2023 00:09:34 +0530 Subject: [PATCH 05/19] dedent line in calendar test --- Lib/test/test_calendar.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py index f358bb9d211a56..92f46a17e99002 100644 --- a/Lib/test/test_calendar.py +++ b/Lib/test/test_calendar.py @@ -497,9 +497,9 @@ def test_deprecation_warning(self): # Access the deprecated attribute calendar.January # Check that a DeprecationWarning was issued - self.assertEqual(len(w), 1) - self.assertEqual(w[0].category, DeprecationWarning) - self.assertIn("The 'January' attribute is deprecated, use 'JANUARY' instead", str(w[0].message)) + self.assertEqual(len(w), 1) + self.assertEqual(w[0].category, DeprecationWarning) + self.assertIn("The 'January' attribute is deprecated, use 'JANUARY' instead", str(w[0].message)) def test_isleap(self): # Make sure that the return is right for a few years, and From 794dddc5205d1f4b57ae24ca7bf74f5865b1a230 Mon Sep 17 00:00:00 2001 From: Prince Roshan Date: Thu, 27 Apr 2023 00:24:27 +0530 Subject: [PATCH 06/19] fix doc --- Doc/library/calendar.rst | 72 ++++++++++++++++++++-------------------- Doc/whatsnew/3.12.rst | 4 +-- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/Doc/library/calendar.rst b/Doc/library/calendar.rst index 10622bd3022bed..878809b95c5008 100644 --- a/Doc/library/calendar.rst +++ b/Doc/library/calendar.rst @@ -34,31 +34,31 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is This enumeration defines the days of the week as integer constants. .. attribute:: MONDAY - + The constant for Monday, with a value of 0. - + .. attribute:: TUESDAY - + The constant for Tuesday, with a value of 1. - + .. attribute:: WEDNESDAY - + The constant for Wednesday, with a value of 2. - + .. attribute:: THURSDAY - + The constant for Thursday, with a value of 3. - + .. attribute:: FRIDAY - + The constant for Friday, with a value of 4. - + .. attribute:: SATURDAY - + The constant for Saturday, with a value of 5. - + .. attribute:: SUNDAY - + The constant for Sunday, with a value of 6. @@ -68,51 +68,51 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is This enumeration defines the months of the year as integer constants. .. attribute:: JANUARY - + The constant for January, with a value of 1. - + .. attribute:: FEBRUARY - + The constant for February, with a value of 2. - + .. attribute:: MARCH - + The constant for March, with a value of 3. - + .. attribute:: APRIL - + The constant for April, with a value of 4. - + .. attribute:: MAY - + The constant for May, with a value of 5. - + .. attribute:: JUNE - + The constant for June, with a value of 6. - + .. attribute:: JULY - + The constant for July, with a value of 7. - + .. attribute:: AUGUST - + The constant for August, with a value of 8. - + .. attribute:: SEPTEMBER - + The constant for September, with a value of 9. - + .. attribute:: OCTOBER - + The constant for October, with a value of 10. - + .. attribute:: NOVEMBER - + The constant for November, with a value of 11. - + .. attribute:: DECEMBER - + The constant for December, with a value of 12. diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index cf460a2737c576..5b4f24ebd94605 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -539,7 +539,7 @@ sys calendar -------- -* Added Enum for Month and Day +* Added Enum for Month and Day (Contributed by Prince Roshan in :gh:`103636`.) Optimizations @@ -646,7 +646,7 @@ Deprecated Python 3.14, when ``'data'`` filter will become the default. See :ref:`tarfile-extraction-filter` for details. -* :data:`January` and :data:`February` is deprated from :mod:`calendar` +* :data:`January` and :data:`February` is deprated from :mod:`calendar` use :data:`JANUARY` and :data:`FEBRUARY` instead Pending Removal in Python 3.13 From 717cea8e25d3d3dc1bdd520973681daf645d42ab Mon Sep 17 00:00:00 2001 From: Prince Roshan Date: Thu, 27 Apr 2023 00:27:32 +0530 Subject: [PATCH 07/19] fix doc --- Doc/library/calendar.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/Doc/library/calendar.rst b/Doc/library/calendar.rst index 878809b95c5008..f84290d5a6e0dc 100644 --- a/Doc/library/calendar.rst +++ b/Doc/library/calendar.rst @@ -29,7 +29,6 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is .. enum:: Day - :type: IntEnum This enumeration defines the days of the week as integer constants. @@ -63,7 +62,6 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is .. enum:: Month - :type: IntEnum This enumeration defines the months of the year as integer constants. From b2c13e86bff72a9eec4180d3c8a8cd7549f23c88 Mon Sep 17 00:00:00 2001 From: Prince Roshan Date: Thu, 27 Apr 2023 00:32:50 +0530 Subject: [PATCH 08/19] fix doc --- Doc/library/calendar.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/calendar.rst b/Doc/library/calendar.rst index f84290d5a6e0dc..28ece1a47d27b7 100644 --- a/Doc/library/calendar.rst +++ b/Doc/library/calendar.rst @@ -28,7 +28,7 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is 2 BC, and so on. -.. enum:: Day +.. class:: Day This enumeration defines the days of the week as integer constants. @@ -61,7 +61,7 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is The constant for Sunday, with a value of 6. -.. enum:: Month +.. class:: Month This enumeration defines the months of the year as integer constants. From 029844f867c1b2defd6a977c5de319e706b0c018 Mon Sep 17 00:00:00 2001 From: Prince Roshan Date: Thu, 27 Apr 2023 00:39:37 +0530 Subject: [PATCH 09/19] fix doc --- Doc/whatsnew/3.12.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index 5b4f24ebd94605..7dbbf61bc4a6f5 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -646,8 +646,8 @@ Deprecated Python 3.14, when ``'data'`` filter will become the default. See :ref:`tarfile-extraction-filter` for details. -* :data:`January` and :data:`February` is deprated from :mod:`calendar` - use :data:`JANUARY` and :data:`FEBRUARY` instead +* ``January`` and ``February`` is deprated from :mod:`calendar` + use `JANUARY and ``FEBRUARY`` instead Pending Removal in Python 3.13 ------------------------------ From 0c52a19afeb6c256c0d4cf3c784e4987fea765ca Mon Sep 17 00:00:00 2001 From: Prince Roshan Date: Thu, 27 Apr 2023 01:15:14 +0530 Subject: [PATCH 10/19] fix doc --- Doc/whatsnew/3.12.rst | 2 +- Lib/test/test_calendar.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index 7dbbf61bc4a6f5..84a202a40e17d2 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -647,7 +647,7 @@ Deprecated See :ref:`tarfile-extraction-filter` for details. * ``January`` and ``February`` is deprated from :mod:`calendar` - use `JANUARY and ``FEBRUARY`` instead + use ``JANUARY`` and ``FEBRUARY`` instead Pending Removal in Python 3.13 ------------------------------ diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py index 92f46a17e99002..3311234cb99d2d 100644 --- a/Lib/test/test_calendar.py +++ b/Lib/test/test_calendar.py @@ -496,7 +496,7 @@ def test_deprecation_warning(self): with warnings.catch_warnings(record=True) as w: # Access the deprecated attribute calendar.January - # Check that a DeprecationWarning was issued + # Check that a DeprecationWarning was issued self.assertEqual(len(w), 1) self.assertEqual(w[0].category, DeprecationWarning) self.assertIn("The 'January' attribute is deprecated, use 'JANUARY' instead", str(w[0].message)) From ac783cfdd5257a7ff8862dd813b3e4bb4ad24424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric?= Date: Wed, 26 Apr 2023 17:35:47 -0400 Subject: [PATCH 11/19] fix spacing --- Lib/calendar.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/calendar.py b/Lib/calendar.py index 8e0fe611e0353a..bbd4fea3b88ca4 100644 --- a/Lib/calendar.py +++ b/Lib/calendar.py @@ -43,10 +43,9 @@ def __str__(self): def __getattr__(name): - if name in ('January','February'): + if name in ('January', 'February'): warnings.warn(f"The '{name}' attribute is deprecated, use '{name.upper()}' instead", - DeprecationWarning, - stacklevel=2) + DeprecationWarning, stacklevel=2) if name == 'January': return 1 else: @@ -84,6 +83,7 @@ class Day(IntEnum): SUNDAY = 6 + # 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] From e002e109f57278eb52f0716bc026b38b15c11472 Mon Sep 17 00:00:00 2001 From: Prince Roshan Date: Thu, 27 Apr 2023 08:53:52 +0530 Subject: [PATCH 12/19] fix grametical mistake --- Doc/library/calendar.rst | 42 +------------------ Doc/whatsnew/3.12.rst | 4 +- Lib/test/test_calendar.py | 2 - ...-04-26-18-12-13.gh-issue-103636.-KvCgO.rst | 2 +- 4 files changed, 5 insertions(+), 45 deletions(-) diff --git a/Doc/library/calendar.rst b/Doc/library/calendar.rst index 28ece1a47d27b7..993e0b7f41615d 100644 --- a/Doc/library/calendar.rst +++ b/Doc/library/calendar.rst @@ -30,89 +30,51 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is .. class:: Day - This enumeration defines the days of the week as integer constants. + Enumeration defining the days of the week as integer constants, from 0 to 6. .. attribute:: MONDAY - The constant for Monday, with a value of 0. - .. attribute:: TUESDAY - The constant for Tuesday, with a value of 1. - .. attribute:: WEDNESDAY - The constant for Wednesday, with a value of 2. - .. attribute:: THURSDAY - The constant for Thursday, with a value of 3. - .. attribute:: FRIDAY - The constant for Friday, with a value of 4. - .. attribute:: SATURDAY - The constant for Saturday, with a value of 5. - .. attribute:: SUNDAY - The constant for Sunday, with a value of 6. - .. class:: Month - This enumeration defines the months of the year as integer constants. + Enumeration defining months of the year as integer constants, from 1 to 12. .. attribute:: JANUARY - The constant for January, with a value of 1. - .. attribute:: FEBRUARY - The constant for February, with a value of 2. - .. attribute:: MARCH - The constant for March, with a value of 3. - .. attribute:: APRIL - The constant for April, with a value of 4. - .. attribute:: MAY - The constant for May, with a value of 5. - .. attribute:: JUNE - The constant for June, with a value of 6. - .. attribute:: JULY - The constant for July, with a value of 7. - .. attribute:: AUGUST - The constant for August, with a value of 8. - .. attribute:: SEPTEMBER - The constant for September, with a value of 9. - .. attribute:: OCTOBER - The constant for October, with a value of 10. - .. attribute:: NOVEMBER - The constant for November, with a value of 11. - .. attribute:: DECEMBER - The constant for December, with a value of 12. - .. class:: Calendar(firstweekday=0) diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index 70b0755e00318d..751ba29f1abee2 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -658,8 +658,8 @@ Deprecated Python 3.14, when ``'data'`` filter will become the default. See :ref:`tarfile-extraction-filter` for details. -* ``January`` and ``February`` is deprated from :mod:`calendar` - use ``JANUARY`` and ``FEBRUARY`` instead +* ``January`` and ``February`` is deprecated from :mod:`calendar`, + use ``JANUARY`` and ``FEBRUARY`` instead. Pending Removal in Python 3.13 ------------------------------ diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py index 3311234cb99d2d..03388e8c55d5a8 100644 --- a/Lib/test/test_calendar.py +++ b/Lib/test/test_calendar.py @@ -494,9 +494,7 @@ class CalendarTestCase(unittest.TestCase): def test_deprecation_warning(self): with warnings.catch_warnings(record=True) as w: - # Access the deprecated attribute calendar.January - # Check that a DeprecationWarning was issued self.assertEqual(len(w), 1) self.assertEqual(w[0].category, DeprecationWarning) self.assertIn("The 'January' attribute is deprecated, use 'JANUARY' instead", str(w[0].message)) diff --git a/Misc/NEWS.d/next/Library/2023-04-26-18-12-13.gh-issue-103636.-KvCgO.rst b/Misc/NEWS.d/next/Library/2023-04-26-18-12-13.gh-issue-103636.-KvCgO.rst index c80752c2f31b74..43825bf893bb4e 100644 --- a/Misc/NEWS.d/next/Library/2023-04-26-18-12-13.gh-issue-103636.-KvCgO.rst +++ b/Misc/NEWS.d/next/Library/2023-04-26-18-12-13.gh-issue-103636.-KvCgO.rst @@ -1 +1 @@ -module-level attribute January and February is deprecated +module-level attribute January and February is deprecated from :mod:`calendar` From 57ee1f999d6702144ef84a1ef4d6cd798a55d43b Mon Sep 17 00:00:00 2001 From: Prince Roshan Date: Thu, 27 Apr 2023 17:50:51 +0530 Subject: [PATCH 13/19] Apply suggestions from code review Co-authored-by: Hugo van Kemenade --- Doc/whatsnew/3.12.rst | 5 +++-- .../Library/2023-04-26-18-12-13.gh-issue-103636.-KvCgO.rst | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index 751ba29f1abee2..22e1e2d32804b9 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -551,7 +551,7 @@ sys calendar -------- -* Added Enum for Month and Day +* Add enums for month and day. For example: ``JANUARY`` and ``MONDAY``. (Contributed by Prince Roshan in :gh:`103636`.) Optimizations @@ -658,8 +658,9 @@ Deprecated Python 3.14, when ``'data'`` filter will become the default. See :ref:`tarfile-extraction-filter` for details. -* ``January`` and ``February`` is deprecated from :mod:`calendar`, +* ``January`` and ``February`` are deprecated from :mod:`calendar`, use ``JANUARY`` and ``FEBRUARY`` instead. + (Contributed by Prince Roshan in :gh:`103636`.) Pending Removal in Python 3.13 ------------------------------ diff --git a/Misc/NEWS.d/next/Library/2023-04-26-18-12-13.gh-issue-103636.-KvCgO.rst b/Misc/NEWS.d/next/Library/2023-04-26-18-12-13.gh-issue-103636.-KvCgO.rst index 43825bf893bb4e..a05a6f5cbcdb99 100644 --- a/Misc/NEWS.d/next/Library/2023-04-26-18-12-13.gh-issue-103636.-KvCgO.rst +++ b/Misc/NEWS.d/next/Library/2023-04-26-18-12-13.gh-issue-103636.-KvCgO.rst @@ -1 +1 @@ -module-level attribute January and February is deprecated from :mod:`calendar` +Module-level attributes ``January`` and ``February`` are deprecated from :mod:`calendar`. From cdcb22ac827a9d3d5757bd4796e20744c423c0d6 Mon Sep 17 00:00:00 2001 From: Prince Roshan Date: Thu, 27 Apr 2023 17:56:43 +0530 Subject: [PATCH 14/19] arrange module in alphabetical order in whats new --- Doc/whatsnew/3.12.rst | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index 22e1e2d32804b9..aef49ec3d98074 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -261,6 +261,12 @@ asyncio yielding tasks. (Contributed by Kumar Aditya in :gh:`78530`.) +calendar +-------- + +* Add enums for month and day. For example: ``JANUARY`` and ``MONDAY``. + (Contributed by Prince Roshan in :gh:`103636`.) + csv --- @@ -548,11 +554,6 @@ sys exception instance, rather than to a ``(typ, exc, tb)`` tuple. (Contributed by Irit Katriel in :gh:`103176`.) -calendar --------- - -* Add enums for month and day. For example: ``JANUARY`` and ``MONDAY``. - (Contributed by Prince Roshan in :gh:`103636`.) Optimizations ============= From 49079d1b45e5b0ccff815d29b92a2def233ab6cb Mon Sep 17 00:00:00 2001 From: Prince Roshan Date: Thu, 27 Apr 2023 20:14:00 +0530 Subject: [PATCH 15/19] Update Doc/whatsnew/3.12.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Éric --- Doc/whatsnew/3.12.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index aef49ec3d98074..468170b8c0cac5 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -659,8 +659,8 @@ Deprecated Python 3.14, when ``'data'`` filter will become the default. See :ref:`tarfile-extraction-filter` for details. -* ``January`` and ``February`` are deprecated from :mod:`calendar`, - use ``JANUARY`` and ``FEBRUARY`` instead. +* ``calendar.January`` and ``calendar.February`` constants are deprecated and + replaced by :data:`calendar.Month.JANUARY` and :data:`calendar.Month.February`. (Contributed by Prince Roshan in :gh:`103636`.) Pending Removal in Python 3.13 From db53e788dc4f8131da7f80d07242ba0b963613a9 Mon Sep 17 00:00:00 2001 From: Prince Roshan Date: Thu, 27 Apr 2023 20:14:11 +0530 Subject: [PATCH 16/19] Update Doc/whatsnew/3.12.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Éric --- Doc/whatsnew/3.12.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index 468170b8c0cac5..f90c0187e8605f 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -264,7 +264,7 @@ asyncio calendar -------- -* Add enums for month and day. For example: ``JANUARY`` and ``MONDAY``. +* Add enums :data:`~calendar.Month` and :data:`~calendar.Day`. (Contributed by Prince Roshan in :gh:`103636`.) csv From 9c289c5a05cc807ba2b88388d016fc76b82f1fa4 Mon Sep 17 00:00:00 2001 From: Prince Roshan Date: Thu, 27 Apr 2023 20:32:44 +0530 Subject: [PATCH 17/19] fix doc --- Doc/whatsnew/3.12.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index f90c0187e8605f..710bf5094dd366 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -660,7 +660,7 @@ Deprecated See :ref:`tarfile-extraction-filter` for details. * ``calendar.January`` and ``calendar.February`` constants are deprecated and - replaced by :data:`calendar.Month.JANUARY` and :data:`calendar.Month.February`. + replaced by :data:`calendar.Month.JANUARY` and :data:`calendar.Month.FEBRUARY`. (Contributed by Prince Roshan in :gh:`103636`.) Pending Removal in Python 3.13 From 7ec1945c9b372656bd22c90ff473496fec04da18 Mon Sep 17 00:00:00 2001 From: Prince Roshan Date: Fri, 28 Apr 2023 09:23:51 +0530 Subject: [PATCH 18/19] Update Doc/library/calendar.rst Co-authored-by: Hugo van Kemenade --- Doc/library/calendar.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Doc/library/calendar.rst b/Doc/library/calendar.rst index 993e0b7f41615d..8c17f9cb93899d 100644 --- a/Doc/library/calendar.rst +++ b/Doc/library/calendar.rst @@ -46,6 +46,8 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is .. attribute:: SUNDAY + .. versionadded:: 3.12 + .. class:: Month From 7628f1175d060938cc461ed76ccb11cddc5d0c32 Mon Sep 17 00:00:00 2001 From: Prince Roshan Date: Fri, 28 Apr 2023 09:24:02 +0530 Subject: [PATCH 19/19] Update Doc/library/calendar.rst Co-authored-by: Hugo van Kemenade --- Doc/library/calendar.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Doc/library/calendar.rst b/Doc/library/calendar.rst index 8c17f9cb93899d..07d04a1c7b582a 100644 --- a/Doc/library/calendar.rst +++ b/Doc/library/calendar.rst @@ -77,6 +77,8 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is .. attribute:: DECEMBER + .. versionadded:: 3.12 + .. class:: Calendar(firstweekday=0) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy