[New-bugs-announce] [issue15223] datetime instances lack __module__ attribute
report at bugs.python.org
Fri Jun 29 18:05:27 CEST 2012
New submission from Chris Jerdonek <chris.jerdonek at gmail.com>:
Instances of datetime.datetime don't seem to have the '__module__' attribute even though the datetime class itself does.
This seems to contradict Section 3.2 of the Python documentation about the standard type hierarchy (in the subsection called "Class instances"): http://docs.python.org/dev/reference/datamodel.html#the-standard-type-hierarchy
"A class instance has a namespace implemented as a dictionary which is the first place in which attribute references are searched. When an attribute is not found there, and the instance’s class has an attribute by that name, the search continues with the class attributes."
Instances of other classes defined in the standard library do have the attribute.
The session below illustrates the issue:
Python 3.3.0a4 (v3.3.0a4:7c51388a3aa7, May 30 2012, 16:58:42)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime
>>> d = datetime(2000, 1, 1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'datetime.datetime' object has no attribute '__module__'
components: Library (Lib)
title: datetime instances lack __module__ attribute
versions: Python 3.3
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce