splunk-sdk-python icon indicating copy to clipboard operation
splunk-sdk-python copied to clipboard

Empty text node raises 'NoneType' object has no attribute 'encode'

Open aarcro opened this issue 13 years ago • 2 comments

In splunklib/results.py at line 257 values.append(elem.text.encode('utf8')) can raise an AttributeError for encode.

If the xml looks like:

<field k='named_field'>
    <value><text></text></value>
</field>

elem.text will be the None object, not an empty string as one might expect. I've used this instead:

t = elem.text
if not t:
    t = ''
 values.append(t.encode('utf8'))

aarcro avatar Aug 27 '13 19:08 aarcro

champ fix. thanks for this

TheCase avatar Mar 07 '14 18:03 TheCase

Great @aarcro. Can you send us a pull request?

glennblock avatar Mar 07 '14 18:03 glennblock