[New-bugs-announce] [issue38155] Add __all__ to the datetime module

Paul Ganssle report at bugs.python.org
Fri Sep 13 06:23:10 EDT 2019


New submission from Paul Ganssle <p.ganssle at gmail.com>:

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.

----------
components: Library (Lib)
keywords: newcomer friendly
messages: 352280
nosy: belopolsky, p-ganssle
priority: normal
severity: normal
stage: needs patch
status: open
title: Add __all__ to the datetime module
type: enhancement
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38155>
_______________________________________


More information about the New-bugs-announce mailing list