Code

Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#207 closed defect (fixed)

TimeFormat seconds function has unused second argument (w/ patch)

Reported by: Mathieu Fenniak <mfenniak@…> Owned by: adrian
Component: Template system Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

When using a time format with the 's' format string, which should be the time's seconds with leading zeros, the following error occurs:

  File "/usr/lib/python2.3/site-packages/django/core/defaultfilters.py", line 329, in time
    return time_format(value, arg)

  File "/usr/lib/python2.3/site-packages/django/utils/dateformat.py", line 317, in time_format
    return tf.format(format_string)

  File "/usr/lib/python2.3/site-packages/django/utils/dateformat.py", line 304, in format
    result += str(getattr(self, char)())

TypeError: s() takes exactly 2 arguments (1 given)

It seems that the TimeFormat's s function has an unnecessary and harmful second argument that is never used. This simple patch addresses the problem:

Index: django/utils/dateformat.py
===================================================================
--- django/utils/dateformat.py  (revision 312)
+++ django/utils/dateformat.py  (working copy)
@@ -293,7 +293,7 @@
             return 'noon'
         return '%s %s' % (self.f(), self.a())
 
-    def s(self, s):
+    def s(self):
         "Seconds; i.e. '00' to '59'"
         return '%02d' % self.time.second

Attachments (0)

Change History (1)

comment:1 Changed 9 years ago by jacob

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

(In [313]) Fixed #207 -- thanks, Mathieu.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


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

 
Note: See TracTickets for help on using tickets.