[Python-bugs-list] [ python-Bugs-482510 ] bug in slicing time.struct_time

noreply@sourceforge.net noreply@sourceforge.net
Fri, 16 Nov 2001 08:26:55 -0800


Bugs item #482510, was opened at 2001-11-16 08:04
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=482510&group_id=5470

Category: Python Library
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: bug in slicing time.struct_time

Initial Comment:
There seems to be a bug in the slicing of time.struct_time
Getting a single item works but a slice doesn't if you use a non-zero start.
i.e. t[i] works and t[:j] seems to be ok,
but t[i:] and t[i:j] don't work
 - they seem to overwrite the first i items with <NULL>

see the transcript below for examples:

>>> import time
>>> time.localtime()
(2001, 11, 16, 21, 17, 9, 4, 320, 0)
>>> time.localtime()[3:6]
(<NULL>, <NULL>, <NULL>)
>>> time.localtime()[-2]
320
>>> time.localtime()[-2:]
(<NULL>, <NULL>)
>>> time.localtime()[:-2]
(2001, 11, 16, 21, 17, 56, 4)
>>> t = time.struct_time((2001, 11, 16, 21, 18, 0, 4, 320, 0))
>>> t.tm_year
2001
>>> t[3:6]
(<NULL>, <NULL>, <NULL>)
>>> t[0:]
(2001, 11, 16, 21, 18, 0, 4, 320, 0)
>>> t[:0]
()
>>> t[:-1]
(2001, 11, 16, 21, 18, 0, 4, 320)
>>> t[:-3]
(2001, 11, 16, 21, 18, 0)
>>> t[1:]
(<NULL>, 11, 16, 21, 18, 0, 4, 320)
>>> t[4:]
(<NULL>, <NULL>, <NULL>, <NULL>, 18)
>>> t.__getslice__(2, 5)
(<NULL>, <NULL>, 16)


----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2001-11-16 08:26

Message:
Logged In: NO 

Addendum to the above:
Sorry, I forgot to mention the platform - this is with the binary distribution of 2.2b1 for Windows (i.e. Python-2.2b1.exe).
I found the problem on Win98 & Win2K - haven't tried any other platforms yet.


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=482510&group_id=5470