str(suds.sax.document.Document()) raises exception

Bug #1200269 reported by dick.fickling
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
suds (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

If the Document object is created without a root element, its overridden version of __str__ throws an exception.

I encountered this bug with an interaction between the django debug toolbar and suds. In suds's suds.mx.core.append method, log.debug() can be called with a Document that has no children. Django's debug toolbar calls str() on the arguments to debug(), which causes the exception to be raised.

Reproduce:
import suds
str(suds.sax.document.Document())

Fix:
replace str and plain definitions in suds.sax.document.Document with the code below:
def str(self):
    s = []
    s.append(self.DECL)
    s.append('\n')
    root = self.root()
    if root is not None:
        s.append(root.str())
    return ''.join(s)

def plain(self):
    s = []
    s.append(self.DECL)
    root = self.root()
    if root is not None:
        s.append(root.plain())
    return ''.join(s)

Affects:
All versions of Ubuntu, all versions of suds

description: updated
Revision history for this message
James Page (james-page) wrote :

I did a quick check on with the latest suds package in Ubuntu, and this issue is resolved:

$ python
Python 2.7.14 (default, Sep 23 2017, 22:06:14)
[GCC 7.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from suds.sax import document
>>> str(document.Document())
'<?xml version="1.0" encoding="UTF-8"?>'
>>>

Marking Fix Released.

Changed in suds (Ubuntu):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.