Edgewall Software
Modify

Opened 17 years ago

Closed 17 years ago

#5778 closed defect (fixed)

Codepages bug in macros

Reported by: OXIj Owned by: Christian Boos
Priority: low Milestone: 0.11
Component: wiki system Version:
Severity: trivial Keywords: unicode datetime locale
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Example macro fails with unicode error on Russian UTF-8 locale.

class TimestampMacro(WikiMacroBase):
    """Inserts the current time (in seconds) into the wiki page."""

    def expand_macro(self, formatter, name, args):
        t = time.localtime()
        return tag.b(time.strftime('%c', t))

this code resolved the problem:

class TimestampMacro(WikiMacroBase):
    """Inserts the current time (in seconds) into the wiki page."""

    def expand_macro(self, formatter, name, args):
        t = time.localtime()
        return tag.b(unicode(time.strftime('%c', t), "utf-8"))

but it shold be written better (with locale checking), and some other macros may have this bug too

Attachments (0)

Change History (2)

comment:1 by Christian Boos, 17 years ago

Milestone: 0.11.1

Ok, to_unicode should be used there.

comment:2 by Christian Boos, 17 years ago

Keywords: datetime locale added
Milestone: 0.11.10.11
Resolution: fixed
Status: newclosed

The fix was slightly more involved and lead me to find a problem with the datefmt.format_datetime utility, see r6113.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos 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.