Modify

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#6054 closed defect (fixed)

[0.12][PATCH] cannot marshal <class 'trac.util.text.Empty'> objects

Reported by: scratcher Owned by: osimons
Priority: normal Component: XmlRpcPlugin
Severity: blocker Keywords: patch
Cc: Trac Release: 0.12

Description (last modified by stp)

NULL values in database (sqlite) cause error in XmlRpcPlugin:

2009-10-28 11:47:15,809 Trac[web_ui] ERROR: cannot marshal <class 'trac.util.text.Empty'> objects
2009-10-28 11:47:15,809 Trac[web_ui] ERROR: Traceback (most recent call last):
  File "build\bdist.win32\egg\tracrpc\web_ui.py", line 185, in process_xml_request
    self._send_response(req, xmlrpclib.dumps(result, methodresponse=True), content_type)
  File "C:\Python25\lib\xmlrpclib.py", line 1080, in dumps
    data = m.dumps(params)
  File "C:\Python25\lib\xmlrpclib.py", line 623, in dumps
    dump(v, write)
  File "C:\Python25\lib\xmlrpclib.py", line 635, in __dump
    f(self, value, write)
  File "C:\Python25\lib\xmlrpclib.py", line 695, in dump_array
    dump(v, write)
  File "C:\Python25\lib\xmlrpclib.py", line 635, in __dump
    f(self, value, write)
  File "C:\Python25\lib\xmlrpclib.py", line 716, in dump_struct
    dump(v, write)
  File "C:\Python25\lib\xmlrpclib.py", line 633, in __dump
    raise TypeError, "cannot marshal %s objects" % type(value)
TypeError: cannot marshal <class 'trac.util.text.Empty'> objects

The reason is that NULL values now returned as trac.util.text.Empty object, not None. Attached patch solves the problem.

Attachments (1)

empty_values.patch (921 bytes) - added by scratcher 5 years ago.
patch to deal with trac.util.text.Empty objects

Download all attachments as: .zip

Change History (6)

Changed 5 years ago by scratcher

patch to deal with trac.util.text.Empty objects

comment:1 Changed 5 years ago by stp

  • Description modified (diff)

comment:2 Changed 5 years ago by osimons

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

(In [7167]) XmlRpcPlugin: Compat code to handle Trac 0.12 Empty objects as None type. Closes #6054.

comment:3 Changed 5 years ago by cboos

  • Resolution fixed deleted
  • Status changed from closed to reopened

Actually, the empty "constant" should be used instead of the Empty class.

Initially Remy made that class hidden, I changed that as I needed to access it from the db layer, but now that I see it's getting used, I should probably remove it again and find another way to access that from the db layer (type(empty)?).

So the fix should rather be something like:

    ...
elif res is None or res is empty:
    ...

comment:4 Changed 5 years ago by osimons

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

(In [7194]) XmlRpcPlugin: 0.12dev compat code revisited - use empty (constant) instead of Empty (class) according to Christian. Closes #6054 again.

comment:5 Changed 5 years ago by cboos

Thanks for the modification, I now made Empty hidden again in [T8860].

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 osimons. 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.