str(suds.sax.document.Document()) raises exception
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.
Fix:
replace str and plain definitions in suds.sax.
def str(self):
s = []
s.append(
s.append('\n')
root = self.root()
if root is not None:
return ''.join(s)
def plain(self):
s = []
s.append(
root = self.root()
if root is not None:
return ''.join(s)
Affects:
All versions of Ubuntu, all versions of suds
description: | updated |
I did a quick check on with the latest suds package in Ubuntu, and this issue is resolved:
$ python Document( ))
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.
'<?xml version="1.0" encoding="UTF-8"?>'
>>>
Marking Fix Released.