Julian/jsonschema — pull request #154 by mdboom (2014-04-02 14:08:15+00:00)
Title: Fixes #126: generator objects leak on Python 3

The issue here is that generator objects that don't run to completion are uncollectable. There are a few places where `iter_errors` is called simply to retrieve the first error, and thus `iter_errors` is left uncompleted and holding references to a bunch of things (including `self`, which prevents deletion of the `iter_errors` generator instance).

The fix here isn't terribly elegant: It adds a kwarg to `iter_errors` to yield only the first error. Then, this is used from the places that only want the first error (along with `list` to fully exhaust the generator). The alternative (to just use `list`) would mean the possibly expensive creation of many error results only to have them immediately ignored and thrown away -- less efficient, but a simpler/less hackish solution perhaps.

Lastly, I couldn't figure out how to write a test for this: except perhaps to do:

```
warnings.filterwarnings("error", ".*", ResourceWarning)
```

which would raise an exception at the end of the test run rather than just a warning.