Modify

Opened 5 years ago

Closed 4 years ago

Last modified 3 years ago

#6786 closed defect (fixed)

usage of strftime() causes a "Genshi UnicodeDecodeError"

Reported by: Jens.Langner@… Owned by: rjollos
Priority: normal Component: TicketChangePlugin
Severity: critical Keywords:
Cc: Trac Release: 0.11

Description

Similar to ticket #4820 this plugins suffers from incorrectly using strftime() which in turn causes a "Genshi UnicodeDecodeError" to appear when a ticket is changed and the Locale is not english.

The following patch fixes the issues:

===================================================================
--- ticketchange/web_ui.py	(revision 7751)
+++ ticketchange/web_ui.py	(working copy)
@@ -168,11 +168,11 @@
         row = cursor.fetchone()
         if not row:
             raise ResourceNotFound("Unable to update comment on Ticket #%d at time '%s' ('%s') - existing change not found.\n" \
-                                   % (id, time, strftime('%A, %d %b %Y %H:%M:%S', localtime(time))))
+                                   % (id, time, strftime('%x %X', localtime(time))))
         old_author, old_comment = (row[0], row[1])
         cursor.execute("UPDATE ticket_change SET newvalue=%s WHERE ticket = %s AND time = %s AND field = 'comment'", (comment, id, time))
         db.commit()
         self.env.log.info("Ticket #%d comment of '%s' by '%s' has been updated by '%s':\nold value: '%s'\n\nnew value: '%s'\n" \
-                        % (id, strftime('%A, %d %b %Y %H:%M:%S', localtime(time)), old_author, author, old_comment.replace('\r', ''), comment.replace('\r','')))
+                        % (id, strftime('%x %X', localtime(time)), old_author, author, old_comment.replace('\r', ''), comment.replace('\r','')))

Attachments (0)

Change History (4)

comment:1 Changed 5 years ago by anonymous

Some up of this bug in 0.11

UnicodeDecodeError: 'ascii' codec can't decode byte 0xf1 in position 22: ordinal not in range(128)

comment:2 Changed 5 years ago by anonymous

Up to front!

File "C:\Python25\lib\site-packages\trac\web\main.py", line 450, in _dispatch_request
  dispatcher.dispatch(req)
File "C:\Python25\lib\site-packages\trac\web\main.py", line 206, in dispatch
  resp = chosen_handler.process_request(req)
File "build\bdist.win32\egg\ticketchange\web_ui.py", line 89, in process_requestFile "build\bdist.win32\egg\ticketchange\web_ui.py", line 176, in _update_ticket_comment

System Information:

User Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
Trac: 	0.11.7
Python: 	2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)]
setuptools: 	0.6c11
SQLite: 	3.3.4
pysqlite: 	2.3.2
Genshi: 	0.5.1
mod_python: 	3.3.1
Pygments: 	1.3.1
Subversion: 	1.6.6 (r40053)
RPC: 	1.0.6
jQuery:	1.2.6

comment:3 Changed 4 years ago by rjollos

  • Owner changed from SergeiLuchko to rjollos
  • Status changed from new to assigned

This can be fixed by proper use of trac.util.datefmt.

comment:4 Changed 4 years ago by rjollos

  • Resolution set to fixed
  • Status changed from assigned to closed

Fixed in [9655] and [9656]. The post-commit hook failed to reference this ticket.

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.