Edgewall Software

Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#10768 closed defect (fixed)

`format_datetime` calls `locale.getpreferredencoding()` which is NOT thread-safe — at Version 3

Reported by: Jun Omae Owned by:
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

Change History (3)

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, 11 years ago

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

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

Note: See TracTickets for help on using tickets.