[Python-checkins] bpo-28292: Mark calendar.py helper functions as private. (GH-15113) (GH-15116)

Raymond Hettinger webhook-mailer at python.org
Sun Aug 4 16:35:00 EDT 2019


https://github.com/python/cpython/commit/0c16f6b307f7607e29b98b8fbb99cbca28f91a48
commit: 0c16f6b307f7607e29b98b8fbb99cbca28f91a48
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Raymond Hettinger <rhettinger at users.noreply.github.com>
date: 2019-08-04T13:34:56-07:00
summary:

bpo-28292: Mark calendar.py helper functions as private. (GH-15113) (GH-15116)

(cherry picked from commit b1c8ec010fb4eb2654ca994e95144c8f2fea07fb)

Co-authored-by: Raymond Hettinger <rhettinger at users.noreply.github.com>

files:
A Misc/NEWS.d/next/Library/2019-08-04-11-47-58.bpo-28292.vkihH5.rst
M Lib/calendar.py

diff --git a/Lib/calendar.py b/Lib/calendar.py
index 3828c43ed279..7550d52c0a94 100644
--- a/Lib/calendar.py
+++ b/Lib/calendar.py
@@ -127,18 +127,18 @@ def monthrange(year, month):
     return day1, ndays
 
 
-def monthlen(year, month):
+def _monthlen(year, month):
     return mdays[month] + (month == February and isleap(year))
 
 
-def prevmonth(year, month):
+def _prevmonth(year, month):
     if month == 1:
         return year-1, 12
     else:
         return year, month-1
 
 
-def nextmonth(year, month):
+def _nextmonth(year, month):
     if month == 12:
         return year+1, 1
     else:
@@ -207,13 +207,13 @@ def itermonthdays3(self, year, month):
         day1, ndays = monthrange(year, month)
         days_before = (day1 - self.firstweekday) % 7
         days_after = (self.firstweekday - day1 - ndays) % 7
-        y, m = prevmonth(year, month)
-        end = monthlen(y, m) + 1
+        y, m = _prevmonth(year, month)
+        end = _monthlen(y, m) + 1
         for d in range(end-days_before, end):
             yield y, m, d
         for d in range(1, ndays + 1):
             yield year, month, d
-        y, m = nextmonth(year, month)
+        y, m = _nextmonth(year, month)
         for d in range(1, days_after + 1):
             yield y, m, d
 
diff --git a/Misc/NEWS.d/next/Library/2019-08-04-11-47-58.bpo-28292.vkihH5.rst b/Misc/NEWS.d/next/Library/2019-08-04-11-47-58.bpo-28292.vkihH5.rst
new file mode 100644
index 000000000000..478a1b03c195
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2019-08-04-11-47-58.bpo-28292.vkihH5.rst
@@ -0,0 +1,3 @@
+Mark calendar.py helper functions as being private.  The follows PEP 8
+guidance to maintain the style conventions in the module and it addresses a
+known case of user confusion.



More information about the Python-checkins mailing list