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
Currently, if a custom class inherits from tuple and an instance ends up with a _make attribute, munch will call it when the __dict__ attribute is accessed. Unlikely to happen by chance, but munch also inserts itself into SafeLoader, so it should probably err on the defensive side.
The text was updated successfully, but these errors were encountered:
Apparently there's no easy way to detect namedtuples other than existence of these not-quite-magic methods. This feels like a footgun, but I'm not sure how to fix it now.
From https://bugs.python.org/issue7796, it seems that the "easiest" way to check if we're dealing with a namedtuple is to check that the type is tuple and that it has a _fields attribute.
I think these should read namedtuple:
https://github.com/Infinidat/munch/blob/d0aeb06/munch/__init__.py#L461
https://github.com/Infinidat/munch/blob/d0aeb06/munch/__init__.py#L523
Currently, if a custom class inherits from tuple and an instance ends up with a _make attribute, munch will call it when the
__dict__
attribute is accessed. Unlikely to happen by chance, but munch also inserts itself into SafeLoader, so it should probably err on the defensive side.The text was updated successfully, but these errors were encountered: