-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hash get_object_state, use dir for native types, fix __slots__ #208
Conversation
I'm running apptek_asr CI w/ the latest commit here to see if AppTek was affected by the bug. |
Btw, I just noticed, our -> @curufinwe said separate PR. |
So, it seems like w/ the new implementation
New sis gives:
The reason for this is that if you instantiate a
Notice the empty slots. Before this PR, sisyphus would therefore not take into account any properties for the hash. All in all the previous behavior was extremely broken, so I think we should merge this as-is and accept the breakage. |
Ah,
__slots__ = (
'_drv', '_root', '_parts',
'_str', '_hash', '_pparts', '_cached_cparts',
) Btw, also please say what Python version you used. For the new code, the Python version should not make a difference (well, despite if the object changed its internal representation - that might also be the case for In any case, maybe it makes sense to treat Also, I wonder, is that correct that you have |
In general, yes. A sisyphus Path would be preferable, but we should make sure that sisyphus also works correctly with PosixPath. I would not mind handling it separately, but then we should do it in this PR to avoid having another commit than changes hashes. |
The python version was 3.10 in the case in question. |
Ok, I added special case for |
Fix #207
See #207 for some discussion.
Note that this slightly changes the behavior, but only for cases which were basically broken before.
E.g., for
functools.partial
, before this change, none of the relevant args (func
,args
,keywords
) were ever part of the hash. So this change should not really break anything.The same is also true for cases where there was both a
__dict__
and__slots__
. With Python <=3.10, it would have used only the__dict__
, and very likely, that was just empty, and does not contain any of the relevant things (which are very likely all in the__slots__
), so it was totally broken and basically unusable. With Python >=3.11, there is a default__getstate__
now, which would already do the correct thing, at least for "normal" (non-native) types, i.e. merge__dict__
and__slots__
, i.e. our existingget_object_state
was correct for those cases. With this change, Python <=3.10 is also correct now.In any case, we check through
dir
now, and we check for member descriptors, which should also cover such native types (likefunctools.partial
).