[z3-five] pythonproducts monkey patches

Philipp von Weitershausen philipp at weitershausen.de
Thu Jul 20 01:07:12 CEST 2006


yuppie wrote:
> I'm not sure which collector to use for Five issues so I decided to 
> report this to the list:

Yeah, thanks.

> The monkey patching code used in Five 1.4 is not very robust.

We accept patches :). Seriously, we do, though this is Rocky's code so I
hope he'll have something to say about this.

> If 
> setupPythonProducts is called twice _originalGetPath is set twice - the 
> second time with the patched getPath. This leads to an infinite 
> recursion because the patched getPath calls _originalGetPath.

This seems easy enough to reproduce in a test...

> The unit tests actually depend on the fact that test_externalmethods is 
> usually run before test_registerPackage. If you change their order 
> (AFAICS they are run in alphabetical order) you can see the problem.

No idea in what order tests are run. I think it might also change with
the endinanness of your platform, the size of your screen and the colour
of your underpants.

> I stumbled over this issue because I did run the Five tests together 
> with tests that initialize Five.

Well, you're actually not supposed to do that. Five tests will clean up
after them nicely. Stuff that does installProduct('Five') will not.
These two collide.

The monkey patches, when tested, should clean up after themselves. ALL
code that operates on global registries or does monkey patching should
clean up after itself. If pythonproducts doesn't do that, it's a bug.

(Note that zope.testing has a very nice hook for providing cleanup
functions. We use this in various places in Five.)

Philipp



More information about the z3-five mailing list