This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author p-ganssle
Recipients belopolsky, p-ganssle
Date 2019-09-13.10:23:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1568370190.96.0.124167415349.issue38155@roundup.psfhosted.org>
In-reply-to
Content
Currently the datetime module has no __all__, which means we only advertise what is public and private based on leading underscores. Additionally, because there are two implementations (Python and C), you actually get different things when you do `from datetime import *` depending on whether you have the C module installed or not.

The "easy" part is to add an __all__ variable to Lib/datetime.py for all the documented attributes:

  __all__ = ["date", "datetime", "time", "timedelta", "timezone", "tzinfo", "MINYEAR", "MAXYEAR"]

A "stretch goal" would be to add a test to ensure that `from datetime import *` imports the same set of symbols from the pure python module that it does from the C module. I haven't quite thought through how this would be achieved, probably something in test_datetime (https://github.com/python/cpython/blob/6a517c674907c195660fa9178a7b561de49cc721/Lib/test/test_datetime.py#L1), where we need to import both modules anyway. I think we can accept an "add __all__" PR without tests, though.
History
Date User Action Args
2019-09-13 10:23:11p-gansslesetrecipients: + p-ganssle, belopolsky
2019-09-13 10:23:10p-gansslesetmessageid: <1568370190.96.0.124167415349.issue38155@roundup.psfhosted.org>
2019-09-13 10:23:10p-gansslelinkissue38155 messages
2019-09-13 10:23:10p-gansslecreate