[Open Crypto Project] #56: Trac Internal Error: AttributeError: 'NoneType' object has no attribute 'split'
Open Crypto Project
trac at cryptech.is
Fri May 6 22:44:13 UTC 2016
#56: Trac Internal Error: AttributeError: 'NoneType' object has no attribute
'split'
-----------------------+-----------------
Reporter: pselkirk | Owner:
Type: defect | Status: new
Priority: minor | Milestone:
Component: wiki | Version:
Resolution: | Keywords:
Blocked By: | Blocking:
-----------------------+-----------------
Comment (by sra):
Managed to catch an example of this, with a backtrace:
{{{
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/trac/web/main.py", line
554, in _dispatch_request
dispatcher.dispatch(req)
File "/usr/local/lib/python2.7/site-packages/trac/web/main.py", line
247, in dispatch
resp = chosen_handler.process_request(req)
File "/usr/local/lib/python2.7/site-packages/trac/ticket/web_ui.py",
line 182, in process_request
return self._process_ticket_request(req)
File "/usr/local/lib/python2.7/site-packages/trac/ticket/web_ui.py",
line 625, in _process_ticket_request
self._do_save(req, ticket, action)
File "/usr/local/lib/python2.7/site-packages/trac/ticket/web_ui.py",
line 1357, in _do_save
replyto=req.args.get('replyto'))
File "/usr/local/lib/python2.7/site-packages/trac/ticket/model.py", line
369, in save_changes
listener.ticket_changed(self, comment, author, old_values)
File "/usr/local/lib/python2.7/site-packages/mastertickets/api.py", line
111, in ticket_changed
links.save(author, comment, tkt.time_changed, db)
File "/usr/local/lib/python2.7/site-packages/mastertickets/model.py",
line 67, in save
new_value = [x.strip() for x in old_value.split(',') if x.strip()]
AttributeError: 'NoneType' object has no attribute 'split'
}}}
So patched:
{{{
#!diff
Index: mastertickets/model.py
--- mastertickets/model.py~ 2011-10-19 17:47:42.000000000 +0000
+++ mastertickets/model.py 2016-05-06 22:34:18.000000000 +0000
@@ -63,7 +63,7 @@
if update_field is not None:
cursor.execute('SELECT value FROM ticket_custom WHERE
ticket=%s AND name=%s',
(n, str(field)))
- old_value = (cursor.fetchone() or ('',))[0]
+ old_value = (cursor.fetchone() or ('',))[0] or ''
new_value = [x.strip() for x in old_value.split(',')
if x.strip()]
update_field(new_value)
new_value = ', '.join(sorted(new_value, key=lambda x:
int(x)))
}}}
In English, for those who have not had the misfortune to have memorized
the Python DB2 SQL API, that's "If the SQL column was NULL, give me an
empty string instead of None."
We'll see.
--
Ticket URL: <https://trac.cryptech.is/ticket/56#comment:2>
Open Crypto Project <https://wiki.cryptech.is/>
More information about the Ticket-BCC
mailing list