Commit Graph

14 Commits

Author SHA1 Message Date
Tim Peters fee69d0313 Changed some comments. Removed the caution about clearing globs, since
clearing a shallow copy _run_examples() makes itself can't hurt anything.
2001-06-24 20:24:16 +00:00
Tim Peters d4ad59e1eb Clear the copy of the globs dict after running examples. This helps to
break cycles, which are a special problem when running generator tests
that provoke exceptions by invoking the .next() method of a named
generator-iterator:  then the iterator is named in globs, and the
iterator's frame gets a tracekback object pointing back to globs, and
gc doesn't chase these types so the cycle leaks.

Also changed _run_examples() to make a copy of globs itself, so its
callers (direct and indirect) don't have to (and changed the callers
to stop making their own copies); *that* much is a change I've been
meaning to make for a long time (it's more robust the new way).

Here's a way to provoke the symptom without doctest; it leaks at a
prodigious rate; if the last two "source" lines are replaced with
    g().next()
the iterator isn't named and then there's no leak:

source = """\
def g():
    yield 1/0

k = g()
k.next()
"""

code = compile(source, "<source>", "exec")

def f(globs):
    try:
        exec code in globs
    except ZeroDivisionError:
        pass

while 1:
    f(globals().copy())

After this change, running test_generators in an infinite loop still leaks,
but reduced from a flood to a trickle.
2001-06-24 20:02:47 +00:00
Tim Peters 77f2d504c3 doctest systematically leaked memory when handling an exception in an
example (an obvious trackback cycle).  Repaired.
Bugfix candidate.
2001-06-24 18:59:01 +00:00
Tim Peters 08bba953ea doctest doesn't handle intentional SyntaxError exceptions gracefully,
because it picks up the first line of traceback.format_exception_only()
instead of the last line.  Pick up the last line instead!
2001-06-24 06:46:58 +00:00
Tim Peters 24a4191160 Changed doctest to run tests in alphabetic order of name.
This makes verbose-mode output easier to dig thru, and removes an accidental
dependence on the order of dict.items() (made visible by recent changes to
dictobject.c).
2001-03-21 23:07:59 +00:00
Guido van Rossum 261d91a3f9 Make doctest's self-test succeed after the previous change. 2001-03-18 17:05:58 +00:00
Guido van Rossum af00a46599 Print a bunch of asterisks before the failure summary, to separate it
from the last failure report.
2001-03-18 16:58:44 +00:00
Tim Peters f9bb4969af Miranda newlines: if anything at all was written to stdout, supply a
newline at the end if there isn't one already.  Expected output has no
way to indicate that a trailing newline was not expected, and in the
interpreter shell *Python* supplies the trailing newline before printing
the next prompt.
2001-02-14 06:35:35 +00:00
Tim Peters 60e23f4cfc Change doctest exception example to one whose detail hasn't changed since 1.5.2. 2001-02-14 00:43:21 +00:00
Tim Peters ea4f931cb9 Teach doctest about newer "(most recent call last)" traceback spelling. 2001-02-13 20:54:42 +00:00
Tim Peters ecb6fb95a2 Bump __version__ tuple. 2001-02-10 01:24:50 +00:00
Eric S. Raymond 630e69cd89 String method conversion. 2001-02-09 08:33:43 +00:00
Skip Montanaro eccd02a40d more __all__ updates 2001-01-20 23:34:12 +00:00
Tim Peters 8a7d2d5cb1 doctest-- The Little Module That Could --finally makes it to the Big Show <wink>. 2001-01-16 07:10:57 +00:00