Issue #1530559: When packing a non-integer with any integer conversion
code using struct.pack, attempt to convert to an integer first using
the argument's __int__ method (if present). Also raise a
DeprecationWarning for any such usage of __int__.
This fixes a regression from 2.6, where some (but not all) integer
conversion codes already used __int__.
diff --git a/Doc/library/struct.rst b/Doc/library/struct.rst
index a115c1d..3664e35 100644
--- a/Doc/library/struct.rst
+++ b/Doc/library/struct.rst
@@ -123,6 +123,18 @@
.. versionadded:: 2.2
+(3)
+ When attempting to pack a non-integer using any of the integer conversion
+ codes, the non-integer's :meth:`__int__` method (if present) will be called
+ to convert to an integer before packing. However, this behaviour is
+ deprecated, and will raise :exc:`DeprecationWarning`.
+
+ .. versionchanged:: 2.7
+ Prior to version 2.7, not all integer conversion codes would use the
+ :meth:`__int__` method to convert, and :exc:`DeprecationWarning` was
+ raised only for float arguments.
+
+
A format character may be preceded by an integral repeat count. For example,
the format string ``'4h'`` means exactly the same as ``'hhhh'``.