Issue2162

classification
Title: (date)time.strptime parses invalid strings
Type: behaviour Severity: normal
Components: Library Versions: Jython 2.7, Jython 2.5
Milestone:
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: pekka.klarck, santa4nt, zyasoft
Priority: Keywords:

Created on 2014-06-07.22:38:36 by pekka.klarck, last changed 2015-02-11.22:10:40 by zyasoft.

Messages
msg8600 (view) Author: Pekka Klärck (pekka.klarck) Date: 2014-06-07.22:38:35
1) Day/month with 00 value is accepted:
 
    Jython 2.5.3 (2.5:c56500f08d34+, Aug 13 2012, 14:48:36) 
    [Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.7.0_55
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import time, datetime
    >>> time.strptime('0000-00-00 00:00:00', '%Y-%m-%d %H:%M:%S')
    (2, 11, 30, 0, 0, 0, 6, 334, -1)
    >>> datetime.datetime.strptime('0000-00-00 00:00:00', '%Y-%m-%d %H:%M:%S')
    datetime.datetime(2, 11, 30, 0, 0)

With CPython both of the above yield this error:

    ValueError: time data '0000-00-00 00:00:00' does not match format '%Y-%m-%d %H:%M:%S'


2) String not matching pattern is accepted:

    >>> time.strptime('11:59 02-06-2014', '%H:%M %d-%m')
    (1970, 6, 2, 11, 59, 0, 1, 153, -1)
    >>> datetime.datetime.strptime('11:59 02-06-2014', '%H:%M %d-%m')
    datetime.datetime(1970, 6, 2, 11, 59)

With CPython you get:

    ValueError: unconverted data remains: -2014
msg8601 (view) Author: Santoso Wijaya (santa4nt) Date: 2014-06-08.01:00:44
The latter (2) has been addressed in Jython 2.7.x, I believe.
msg9489 (view) Author: Jim Baker (zyasoft) Date: 2015-02-07.01:15:15
Per Santoso, this has been fixed for some time in 2.7, and it's not something we would backport to 2.5
History
Date User Action Args
2015-02-11 22:10:40zyasoftsetstatus: pending -> closed
2015-02-07 01:15:16zyasoftsetstatus: open -> pending
resolution: out of date
messages: + msg9489
nosy: + zyasoft
2014-06-08 01:00:45santa4ntsettype: behaviour
messages: + msg8601
nosy: + santa4nt
components: + Library
versions: + Jython 2.5, Jython 2.7
2014-06-07 22:38:36pekka.klarckcreate