[issue2551207] Empty order attribute produces traceback in HTMLDatabase.list

Ralf Schlatterbeck <[email protected]> Mon, 30 May 2022 15:57:25 +0000
Newsgroups gmane.comp.bug-tracking.roundup.devel
Message-ID <[email protected]>
New submission from Ralf Schlatterbeck:

When moving an existing tracker to Python3 I'm getting the traceback below from a HTML form.
Turns out the HTMLDatabase.list function tries to sort items (ids) of a class.
If the id is numeric *and* the class has an order attribute that allows NULL values (happens when the class has a explicit order attribute) and we encounter such NULL values (None in python) we compare a string to None which is disallowed in Python3. So the solution is to check for None in the sort-key function.

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/roundup/cgi/client.py", line 1927, in renderContext
    result = pt.render(self, None, None, **args)
  File "/usr/local/lib/python3.9/dist-packages/roundup/cgi/engine_zopetal.py", line 94, in render
    TALInterpreter.TALInterpreter(self._v_program, self.macros,
  File "/usr/local/lib/python3.9/dist-packages/roundup/cgi/TAL/TALInterpreter.py", line 192, in __call__
    self.interpret(self.program)
  File "/usr/local/lib/python3.9/dist-packages/roundup/cgi/TAL/TALInterpreter.py", line 236, in interpret
    handlers[opcode](self, args)
  File "/usr/local/lib/python3.9/dist-packages/roundup/cgi/TAL/TALInterpreter.py", line 680, in do_useMacro
    self.interpret(macro)
  File "/usr/local/lib/python3.9/dist-packages/roundup/cgi/TAL/TALInterpreter.py", line 236, in interpret
    handlers[opcode](self, args)
  File "/usr/local/lib/python3.9/dist-packages/roundup/cgi/TAL/TALInterpreter.py", line 413, in do_optTag_tal
    self.do_optTag(stuff)
  File "/usr/local/lib/python3.9/dist-packages/roundup/cgi/TAL/TALInterpreter.py", line 398, in do_optTag
    return self.no_tag(start, program)
  File "/usr/local/lib/python3.9/dist-packages/roundup/cgi/TAL/TALInterpreter.py", line 392, in no_tag
    self.interpret(program)
  File "/usr/local/lib/python3.9/dist-packages/roundup/cgi/TAL/TALInterpreter.py", line 236, in interpret
    handlers[opcode](self, args)
  File "/usr/local/lib/python3.9/dist-packages/roundup/cgi/TAL/TALInterpreter.py", line 644, in do_condition
    self.interpret(block)
  File "/usr/local/lib/python3.9/dist-packages/roundup/cgi/TAL/TALInterpreter.py", line 236, in interpret
    handlers[opcode](self, args)
  File "/usr/local/lib/python3.9/dist-packages/roundup/cgi/TAL/TALInterpreter.py", line 413, in do_optTag_tal
    self.do_optTag(stuff)
  File "/usr/local/lib/python3.9/dist-packages/roundup/cgi/TAL/TALInterpreter.py", line 398, in do_optTag
    return self.no_tag(start, program)
  File "/usr/local/lib/python3.9/dist-packages/roundup/cgi/TAL/TALInterpreter.py", line 392, in no_tag
    self.interpret(program)
  File "/usr/local/lib/python3.9/dist-packages/roundup/cgi/TAL/TALInterpreter.py", line 236, in interpret
    handlers[opcode](self, args)
  File "/usr/local/lib/python3.9/dist-packages/roundup/cgi/TAL/TALInterpreter.py", line 705, in do_defineSlot
    self.interpret(slot)
  File "/usr/local/lib/python3.9/dist-packages/roundup/cgi/TAL/TALInterpreter.py", line 236, in interpret
    handlers[opcode](self, args)
  File "/usr/local/lib/python3.9/dist-packages/roundup/cgi/TAL/TALInterpreter.py", line 467, in do_setLocal_tal
    self.engine.setLocal(name, self.engine.evaluateValue(expr))
  File "/usr/local/lib/python3.9/dist-packages/roundup/cgi/PageTemplates/TALES.py", line 225, in evaluate
    return expression(self)
  File "/usr/local/lib/python3.9/dist-packages/roundup/cgi/PageTemplates/PythonExpr.py", line 91, in __call__
    return f()
  File "<string>", line 2, in f
  File "/usr/local/lib/python3.9/dist-packages/roundup/cgi/templating.py", line 791, in list
    l.sort(key=keyfunc)
TypeError: '<' not supported between instances of 'NoneType' and 'str'

----------
assignee: schlatterbeck
components: Web interface
keywords: python3
messages: 7538
nosy: rouilj, schlatterbeck
priority: normal
severity: normal
status: new
title: Empty order attribute produces traceback in HTMLDatabase.list
type: crash
versions: devel

_________________________________________________
Roundup tracker <[email protected]>
<https://issues.roundup-tracker.org/issue2551207>
_________________________________________________