Opened 15 years ago
Last modified 8 years ago
#5748 closed defect
PeerReview search on date fail on non-US locales — at Initial Version
Reported by: | Owned by: | mikechml | |
---|---|---|---|
Priority: | normal | Component: | PeerReviewPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: | 0.11 |
Description
I'm running the current subversion version (r6459) of the 2.2-dev branch of the plugin, over a 0.11.5 trac. I see the following error when I perform a "search code reviews" and specify a date for "Reviews after date":
Most recent call last:
- File "/home/arbit/opt/2/x86_64/lib/python2.5/site-packages/Trac-0.11.5-py2.5.egg/trac/web/main.py", line 444, in _dispatch_request
Code fragment:
- try:
- if not env and env_error:
- raise HTTPInternalError(env_error)
- try:
- dispatcher = RequestDispatcher(env)
- dispatcher.dispatch(req)
- except RequestDone:
- pass
- resp = req._response or []
- except HTTPException, e:
- File "/home/arbit/opt/2/x86_64/lib/python2.5/site-packages/Trac-0.11.5-py2.5.egg/trac/web/main.py", line 205, in dispatch
Code fragment:
- req.args.get('FORM_TOKEN') != req.form_token:
- raise HTTPBadRequest('Missing or invalid form token. '
- 'Do you have cookies enabled?')
- # Process the request and render the template
- resp = chosen_handler.process_request(req)
- if resp:
- if len(resp) == 2: # Clearsilver
- chrome.populate_hdf(req)
- template, content_type = \
- self._post_process_request(req, *resp)
- File "build/bdist.linux-i686/egg/codereview/peerReviewSearch.py", line 52, in process_request Local variables: Name Value data {'searchValues_author': u'Select...', 'searchValues_day': u'01', ... req <Request "POST u'/peerReviewSearch'"> self <codereview.peerReviewSearch.UserbaseModule object at 0xc98d090>
- File "build/bdist.linux-i686/egg/codereview/peerReviewSearch.py", line 138, in performSearch Local variables: Name Value author u'Select...' crStruct <codereview.CodeReviewStruct.CodeReviewStruct object at 0xd0ff4d0> data {'searchValues_author': u'Select...', 'searchValues_day': u'01', ... day u'01' fromdate '-1' month u'08' name u req <Request "POST u'/peerReviewSearch'"> self <codereview.peerReviewSearch.UserbaseModule object at 0xc98d090> status u'Select...' year u'2009'
- File "/home/arbit/opt/2/x86_64/lib/python2.5/_strptime.py", line 330, in strptime
Code fragment:
- finally:
- _cache_lock.release()
- found = format_regex.match(data_string)
- if not found:
- raise ValueError("time data did not match format: data=%s fmt=%s" %
- (data_string, format))
- if len(data_string) != found.end():
- raise ValueError("unconverted data remains: %s" %
- data_string[found.end():])
- year = 1900
- month = day = 1
File "/home/arbit/opt/2/x86_64/lib/python2.5/site-packages/Trac-0.11.5-py2.5.egg/trac/web/main.py", line 444, in _dispatch_request
dispatcher.dispatch(req)
File "/home/arbit/opt/2/x86_64/lib/python2.5/site-packages/Trac-0.11.5-py2.5.egg/trac/web/main.py", line 205, in dispatch
resp = chosen_handler.process_request(req)
File "build/bdist.linux-i686/egg/codereview/peerReviewSearch.py", line 52, in process_requestFile "build/bdist.linux-i686/egg/codereview/peerReviewSearch.py", line 138, in performSearchFile "/home/arbit/opt/2/x86_64/lib/python2.5/_strptime.py", line 330, in strptime
(data_string, format))
It is clear that the culprit is the following line in the peerReviewSearch function:
t = time.strptime(month + '/' + day + '/' + year[2] + year[3], '%x')
This does not work in all locale, since "%x" means the following, as described in the manual of the time module:
%x: Locale’s appropriate date representation
Since the date string constructed by the program is always in a particular format, I suggest changing it to:
t = time.strptime(month + '/' + day + '/' + year[2] + year[3], '%m/%d/%y')