Modify

Opened 4 years ago

Closed 16 months ago

#6636 closed defect (fixed)

[patch] Failure on use: "day of month out of range" (in Python 2.4)

Reported by: Michel Jouvin <jouvin@…> Owned by: hasienda
Priority: normal Component: WikiCalendarMacro
Severity: normal Keywords: date/time timezone locale
Cc: Trac Release: 0.12

Description

I just installed WikiCalendarMacro r7528 on a fairly recent Trac trunk (r9115). I cannot succeed to get it to work. Whatever argument I use, I get the error message "day of month out of range" with the following traceback in the log file:

2010-02-15 21:16:38,102 Trac[formatter] ERROR: Macro WikiCalendar(*,*) failed:
Traceback (most recent call last):
  File "build/bdist.linux-x86_64/egg/trac/wiki/formatter.py", line 608, in _macro_formatter
  File "build/bdist.linux-x86_64/egg/trac/wiki/formatter.py", line 273, in process

  File "build/bdist.linux-x86_64/egg/trac/wiki/formatter.py", line 260, in _macro_processor
    if not margin and fstack:
  File "/wwwdata/products/trac/site-config/plugins/0.11/WikiCalendarMacro.py", line 163, in expand_macro
    buff.write('<table><tr><td class="x"><a class="prev" href="%(url)s" title="%(title)s">&lt;&lt;</a></td>' % {
ValueError: day of month out of range

Cheers,

Michel

Attachments (0)

Change History (12)

comment:1 Changed 4 years ago by rjollos

I noticed this last week as well when I tried to install it on my production Trac instance. However, it seems to work fine in the Trac development environment.

I'll be working on fixing this within the hour. Can you send me the details of you system from the System Information section of the About page?

comment:2 Changed 4 years ago by Michel Jouvin <jouvin@…>

Her it is:

Trac	0.12dev-r9115
Python	2.4.3 (#1, Sep 10 2009, 18:34:35) [GCC 4.1.2 20080704 (Red Hat 4.1.2-46)]
setuptools	0.6c11
SQLite	3.5.9
pysqlite	2.3.3
Genshi	0.6dev-r1092
Babel	0.9.4
mod_wsgi	3.1 (WSGIProcessGroup trac WSGIApplicationGroup %{GLOBAL})
Pygments	1.0
RPC	1.0.6
FullBlog	0.1.1-r7214
GIT	1.6.6
Subversion	1.6.5 (r38866)
jQuery:	1.3.2

Michel

comment:3 Changed 4 years ago by rjollos

I'm also running Python 2.4 on my production Trac, but my development environment is Python 2.6.

The original author left a note "breaks Python 2.4": wikicalendarmacro/0.11/WikiCalendarMacro.py@7528:127:130#L127

I'll look into making this Python 2.4 compatible.

comment:4 Changed 4 years ago by rjollos

  • Status changed from new to assigned

I'm working on making it compatible with Python 2.4, but I need to setup a development Trac instance in a 2.4 virtualenv, so it will probably be a few days before I have a new revision of the macro ready.

Thank you for the detailed report, it helped with quickly tracking down the issue.

comment:5 Changed 4 years ago by Michel Jouvin <jouvin@…>

Any progress on this?

Cheers,

Michel

comment:6 Changed 4 years ago by pipern

  • Keywords patch added

Is this as simple as

  • WikiCalendarMacro.py

     
    127127        # 9-tuple for use with time.* functions requiring a struct_time 
    128128        # argument. The ninth value of -1 signals "do the right thing" 
    129129        # w.r.t. daylight savings time. 
    130         date = [0] * 8 + [-1] # AS: breaks Python 2.4 
     130        date = [1] * 8 + [-1] 
    131131        # date = list( today ) # AS: breaks SQL query 
    132132         
    133133        # building the output 

? This "appears to work" for the little manual testing I've done.

comment:7 Changed 4 years ago by rjollos

I'm on Python 2.6 now, so the macro is working for me. I'm happy to make the change if it will make it work with Python 2.4.

Michel, would you be willing to test the patch?

comment:8 Changed 4 years ago by rjollos

  • Summary changed from Failure to use the macro : day of month out of range to Failure to use the macro: day of month out of range (in Python 2.4)

comment:9 Changed 4 years ago by hasienda

  • Keywords date/time timezone locale added; patch removed
  • Summary changed from Failure to use the macro: day of month out of range (in Python 2.4) to [patch] Failure on use: "day of month out of range" (in Python 2.4)

An alternative approach would be to avoid Python time at all and go with datetime.

And since Trac internally uses datetime objects for representing any date/time stamp this looks like the preferable way to me, hence I've done so for the 'sister' plugin, WikiTicketCalendarMacro, in changeset [8356] (consider [8434] for proper behavior with time zones other than GMT as well).

Considering #7564 I'd appreciate, if you could test your issue with the current version of WikiTicketCalendarMacro as well and report back here. Thanks for your patience and for taking care to help us with improvement.

comment:10 Changed 4 years ago by rjollos

  • Owner changed from rjollos to hasienda
  • Status changed from assigned to new

comment:11 Changed 4 years ago by hasienda

  • Status changed from new to assigned

Ping. Michael, would you please test the patch?

Or even better test WikiTicketCalendarMacro in current trunk here with Python time replaced as mentioned before. The WikiCalendarMacro will be integrated there too very soon, so this would help me a lot to get this issue resolved for you and me.

comment:12 Changed 16 months ago by hasienda

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [12842]) WikiCalendarMacro: Releasing current, tested macro package as final product, closes #64, #578, #6636, #7564, #7653, #8818, #9568, #9718 and #9719.

After a long time one of the oldest Trac hacks (see changeset [53]) is united
with its ambitious fork WikiTicketCalendarMacro for convenience.
While maintaining separate wiki pages for both macros, upstream development
continues together in the source:wikicalendarmacro/trunk branch.

Add Comment

Modify Ticket

Action
as closed .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from hasienda. Next status will be 'closed'.
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.