Merged revisions 79674 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r79674 | mark.dickinson | 2010-04-03 15:05:10 +0100 (Sat, 03 Apr 2010) | 3 lines

  Issue #8300:  Let struct.pack use __index__ to convert and pack non-integers.
  Based on a patch by Meador Inge.
........
diff --git a/Doc/library/struct.rst b/Doc/library/struct.rst
index bee154f..ee949d9 100644
--- a/Doc/library/struct.rst
+++ b/Doc/library/struct.rst
@@ -119,6 +119,15 @@
    the platform C compiler supports C :ctype:`long long`, or, on Windows,
    :ctype:`__int64`.  They are always available in standard modes.
 
+(4)
+   When attempting to pack a non-integer using any of the integer conversion
+   codes, if the non-integer has a :meth:`__index__` method then that method is
+   called to convert the argument to an integer before packing.
+
+   .. versionchanged:: 3.2
+      Use of the :meth:`__index__` method for non-integers is new in 3.2.
+
+
 A format character may be preceded by an integral repeat count.  For example,
 the format string ``'4h'`` means exactly the same as ``'hhhh'``.