Warning: don't refresh MonkeyPatches
Posting this on the off chance that it saves someone the week of hair-tearing that I've just experienced... I sometimes find MonkeyPatches a convenient way to globally change behavior of zope or 3rd-party products. But I just discovered something very important: it's apparently NOT safe to "refresh" a MonkeyPatch-style product. I have a monkeypatch that works fine until I refresh it, then I get mysterious errors like "Object of type 'None' is not callable" with no indication in the traceback of what object is None or even what's trying to call it! In a debugging session, I explored everything near the end of the traceback and could not find any variables that are None. I know it's in there somewhere... If I restart zope, everything works fine. -- Paul Winkler http://www.slinkp.com Look! Up in the sky! It's THE BAT-FLAGELLA! (random hero from isometric.spaceninja.com)
As an extra precaution you could explicitly disallow a refresh by setting __refresh_module__ = 0 in your monkey patch module. Stefan --On Freitag, 21. März 2003 12:47 -0500 Paul Winkler <pw_lists@slinkp.com> wrote:
Posting this on the off chance that it saves someone the week of hair-tearing that I've just experienced...
I sometimes find MonkeyPatches a convenient way to globally change behavior of zope or 3rd-party products. But I just discovered something very important:
it's apparently NOT safe to "refresh" a MonkeyPatch-style product.
I have a monkeypatch that works fine until I refresh it, then I get mysterious errors like "Object of type 'None' is not callable" with no indication in the traceback of what object is None or even what's trying to call it! In a debugging session, I explored everything near the end of the traceback and could not find any variables that are None. I know it's in there somewhere...
If I restart zope, everything works fine.
-- Those who write software only for pay should go hurt some other field. /Erik Naggum/
Paul Winkler wrote at 2003-3-21 12:47 -0500:
Posting this on the off chance that it saves someone the week of hair-tearing that I've just experienced...
I sometimes find MonkeyPatches a convenient way to globally change behavior of zope or 3rd-party products. But I just discovered something very important:
it's apparently NOT safe to "refresh" a MonkeyPatch-style product.
I have a monkeypatch that works fine until I refresh it, then I get mysterious errors like "Object of type 'None' is not callable" with no indication in the traceback of what object is None or even what's trying to call it! In a debugging session, I explored everything near the end of the traceback and could not find any variables that are None. I know it's in there somewhere...
This is not a problem of monkey patching, but of refreshing in general. Search the mailing list archives: Shane explains in some message why it happens and how to avoid it. Dieter
On Sat, Mar 22, 2003 at 10:24:00PM +0100, Dieter Maurer wrote:
This is not a problem of monkey patching, but of refreshing in general.
Interesting! Thanks Dieter. I assumed it was due to it being a monkey-patch because I'd never seen this problem with refreshing any other product I've developed.
Search the mailing list archives: Shane explains in some message why it happens and how to avoid it.
Cool, thanks. -- Paul Winkler http://www.slinkp.com Look! Up in the sky! It's THE SOCK! (random hero from isometric.spaceninja.com)
participants (3)
-
Dieter Maurer -
Paul Winkler -
Stefan H. Holek