]> granicus.if.org Git - python/commit
SF bug #761337: datetime.strftime fails on trivial format string
authorRaymond Hettinger <python@rcn.com>
Fri, 27 Jun 2003 08:14:17 +0000 (08:14 +0000)
committerRaymond Hettinger <python@rcn.com>
Fri, 27 Jun 2003 08:14:17 +0000 (08:14 +0000)
commitf69d9f6818225fc2613230c5dc11c181085db383
tree41adffd0bafe34bcfa52f4f8f09b088fc7c3e38f
parentdf9eff061e67ead5af3433c34b5f58451bc201a0
SF bug #761337: datetime.strftime fails on trivial format string

The interning of short strings violates the refcnt==1 assumption for
_PyString_Resize().

A simple fix is to boost the initial value of "totalnew" by 1.
Combined with an NULL argument to PyString_FromStringAndSize(),
this assures that resulting format string is not interned.
This will remain true even if the implementation of
PyString_FromStringAndSize() changes because only the uninitialized
strings that can be interned are those of zero length.

Added a test case.
Lib/test/test_datetime.py
Modules/datetimemodule.c