Edgewall Software
Modify

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#10768 closed defect (fixed)

`format_datetime` calls `locale.getpreferredencoding()` which is NOT thread-safe

Reported by: Jun Omae Owned by: Jun Omae
Priority: normal Milestone: 0.12.5
Component: general Version: 0.12
Severity: normal Keywords:
Cc:
Release Notes:
API Changes:

Add trac.util.text.getpreferredencoding which returns the cached result of locale.getpreferredencoding()

Description

format_datetime function in trac.util.datefmt calls locale.getpreferredencoding() which is NOT thread-safe.

On some systems, it is necessary to invoke setlocale() to obtain the user preferences, so this function is not thread-safe. If invoking setlocale is not necessary or desired, do_setlocale should be set to False. From http://docs.python.org/library/locale.html#locale.getpreferredencoding

I think we should call locale.getpreferredencoding() on ahead and cache the retrieved value.

repos:jomae.git:ticket10768/cached-pref-encoding/0.12-stable

Attachments (0)

Change History (4)

comment:1 Changed 6 years ago by Jun Omae

Milestone: 0.12.4next-stable-1.0.x

comment:2 Changed 6 years ago by Christian Boos

Milestone: next-stable-1.0.x0.12.5

Looks good! This one somehow slipped through when doing 0.12.4, but I think this is fine for 0.12-stable as well (import () put aside).

comment:3 Changed 6 years ago by Jun Omae

API Changes: modified (diff)
Resolution: fixed
Status: newclosed

Applied in [11438-11440], which don't use import ().

comment:4 Changed 6 years ago by Jun Omae

Owner: set to Jun Omae

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted.
to The owner will be changed from Jun Omae to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.