]> granicus.if.org Git - python/commitdiff
bpo-38155: Add __all__ to datetime module (GH-16203)
authort k <tahia.khan@gmail.com>
Thu, 19 Sep 2019 13:34:41 +0000 (09:34 -0400)
committerPaul Ganssle <paul@ganssle.io>
Thu, 19 Sep 2019 13:34:41 +0000 (14:34 +0100)
https://bugs.python.org/issue38155

Lib/datetime.py
Lib/test/datetimetester.py
Misc/NEWS.d/next/Library/2019-09-16-21-47-48.bpo-38155.d92lRc.rst [new file with mode: 0644]

index 0adf1dd67dfb637cf83e93d49d6343e6955afee5..67555191d02c187587148d9c88d49d610574e91f 100644 (file)
@@ -4,6 +4,10 @@ See http://www.iana.org/time-zones/repository/tz-link.html for
 time zone and DST data sources.
 """
 
+__all__ = ("date", "datetime", "time", "timedelta", "timezone", "tzinfo",
+           "MINYEAR", "MAXYEAR")
+
+
 import time as _time
 import math as _math
 import sys
index 32977b12ebae4bfe8dcfa930a909d2f3e56d8772..42e2cecaeb724e873db6b0b187d40a3c17f12524 100644 (file)
@@ -62,6 +62,12 @@ class TestModule(unittest.TestCase):
         self.assertEqual(datetime.MINYEAR, 1)
         self.assertEqual(datetime.MAXYEAR, 9999)
 
+    def test_all(self):
+        """Test that __all__ only points to valid attributes."""
+        all_attrs = dir(datetime_module)
+        for attr in datetime_module.__all__:
+            self.assertIn(attr, all_attrs)
+
     def test_name_cleanup(self):
         if '_Pure' in self.__class__.__name__:
             self.skipTest('Only run for Fast C implementation')
diff --git a/Misc/NEWS.d/next/Library/2019-09-16-21-47-48.bpo-38155.d92lRc.rst b/Misc/NEWS.d/next/Library/2019-09-16-21-47-48.bpo-38155.d92lRc.rst
new file mode 100644 (file)
index 0000000..14b6e2d
--- /dev/null
@@ -0,0 +1 @@
+Add ``__all__`` to  :mod:`datetime`. Patch by Tahia Khan.