[Zope-dev] [zope.testing.doctest] a nasty surprise

Dieter Maurer dieter at handshake.de
Thu Apr 10 15:57:26 EDT 2008


Marius Gedminas wrote at 2008-4-10 22:37 +0300:
> ...
>doctest monkey-patches pdb.set_trace (in an ugly way, IMHO) to restore
>sys.stdout, because you want the output from pdb commands like 'list' or
>'print' to go to your console, and not to the doctest's actual result
>StringIO collector.
>
>> Apparently, "doctest" has replaced my "set_trace" in "zpdb"
>> by its non working implementation of "set_trace".
>
>I find it hard to believe.  It's more likely that zpdb is interacting
>with pdb.set_trace in a way that conflicts with doctest's monkey-patch.
>
>Is the zdpb module available on the web somewhere?

"dm.pdb" is on "PyPI".

And your intuition is right.
"zpdb" rebinds "pdb.set_trace" overriding the name "Pdb".


Now, I also understand how the "TypeError" results:

   "doctest" has replaced the function "set_trace" by an instance method.
   Rebinding unwraps the "InstanceMethod" and operates only on
   the enclosed function -- the implicit instance argument is lost.



-- 
Dieter


More information about the Zope-Dev mailing list