Issue2071

classification
Title: datetime strftime %f does not work in Jython 2.7
Type: behaviour Severity: normal
Components: Library Versions: Jython 2.7
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: jeff.allen Nosy List: Arfrever, dcoles, jeff.allen, santa4nt
Priority: Keywords: patch

Created on 2013-07-23.17:51:20 by dcoles, last changed 2013-12-02.20:42:00 by jeff.allen.

Files
File name Uploaded Description Edit Remove
strftime_f.patch santa4nt, 2013-07-25.01:10:29
strftime_f.patch santa4nt, 2013-07-25.01:18:44
Messages
msg8072 (view) Author: David Coles (dcoles) Date: 2013-07-23.17:51:19
Steps to reproduce:

Jython 2.7b1+ (, May 9 2013, 17:33:05) 
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.7.0_25
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> d = datetime.datetime.now()
>>> d.strftime("%H:%M:%S.%f")
'17:47:35.%f'


Expected results:

Python 2.7.5 (default, Jul 12 2013, 16:58:06) 
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> d = datetime.datetime.now()
>>> d.strftime("%H:%M:%S.%f")
'17:48:32.770720'


Similar to issue1689, except that "%f" is part of datetime library in Python 2.7.
msg8073 (view) Author: Santoso Wijaya (santa4nt) Date: 2013-07-23.22:19:30
Related to issue 1964 [1]?

[1] http://bugs.jython.org/issue1964
msg8074 (view) Author: Santoso Wijaya (santa4nt) Date: 2013-07-25.01:10:29
Nevermind. Similar issue, but completely different code paths.

Attaching a patch that includes a preprocessing step in _wrap_strftime() to include "%f".

$ ./dist/bin/jython -c "import datetime; d = datetime.datetime.now(); print d.strftime('%H:%M:%S.%f')"
18:11:32.289000
msg8075 (view) Author: Santoso Wijaya (santa4nt) Date: 2013-07-25.01:17:15
Patch + re-enabling unittest that would have caught this.
msg8187 (view) Author: Jeff Allen (jeff.allen) Date: 2013-12-01.21:03:24
I'll take this one to evaluate. Thanks for submitting it.

Hmmm, we ought not to skip those other tests silently. I think the right thing to do here is bring on the test_datetime.py from Python 2.7 and skip noisily the tests Jython can't pass ... implying a need for more patches in the same area.
msg8191 (view) Author: Jeff Allen (jeff.allen) Date: 2013-12-02.20:42:00
Fixed in http://hg.python.org/jython/rev/8b200f9ff1ea . And the next changeset updates test_datetime.py as I proposed, making the skips visible.

Thanks for this and related patches.
History
Date User Action Args
2013-12-02 20:42:00jeff.allensetstatus: open -> closed
resolution: fixed
messages: + msg8191
2013-12-02 13:45:46Arfreversetnosy: + Arfrever
2013-12-01 21:03:24jeff.allensetassignee: jeff.allen
messages: + msg8187
nosy: + jeff.allen
2013-07-25 01:18:44santa4ntsetfiles: + strftime_f.patch
2013-07-25 01:17:15santa4ntsetmessages: + msg8075
2013-07-25 01:10:30santa4ntsetfiles: + strftime_f.patch
keywords: + patch
messages: + msg8074
2013-07-23 22:19:30santa4ntsetnosy: + santa4nt
messages: + msg8073
2013-07-23 17:51:20dcolescreate