Skip to content

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

@aarcro

Description

@aarcro

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'))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions