Opened 7 years ago

Closed 6 years ago

#13196 closed defect (fixed)

Decode bytestrings to Unicode before storing them in the DB

Reported by: Peter Suter Owned by: Peter Suter
Priority: normal Component: OnSiteNotificationsPlugin
Severity: normal Keywords:
Cc: Trac Release:


From the mailing list:

I now see the following in my browser and Trac log file:

"Warning: The change has been saved, but an error occurred while sending notifications: You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings. "

That message is raised from SQLite bindings.

I guess this plugin uses utf-8 bytestring to create record when sending notification.

diff --git a/onsitenotificationsplugin/trunk/onsitenotifications/
index 3499c4dd8..59fdb3432 100644
--- a/onsitenotificationsplugin/trunk/onsitenotifications/
+++ b/onsitenotificationsplugin/trunk/onsitenotifications/
@@ -12,6 +12,7 @@ from trac.resource import Resource,
get_resource_description, get_resource_url
 from trac.web.api import IRequestHandler
 from import add_ctxtnav, INavigationContributor
 from trac.util.compat import set
+from trac.util.text import to_unicode

 from onsitenotifications.model import OnSiteMessage

@@ -72,6 +73,7 @@ class OnSiteNotificationsDistributor(Component):

         for fmt, sids in msgdict.iteritems():
             message = formats[fmt].format(transport, fmt, event)
+            message = to_unicode(message)
             for sid, authenticated in sids:
                 OnSiteMessage.add(self.env, sid, authenticated, message,
                                   event.realm, get_target_id(

Attachments (0)

Change History (2)

comment:1 Changed 6 years ago by Peter Suter

In 16948:

OnSiteNotificationsPlugin: Decode bytestrings to Unicode before storing them in the DB.
(see #13196)

comment:2 Changed 6 years ago by Peter Suter

Resolution: fixed
Status: newclosed

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Peter Suter.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment

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

Note: See TracTickets for help on using tickets.