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
The update_function in the autoreload module tries to copy the __closure__ attribute from the new version of the function to the old one (presumably for reloading decorated functions).
However, __closure__ is a read-only attribute, so the copy never actually takes place. The error is caught and ignored.
This may be the cause of the long-standing issue "autoreload does not work with decorators": link and link.
The fix should be quite simple.
old_closure, new_closure=old.__closure__, new.__closure__iflen(old_closure) !=len(new_closure):
# may need more check for variable namesreturnforo, ninzip(old_closure, new_closure):
o.cell_contents=n.cell_contents
Have I just found a 16-year-old bug? : )
The text was updated successfully, but these errors were encountered:
Yes.
I did the tests. The DeduperReloader implementation correctly updates closure attribute.
But as I understand, there will be two modes of reloading: the new DeduperReloader and the old one ?
If that is the case, the old one still needs to be fixed
That's correct that deduperreload could fall back to the original algorithm if it can't isolate module changes to individual functions.
The fix should be quite simple.
Unfortunately the proposed fix only works if the old and new closures have the same length. Deduperreload works around this by doing some magic to patch the readonly __closure__ attribute at the level of the C struct; we could potentially do the same thing in the original autoreload algorithm as well.
Have I just found a 16-year-old bug? : )
It's hard to say whether it's a bug or a limitation -- I think autoreload is one of those "best-effort" things and it's pretty easy to hit a case with undefined behavior.
The update_function in the
autoreload
module tries to copy the__closure__
attribute from the new version of the function to the old one (presumably for reloading decorated functions).However,
__closure__
is a read-only attribute, so the copy never actually takes place. The error is caught and ignored.This may be the cause of the long-standing issue "autoreload does not work with decorators": link and link.
The fix should be quite simple.
Have I just found a 16-year-old bug? : )
The text was updated successfully, but these errors were encountered: