Opened 4 years ago

Closed 3 years ago

#19417 closed Bug (duplicate)

Django 1.4.2 does not support Jython 2.5.3 (strptime issue)

Reported by: fvox13 Owned by: nobody
Component: Documentation Version: 1.4
Severity: Normal Keywords: strptime jython forms datetimefield
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by aaugustin)

As near as I can tell, this is a problem with Django / Jython compatibility and not my code... if I'm wrong feel free to slap my wrist...

A form was created with the following field:
start_date = forms.DateTimeField(required=True, widget=forms.DateTimeInput({'class': 'datetime'}))

The following POST data was passed:
start_date u'11/03/2012 00:00:00'

The following traceback was received when I check for form.is_valid() in the view:


Request Method: POST
Request URL:

Django Version: 1.4.2
Python Version: 2.5.3
Installed Applications:
Installed Middleware:

File "/usr/share/msa/jython/Lib/site-packages/Django-1.4.2-py2.5.egg/django/core/handlers/" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/usr/share/msa/jython/Lib/site-packages/Django-1.4.2-py2.5.egg/django/core/handlers/" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/usr/share/msa/jython/Lib/site-packages/Django-1.4.2-py2.5.egg/django/views/decorators/" in inner
  41.             return func(request, *args, **kwargs)
File "/usr/share/msa/ui/mykui/" in _inner
  49. 		return view(*args, **kwargs)
File "/usr/share/msa/ui/mykui/" in _inner
  31. 		return view(*args, **kwargs)
File "/usr/share/msa/ui/mykui/reports/" in reports_ondemand
  38. 				if form.is_valid():
File "/usr/share/msa/jython/Lib/site-packages/Django-1.4.2-py2.5.egg/django/forms/" in is_valid
  124.         return self.is_bound and not bool(self.errors)
File "/usr/share/msa/jython/Lib/site-packages/Django-1.4.2-py2.5.egg/django/forms/" in _get_errors
  115.             self.full_clean()
File "/usr/share/msa/jython/Lib/site-packages/Django-1.4.2-py2.5.egg/django/forms/" in full_clean
  270.         self._clean_fields()
File "/usr/share/msa/jython/Lib/site-packages/Django-1.4.2-py2.5.egg/django/forms/" in _clean_fields
  287.                     value = field.clean(value)
File "/usr/share/msa/jython/Lib/site-packages/Django-1.4.2-py2.5.egg/django/forms/" in _clean_fields
  287.                     value = field.clean(value)
File "/usr/share/msa/jython/Lib/site-packages/Django-1.4.2-py2.5.egg/django/forms/" in clean
  153.         value = self.to_python(value)
File "/usr/share/msa/jython/Lib/site-packages/Django-1.4.2-py2.5.egg/django/forms/" in to_python
  437.         result = super(DateTimeField, self).to_python(value)
File "/usr/share/msa/jython/Lib/site-packages/Django-1.4.2-py2.5.egg/django/forms/" in to_python
  342.                     return self.strptime(value, format)
File "/usr/share/msa/jython/Lib/site-packages/Django-1.4.2-py2.5.egg/django/forms/" in to_python
  342.                     return self.strptime(value, format)
File "/usr/share/msa/jython/Lib/site-packages/Django-1.4.2-py2.5.egg/django/forms/" in strptime
  441.         return datetime.datetime.strptime(value, format)
File "/usr/share/msa/jython/Lib/" in strptime
  1499.         return cls(*(_time.strptime(date_string, format))[0:6])

Exception Type: IllegalArgumentException at /reports/ondemand/Top_Incident_Types/
Exception Value: java.lang.IllegalArgumentException: Illegal pattern character 'f'

At 441, format = '%Y-%m-%d %H:%M:%S.%f'

The %f formatting character was introduced in Python 2.6, but it is not supported in Jython, even in the 2.7 alphas.

I remember this code working fine in Django 1.4.1, but I cannot seem to find a commit that would have broken it during the timeframe between the 1.4.1 and 1.4.2 releases.

Change History (6)

comment:1 Changed 4 years ago by aaugustin

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

This behavior was introduced by the fix for #9459.

comment:2 Changed 4 years ago by russellm

  • Triage Stage changed from Unreviewed to Design decision needed
  • Type changed from Uncategorized to Bug

Given that this is a known bug in Jython, I'm not sure what the right response is here. The %f is needed to fix the problem from #9459; the right solution would seem to be "Fix Jython", not "put in a workaround in Django".

comment:3 Changed 4 years ago by fvox13

I agree that Jython is the right place to put the fix. However, as it stands right now, our documentation is wrong, because it states that we are compatible with Jython 2.5, when we're not. Some mention of this bug should appear here: especially given how common DateTimeField usage is.

comment:4 Changed 3 years ago by aaugustin

  • Triage Stage changed from Design decision needed to Accepted

Accepting as a doc fix.

comment:5 Changed 3 years ago by timo

  • Component changed from Forms to Documentation

comment:6 Changed 3 years ago by timo

  • Resolution set to duplicate
  • Status changed from new to closed

Marking as a duplicate of #20517 which suggests documenting Jython issues on a wiki page. I've made a note of this issue on that ticket.

Note: See TracTickets for help on using tickets.
Back to Top