Opened 12 years ago
Closed 11 years ago
#19417 closed Bug (duplicate)
Django 1.4.2 does not support Jython 2.5.3 (strptime issue)
Reported by: | Steven L Smith | 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 )
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:
Environment: Request Method: POST Request URL: http://127.0.0.1:6701/reports/ondemand/Top_Incident_Types/ Django Version: 1.4.2 Python Version: 2.5.3 Installed Applications: ('django.contrib.formtools', 'django.contrib.humanize', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'mykui.accounts', 'mykui.console', 'mykui.mykonfig', 'mykui.reports', 'mykui.status', 'mykui.updates', 'mykui.util') Installed Middleware: ('django.middleware.gzip.GZipMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'mykui.middleware.UserMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'mykui.middleware.UnavailableMiddleware', 'mykui.middleware.SystemMessageMiddleware', 'mykui.middleware.TimezoneMiddleware') Traceback: File "/usr/share/msa/jython/Lib/site-packages/Django-1.4.2-py2.5.egg/django/core/handlers/base.py" 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/base.py" 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/http.py" in inner 41. return func(request, *args, **kwargs) File "/usr/share/msa/ui/mykui/decorators.py" in _inner 49. return view(*args, **kwargs) File "/usr/share/msa/ui/mykui/decorators.py" in _inner 31. return view(*args, **kwargs) File "/usr/share/msa/ui/mykui/reports/views.py" 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/forms.py" 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/forms.py" in _get_errors 115. self.full_clean() File "/usr/share/msa/jython/Lib/site-packages/Django-1.4.2-py2.5.egg/django/forms/forms.py" in full_clean 270. self._clean_fields() File "/usr/share/msa/jython/Lib/site-packages/Django-1.4.2-py2.5.egg/django/forms/forms.py" 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/forms.py" 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/fields.py" 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/fields.py" 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/fields.py" 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/fields.py" 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/fields.py" in strptime 441. return datetime.datetime.strptime(value, format) File "/usr/share/msa/jython/Lib/datetime.py" 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. http://bugs.jython.org/issue1964
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 by , 12 years ago
Description: | modified (diff) |
---|
comment:2 by , 12 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|---|
Type: | Uncategorized → 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 by , 12 years ago
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: https://docs.djangoproject.com/en/1.4/howto/jython/ especially given how common DateTimeField usage is.
comment:5 by , 12 years ago
Component: | Forms → Documentation |
---|
comment:6 by , 11 years ago
Resolution: | → duplicate |
---|---|
Status: | new → 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.
This behavior was introduced by the fix for #9459.