quandyfactory/dicttoxml

use of mutable object in python signatures

ooldham opened this issue · 2 comments

Examining v1.6.6 - I see 3 methods with mutable object in signature.
This is never a good idea.

def convert_kv(key, val, attr_type, attr={}):
def convert_bool(key, val, attr_type, attr={}):
def convert_none(key, val, attr_type, attr={}):

These should be changed to:
def convert_kv(key, val, attr_type, attr=None):
def convert_bool(key, val, attr_type, attr=None):
def convert_none(key, val, attr_type, attr=None):

And the following - or something similar, inserted after each LOG statement found in each method.

    attr = dict() if attr is None else attr
    if not isinstance(attr, dict):
        raise TypeError("Unexpected type: attr={a}, type={t} vs dict".format(a=attr, t=type(attr).__name__))

This will be fixed in v1.7.15.

I have resolved this in version 1.7.15.