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 chris.jerdonek
Recipients chris.jerdonek
Date 2012-06-29.16:05:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1340985927.81.0.282972335734.issue15223@psf.upfronthosting.co.za>
In-reply-to
Content
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
>>> datetime.__module__
'datetime'
>>> d = datetime(2000, 1, 1)
>>> d.__class__ 
<class 'datetime.datetime'>
>>> d.__module__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'datetime.datetime' object has no attribute '__module__'
History
Date User Action Args
2012-06-29 16:05:27chris.jerdoneksetrecipients: + chris.jerdonek
2012-06-29 16:05:27chris.jerdoneksetmessageid: <1340985927.81.0.282972335734.issue15223@psf.upfronthosting.co.za>
2012-06-29 16:05:26chris.jerdoneklinkissue15223 messages
2012-06-29 16:05:26chris.jerdonekcreate