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
This (reduced from real-world code) example fails:
import collections, dill
class A:
class B(collections.namedtuple("B", ["one", "two"])):
pass
a = A()
aa = dill.loads(dill.dumps(a))
Dill thinks B is named A.B, which is not a valid name for a NamedTuple since it has to be a valid identifier, and Python gives ValueError: Type names and field names must be valid identifiers: 'A.B'
Adding the following makes it work again for me at least, but I don't know whether or not the name being wrong should be considered a deeper issue.
In _dill._create_namedtuple:
import collections
name = name.split('.')[-1] #add this line - removes the parent's name, 'A.B' -> 'B'
t = collections.namedtuple(name, fieldnames)
The text was updated successfully, but these errors were encountered:
* fix#288 nested namedtuples
* Remove special case for PyPy 2.7 that doesn't exist
__kwdefaults__ and __annotations__ are invalid in PyPy2.7
* Bug fix for __qualname__ on classes
* Fix bug if _postproc not present and use _setitems
This (reduced from real-world code) example fails:
Dill thinks
B
is namedA.B
, which is not a valid name for a NamedTuple since it has to be a valid identifier, and Python givesValueError: Type names and field names must be valid identifiers: 'A.B'
Adding the following makes it work again for me at least, but I don't know whether or not the name being wrong should be considered a deeper issue.
In _dill._create_namedtuple:
The text was updated successfully, but these errors were encountered: