Edgewall Software
Modify

Opened 12 years ago

Closed 12 years ago

Last modified 12 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: Branch:
Release Notes:
API Changes:

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

Internal Changes:

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 by Jun Omae, 12 years ago

Milestone: 0.12.4next-stable-1.0.x

comment:2 by Christian Boos, 12 years ago

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 by Jun Omae, 12 years ago

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

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

comment:4 by Jun Omae, 12 years ago

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. Next status will be 'reopened'.
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.