You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a recent PR #263 the to_serializable function misbehaved and serialized a set of strings into the string "{'pytm/threatlib/threats.json'}".
The issue is caused by the default to_serializable, which is used because there seems to be no rule to serialize the member variable threatsFile of the class TM.
But the potential of @singledispatch is not fully used here since the it is only used in the default variant (seen above) and the two overload variants serialize(obj, nested=True) and serialize(obj, nested=False)
The serialize function is overloaded with special handling of member variables and requires a rewrite.
All the checks seem to be for specific classes which are all handle in the same function.
Also why is there the check for nested?
This is basically equivalent to checking if the class is TM.
In summary we have two types of overloading in the function to_serializable, one via @singledispatch and one via the use of the use of isinstance and the nested parameter in serialize.
I propose to move to just use @singledispatch and move the isinstance functionality of serialize into to_serializable. Maybe remove serialize in the process or at least make it less complex.
In a recent PR #263 the
to_serializable
function misbehaved and serialized a set of strings into the string"{'pytm/threatlib/threats.json'}"
.The issue is caused by the default
to_serializable
, which is used because there seems to be no rule to serialize the member variablethreatsFile
of the classTM
.to_serializable
is a @singledispatch function.pytm/pytm/pytm.py
Lines 1999 to 2002 in 0c8f23c
But the potential of
@singledispatch
is not fully used here since the it is only used in the default variant (seen above) and the two overload variantsserialize(obj, nested=True)
andserialize(obj, nested=False)
pytm/pytm/pytm.py
Lines 2005 to 2016 in 0c8f23c
The reason why the string
"{'pytm/threatlib/threats.json'}"
is created is that the defaultto_serializable
is used.This is just the same as
The issue is created by
pytm/pytm/pytm.py
Line 2007 in 0c8f23c
Because of this check for
not nested
inserialize()
.pytm/pytm/pytm.py
Line 2048 in 0c8f23c
pytm/pytm/pytm.py
Lines 2019 to 2054 in 0c8f23c
The
serialize
function is overloaded with special handling of member variables and requires a rewrite.All the checks seem to be for specific classes which are all handle in the same function.
Also why is there the check for
nested
?This is basically equivalent to checking if the class is
TM
.In summary we have two types of overloading in the function
to_serializable
, one via@singledispatch
and one via the use of the use ofisinstance
and thenested
parameter inserialize
.I propose to move to just use
@singledispatch
and move theisinstance
functionality ofserialize
intoto_serializable
. Maybe removeserialize
in the process or at least make it less complex.The
serialize
function is also used insqlDump
.pytm/pytm/pytm.py
Line 1272 in 0c8f23c
Is is unclear if it can be replaced with
to_serializable
.The text was updated successfully, but these errors were encountered: