Issue2730

classification
Title: datetime.strptime('%b') behaviour inconsistent with CPython on Windows JDK 9+
Type: behaviour Severity: normal
Components: Library Versions: Jython 2.7
Milestone:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: adamburke
Priority: Keywords:

Created on 2019-01-08.07:46:47 by adamburke, last changed 2019-01-08.07:51:10 by adamburke.

Messages
msg12290 (view) Author: Adam Burke (adamburke) Date: 2019-01-08.07:46:46
It seems there are a few datetime.strptime() / strftime() issues, but this seems like a new variation.

On JDK 9+, Windows 10, the short name for months has changed even for English locales to include a fullstop. This causes incompatibility with CPython and earlier versions of Jython, and breaks regtests, mainly those inherited from CPython itself.

Regrtest sample output
> dist\bin\jython.exe -m test.regrtest -v test_strptime

======================================================================
ERROR: test_feb29_on_leap_year_without_year (test.test_strptime.StrptimeTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Adam\jython\jython3\dist\Lib\test\test_strptime.py", line 382, in test_feb29_on_leap_year_without_year
    time.strptime("Feb 29", "%b %d")
  File "C:\Users\Adam\jython\jython3\dist\Lib\_strptime.py", line 467, in _strptime_time
    return _strptime(data_string, format)[0]
  File "C:\Users\Adam\jython\jython3\dist\Lib\_strptime.py", line 324, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data u'Feb 29' does not match format u'%b %d'

ERROR: test_mar1_comes_after_feb29_even_when_omitting_the_year (test.test_strptime.StrptimeTests)
FAIL: test_pattern (test.test_strptime.TimeRETests)

Demonstration script:
import os
import time
from datetime import date

print (os.uname())
print (os.environ['JAVA_HOME'])

print ( date(2002, 2, 4).strftime('%b %d')  )


print ( time.strptime("Jan. 29", "%b %d") ) # No ValueError
print ( time.strptime("Jan 29", "%b %d") ) # ValueError

C:\Users\Adam\jython\jython3>dist\bin\jython.exe datebug20190108.py
('Windows', '...', '10', '...', 'AMD64')
C:\Program Files\Java\jdk-11.0.1
Feb. 04
time.struct_time(tm_year=1900, tm_mon=1, tm_mday=29, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=0, tm_yday=29, tm_isdst=-1)
Traceback (most recent call last):
  File "datebug20190108.py", line 13, in <module>
    print ( time.strptime("Jan 29", "%b %d") ) # ValueError
  File "C:\Users\Adam\jython\jython3\dist\Lib\_strptime.py", line 467, in _strptime_time
    return _strptime(data_string, format)[0]
  File "C:\Users\Adam\jython\jython3\dist\Lib\_strptime.py", line 324, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data u'Jan 29' does not match format u'%b %d'
msg12292 (view) Author: Adam Burke (adamburke) Date: 2019-01-08.07:48:54
Tested on JDK 9 and 11. Causes some related failures across a few reg tests.
msg12294 (view) Author: Adam Burke (adamburke) Date: 2019-01-08.07:51:10
Related 
#2503
#2285
History
Date User Action Args
2019-01-08 07:51:10adamburkesetmessages: + msg12294
2019-01-08 07:48:54adamburkesetmessages: + msg12292
2019-01-08 07:46:47adamburkecreate