[PEAK] setuptools: Test works only after second invocation
P.J. Eby
pje at telecommunity.com
Thu Apr 29 14:36:52 EDT 2010
At 12:34 PM 4/29/2010 -0400, Nikolaus Rath wrote:
>Is setuptools by any chance doing more of this kind of black magic?
Sure, lots. ;-)
>I'm about to start debugging a second, even more mysterious looking
>problem when running the test command. If it is used in combination
>with Psyco, I get exceptions after all the tests have completed:
These exceptions are happening at Python shutdown. You can tell by this bit:
> return embedframe(_psyco.getframe(depth+1))
>AttributeError: 'NoneType' object has no attribute 'getframe'
_psyco is obviously 'None' here -- which would only happen during the
Python shutdown phase where the interpreter sets *all* module globals
to None. So the problem is that your excepthook implementation is
running during that phase. It probably doesn't have anything to do
with setuptools, but you'll need to change your code to work
correctly at shutdown time in order to find out what the real error(s) are.
>Is there also an ez_setup.py available that downloads this (or any
>newer release) automatically?
Not at the moment. (Of course, as you pointed out, the second and
subsequent run of tests work fine.)
> I don't want to require people to first manually upgrade setuptools..
>
>Or is it possible to work around this problem somehow? Is the
>original file class backed up somewhere, so that I can refer to the backup?
You can use this to monkeypatch the problem:
if file is setuptools.sandbox._open:
file = setuptools.sandbox._file
It won't break out of the sandbox if you're in the sandbox, but it'll
fix the problem if it's current.
Unfortunately, one thing that your code has shown is that you can't
subclass 'file' while the sandbox is active, and if you manage to
subclass 'file' before the sandbox is activated, you'll be able to
bypass it. That's a little troubling for the strength of the
sandbox, so in future versions I should probably do a subclass check
and issue warnings for unexpected file subclasses when the sandbox is
started running.
More information about the PEAK
mailing list