Modify

Opened 4 years ago

Closed 20 months ago

#13463 closed defect (fixed)

TypeError: object of type 'NoneType' has no len()

Reported by: Rochi Owned by: Ryan J Ollos
Priority: normal Component: TracJsGanttPlugin
Severity: normal Keywords: patch
Cc: Trac Release: 1.2

Description

Using: Trac 1.2.3 Trac_jsGantt-1.2.0.0.dev0

Error was:

2018-07-30 16:45:48,869 Trac[formatter] ERROR: Macro TracJSGanttChart(milestone=Organisatorisches,display=status:new|status:assigned|status:accepted,res=0,startDate=0) failed for
<Resource u'wiki:WikiStart'>:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/Trac-1.2.3-py2.7.egg/trac/wiki/formatter.py", line 822, in _macro_formatter
    return macro.ensure_inline(macro.process(args), in_paragraph)
  File "/usr/local/lib/python2.7/dist-packages/Trac-1.2.3-py2.7.egg/trac/wiki/formatter.py", line 396, in process
    text = self.processor(text)
  File "/usr/local/lib/python2.7/dist-packages/Trac-1.2.3-py2.7.egg/trac/wiki/formatter.py", line 368, in _macro_processor
    text)
  File "/usr/local/lib/python2.7/dist-packages/Trac_jsGantt-1.2.0.0.dev0-py2.7.egg/tracjsgantt/tracjsgantt.py", line 751, in expand_macro
    tasks = self._add_tasks(options)
  File "/usr/local/lib/python2.7/dist-packages/Trac_jsGantt-1.2.0.0.dev0-py2.7.egg/tracjsgantt/tracjsgantt.py", line 692, in _add_tasks
    self.pm.computeSchedule(options, self.tickets)
  File "/usr/local/lib/python2.7/dist-packages/Trac_jsGantt-1.2.0.0.dev0-py2.7.egg/tracjsgantt/tracpm.py", line 1250, in computeSchedule
    self.scheduler.scheduleTasks(options, ticketsByID)
  File "/usr/local/lib/python2.7/dist-packages/Trac_jsGantt-1.2.0.0.dev0-py2.7.egg/tracjsgantt/tracpm.py", line 2238, in scheduleTasks
    serialSGS(_schedule_task_alap, 'nsucc', -1, self.pm.predecessors)
  File "/usr/local/lib/python2.7/dist-packages/Trac_jsGantt-1.2.0.0.dev0-py2.7.egg/tracjsgantt/tracpm.py", line 2194, in serialSGS
    scheduleFunction(ticket)
  File "/usr/local/lib/python2.7/dist-packages/Trac_jsGantt-1.2.0.0.dev0-py2.7.egg/tracjsgantt/tracpm.py", line 2022, in _schedule_task_alap
    _compare_alap_limits, _wrap_alap_day)
  File "/usr/local/lib/python2.7/dist-packages/Trac_jsGantt-1.2.0.0.dev0-py2.7.egg/tracjsgantt/tracpm.py", line 1786, in _schedule_task
    elif self.pm.isSet(t, fromField):
  File "/usr/local/lib/python2.7/dist-packages/Trac_jsGantt-1.2.0.0.dev0-py2.7.egg/tracjsgantt/tracpm.py", line 343, in isSet
    len(ticket[self.fields[field]]) != 0:
TypeError: object of type 'NoneType' has no len()

Fixed it with:

# Return True if ticket has a non-empty value for field, False
    # otherwise.
    def isSet(self, ticket, field):
        if self.isCfg(field) and \
                isinstance(ticket[self.fields[field]], datetime) and \
                len(str(ticket[self.fields[field]])) != 0:
            return True
        elif self.isCfg(field) and \
                ticket[self.fields[field]] is not None and \
                len(ticket[self.fields[field]]) != 0:
            return True
        else:
            return False

Attachments (0)

Change History (8)

comment:1 Changed 4 years ago by figaro

Keywords: patch added

comment:2 Changed 4 years ago by Ryan J Ollos

Resolution: fixed
Status: newclosed

In 17250:

Trac-jsGantt 1.2.0.0dev: Fix exception when ticket field is None

Patch by Rochi.

Fixes #13463.

comment:3 Changed 4 years ago by Ryan J Ollos

Owner: changed from Chris Nelson to Rochi

comment:4 Changed 2 years ago by anonymous

FYI, got that error again (TRAC 1.2.3 + Trac-jsGantt 1.2.0.0.dev0), having cutom-fields

userfinish = time
userfinish.format = time
userfinish.label = Due DateTime
userfinish.order = 18
userfinish.value =
userstart = time
userstart.format = time
userstart.label = Start DateTime
userstart.order = 17
userstart.value =

then leaving either userstart or userfinish unset. The following mod of isSet() WFM

    def isSet(self, ticket, field):
        if self.isCfg(field) and ticket[self.fields[field]] is not None:
            if len(str(ticket[self.fields[field]])) != 0:
                return True
            else:
                return False
        else:
            return False

comment:5 Changed 2 years ago by Ryan J Ollos

How about this?

  • tracjsgantt/tracpm.py

     
    336336    # Return True if ticket has a non-empty value for field, False
    337337    # otherwise.
    338338    def isSet(self, ticket, field):
    339         if self.isCfg(field) and \
    340                 isinstance(ticket[self.fields[field]], datetime) and \
    341                 ticket[self.fields[field]] is not None and \
    342                 len(str(ticket[self.fields[field]])) != 0:
    343             return True
    344         elif self.isCfg(field) and \
    345                 len(ticket[self.fields[field]]) != 0:
    346             return True
    347         else:
    348             return False
     339        return bool(self.isCfg(field) and ticket.get(self.fields[field]))
    349340
    350341    # FIXME - Many of these should be marked as more private.  Perhaps
    351342    # an leading underscore?
Last edited 2 years ago by Ryan J Ollos (previous) (diff)

comment:6 Changed 2 years ago by Ryan J Ollos

Resolution: fixed
Status: closedreopened

comment:7 Changed 2 years ago by Ryan J Ollos

Owner: changed from Rochi to Ryan J Ollos
Status: reopenedaccepted

comment:8 Changed 20 months ago by Ryan J Ollos

Resolution: fixed
Status: acceptedclosed

Accidentally committed the comment:5 change in r17888.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
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.