diff options
author | Raymond Hettinger <python@rcn.com> | 2003-06-27 08:14:17 +0000 |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2003-06-27 08:14:17 +0000 |
commit | 09de1ee838fcc77cbf9ea41bc7149282be2f1f26 (patch) | |
tree | 0be5388cb603dca08940a243bbbf91acd299369c /Lib/test/test_datetime.py | |
parent | 217e4f834a68d29e038aeb23a4f02931d3288473 (diff) | |
download | cpython-09de1ee838fcc77cbf9ea41bc7149282be2f1f26.tar.gz |
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.
Diffstat (limited to 'Lib/test/test_datetime.py')
-rw-r--r-- | Lib/test/test_datetime.py | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/Lib/test/test_datetime.py b/Lib/test/test_datetime.py index cca0c9d9c5..c6dbb48956 100644 --- a/Lib/test/test_datetime.py +++ b/Lib/test/test_datetime.py @@ -831,6 +831,7 @@ class TestDate(HarmlessMixedComparison): def test_strftime(self): t = self.theclass(2005, 3, 2) self.assertEqual(t.strftime("m:%m d:%d y:%y"), "m:03 d:02 y:05") + self.assertEqual(t.strftime(""), "") # SF bug #761337 self.assertRaises(TypeError, t.strftime) # needs an arg self.assertRaises(TypeError, t.strftime, "one", "two") # too many args |