[egenix-users] DeprecationWarning with Python 2.3c1
M.-A. Lemburg
mal at lemburg.com
Tue Jul 22 14:39:12 CEST 2003
Jacob Smullyan wrote:
> Using mx base 2.1.0b5, the following code produces a DeprecationWarning
> in the latest Python (also as far back as 2.3b1, at least):
>
>
>>>>import mx.DateTime as M
>>>>n=M.now()
>>>>import time
>>>>time.strftime('%Y', n.tuple())
>
> __main__:1: DeprecationWarning: integer argument expected, got float
> '2003'
>
> The tuple returned contains a float rather than an int for the "second"
> field. From the 2.3 release notes (from the 2.3a2 C API section): "The
> PyArg_Parse functions now issue a DeprecationWarning if a float
> argument is provided when an integer is specified (this affects the 'b',
> 'B', 'h', 'H', 'i', and 'l' codes). Future versions of Python will raise
> a TypeError."
Oh well :-/ Guess I'll have to change the format in the tuple to
be all integers...
> Whether this is a bug in time.strftime or in mx.DateTime, I leave to
> your better judgement. Also, don't ask why someone is using
> time.strftime with mx.DateTime this way, because I have no idea!
> Nonetheless, if the tuple returned from DateTimeType.tuple() isn't
> compatible is those used in the time module, there isn't a whole lot of
> point to them.
OTOH, people should use n.strftime() directly.
--
Marc-Andre Lemburg
eGenix.com
Professional Python Software directly from the Source (#1, Jul 22 2003)
>>> Python/Zope Products & Consulting ... http://www.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
2003-07-01: Released mxODBC.Zope.DA for FreeBSD 1.0.6 beta 1
More information about the egenix-users
mailing list