[Python-checkins] python/dist/src/Lib/test test_datetime.py,1.44,1.45

rhettinger@users.sourceforge.net rhettinger@users.sourceforge.net
Fri, 27 Jun 2003 01:14:19 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv5051/Lib/test

Modified Files:
	test_datetime.py 
Log Message:
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.



Index: test_datetime.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_datetime.py,v
retrieving revision 1.44
retrieving revision 1.45
diff -C2 -d -r1.44 -r1.45
*** test_datetime.py	17 May 2003 15:56:59 -0000	1.44
--- test_datetime.py	27 Jun 2003 08:14:17 -0000	1.45
***************
*** 832,835 ****
--- 832,836 ----
          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