Modify

Opened 13 years ago

Closed 13 years ago

#9124 closed defect (fixed)

Macro failed with "strftime() argument 1 must be str, not unicode"

Reported by: falkb Owned by: Chris Nelson
Priority: normal Component: TracJsGanttPlugin
Severity: normal Keywords:
Cc: Ryan J Ollos Trac Release: 0.12

Description (last modified by Ryan J Ollos)

with today's official plugin version:

[2011-08-25 14:34:57,065 p3000:t3288] formatter.py:720 ERROR: Macro TracJSGanttChart(milestone=P7 X-Mount - M9) failed: 
Traceback (most recent call last):
  File "build\bdist.win32\egg\trac\wiki\formatter.py", line 717, in _macro_formatter
    return macro.process(args, in_paragraph=True)
  File "build\bdist.win32\egg\trac\wiki\formatter.py", line 304, in process
    text = self.processor(text)
  File "build\bdist.win32\egg\trac\wiki\formatter.py", line 291, in _macro_processor
    text)
  File "build\bdist.win32\egg\tracjsgantt\tracjsgantt.py", line 896, in expand_macro
    tasks = self._add_tasks(options)
  File "build\bdist.win32\egg\tracjsgantt\tracjsgantt.py", line 847, in _add_tasks
    self._add_milestones(options)
  File "build\bdist.win32\egg\tracjsgantt\tracjsgantt.py", line 594, in _add_milestones
    format_date(ts, self.dbDateFormat)
  File "build\bdist.win32\egg\trac\util\datefmt.py", line 162, in format_date
    return format_datetime(t, format, tzinfo=tzinfo)
  File "build\bdist.win32\egg\trac\util\datefmt.py", line 145, in format_datetime
    text = t.strftime(format)
TypeError: strftime() argument 1 must be str, not unicode

Attachments (0)

Change History (11)

comment:1 Changed 13 years ago by falkb

  • the error doesn't happen with just [[TracJSGanttChart(sample=1)]]
  • the error also happens with simple milestone names without spaces

comment:2 Changed 13 years ago by anonymous

Have the same issue.

centos 5.6 apache mod_python trac 11.7

Using the sample setting doesn't throw an error but I don't see a gantt chart.

comment:3 Changed 13 years ago by anonymous

I reckon it's because I'm driving a 0.12.2 with Babel for internationalization on board. And probably the Gantt developers have just a non-Unicode version installed. And somewhere they don't use something like a unicode-to-simple_char_string converter.

comment:4 Changed 13 years ago by anonymous

I had the same issue (centos 5.6 / trac 11.5)

I got it "fixed" by replacing the line

# This is the format of start and finish in the Trac database
self.dbDateFormat = self.config.get('trac-jsgantt', 'date_format') 

with

self.dbDateFormat = '%Y-%m-%d'

(which is what I had in the config file as well, so I took a guess this might work :) )

And then I got nice charts.

Since the last traceback call of the ganttplugin was the equivalent of the OP's:

File "build\bdist.win32\egg\tracjsgantt\tracjsgantt.py", line 594, in _add_milestones
format_date(ts, self.dbDateFormat) 

, it seems the self.config.get function can return unicode strings and trac's format_date function can only handle non-unicode strings.

Well, maybe this helps...

comment:5 in reply to:  4 Changed 13 years ago by falkb

Replying to anonymous:

I had the same issue (centos 5.6 / trac 11.5)

I got it "fixed" by...

---8<-----8<----- snip

Thanks for your hint that gives my internet-searching the right keywords... and after reading ticket/7698 and [9596] it seems to me that this might be the bugfix at browser/tracjsganttplugin/0.11/tracjsgantt/tracjsgantt.py:

- self.dbDateFormat = self.config.get('trac-jsgantt', 'date_format')
+ self.dbDateFormat = str(self.config.get('trac-jsgantt', 'date_format'))

Anyway, now the chart appears for me again.

comment:6 Changed 13 years ago by Chris Nelson

Status: newassigned

comment:7 Changed 13 years ago by Chris Nelson

(In [10687]) Make sure dbDateFormat is not unicode. Refs #9124.

It appears that in Trac 0.12, configuration options are returned as unicode strings but the Python date conversion routines insist on a simple string.

Converting the value to a string explicitly seems to do no harm in 0.11 and hopefully will just work in 0.12 (I can't test there).

comment:8 Changed 13 years ago by falkb

You can close this ticket. Works now. Thanks.

comment:9 Changed 13 years ago by Ryan J Ollos

Cc: Ryan J Ollos added; anonymous removed

comment:10 Changed 13 years ago by Ryan J Ollos

Description: modified (diff)

comment:11 Changed 13 years ago by Chris Nelson

Resolution: fixed
Status: assignedclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Chris Nelson.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.