Message7429
time.strptime() does not support %f in format.
%f was added in CPython 2.6: http://bugs.python.org/issue1158
CPython 2.7:
$ python2.7 -c 'import time; print(time.strptime("0", "%f"))'
time.struct_time(tm_year=1900, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=0, tm_yday=1, tm_isdst=-1)
$
Jython 2.7:
$ jython2.7 -c 'import time; print(time.strptime("0", "%f"))'
Traceback (most recent call last):
File "<string>", line 1, in <module>
at java.text.SimpleDateFormat.compile(SimpleDateFormat.java:845)
at java.text.SimpleDateFormat.initialize(SimpleDateFormat.java:659)
at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:585)
at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:560)
at org.python.modules.time.Time.strptime(Time.java:707)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Illegal pattern character 'f'
$
src/org/python/modules/time/Time.java contains the following code, which does not detect format not translatable to Java:
String jformat = py2java_format(format);
if (jformat == null) {
// Format not translatable to java, fallback to _strptime
return pystrptime(data_string, format);
}
SimpleDateFormat d = new SimpleDateFormat(jformat);
Another symptom of probably the same bug is wrong exception (java.lang.IllegalArgumentException instead of ValueError documented in documentation of time.strptime):
$ python2.7 -c 'import time; print(time.strptime("", "%e"))'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib64/python2.7/_strptime.py", line 467, in _strptime_time
return _strptime(data_string, format)[0]
File "/usr/lib64/python2.7/_strptime.py", line 317, in _strptime
(bad_directive, format))
ValueError: 'e' is a bad directive in format '%e'
$ jython2.7 -c 'import time; print(time.strptime("", "%e"))'
Traceback (most recent call last):
File "<string>", line 1, in <module>
at java.text.SimpleDateFormat.compile(SimpleDateFormat.java:845)
at java.text.SimpleDateFormat.initialize(SimpleDateFormat.java:659)
at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:585)
at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:560)
at org.python.modules.time.Time.strptime(Time.java:707)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Illegal pattern character 'e'
$ |
|
Date |
User |
Action |
Args |
2012-08-28 08:38:11 | Arfrever | set | recipients:
+ Arfrever |
2012-08-28 08:38:11 | Arfrever | set | messageid: <1346143091.32.0.640620819206.issue1964@psf.upfronthosting.co.za> |
2012-08-28 08:38:11 | Arfrever | link | issue1964 messages |
2012-08-28 08:38:10 | Arfrever | create | |
|