Menu

Commit [r3141]  Maximize  Restore  History

Unicode consolidation: use `to_unicode(x)` instead of `unicode(x)` when `x` might be a `str` object.

This is especially true when the content may come from a plugin,
e.g. the fix in the `WikiProcessor` will likely fix #3024.

`to_unicode` will always succeed at producing some unicode object,
whereas the basic `unicode(x)` call can raise an `UnicodeDecodeError`
when given an arbitrarily encoded string.
Thus, `unicode(x)` should only be used when we're confident that `x`
is already an `unicode` or derived object, like `Markup`, or is some other type that can be safely converted to `unicode`.

This also fixes the problems that happened in TracAdmin
when `sys.stdin.encoding` was `None` (#3018).

''Last minute, the typo introduced in r3138 in `format_datetime` is fixed,
and mgood actually already fixed #3018 in r3140 :)''

cboos 2006-04-13

changed /trunk/trac/Timeline.py
changed /trunk/trac/db/schema.py
changed /trunk/trac/env.py
changed /trunk/trac/mimeview/api.py
changed /trunk/trac/mimeview/patch.py
changed /trunk/trac/ticket/query.py
changed /trunk/trac/util/__init__.py
changed /trunk/trac/web/clearsilver.py
changed /trunk/trac/web/main.py
changed /trunk/trac/wiki/formatter.py
changed /trunk/trac/wiki/tests/formatter.py
/trunk/trac/Timeline.py Diff Switch to side-by-side view
Loading...
/trunk/trac/db/schema.py Diff Switch to side-by-side view
Loading...
/trunk/trac/env.py Diff Switch to side-by-side view
Loading...
/trunk/trac/mimeview/api.py Diff Switch to side-by-side view
Loading...
/trunk/trac/mimeview/patch.py Diff Switch to side-by-side view
Loading...
/trunk/trac/ticket/query.py Diff Switch to side-by-side view
Loading...
/trunk/trac/util/__init__.py Diff Switch to side-by-side view
Loading...
/trunk/trac/web/clearsilver.py Diff Switch to side-by-side view
Loading...
/trunk/trac/web/main.py Diff Switch to side-by-side view
Loading...
/trunk/trac/wiki/formatter.py Diff Switch to side-by-side view
Loading...
/trunk/trac/wiki/tests/formatter.py Diff Switch to side-by-side view
Loading...
MongoDB Logo MongoDB