Julian/jsonschema — pull request #7 by mdboom (2012-04-20 19:23:07+00:00)
Title: An initial stab at making jsonschema Python 3.x compatible.

This takes the approach of being Python 2.6, 2.7, 3.1 and 3.2
compatible from an identical code base, i.e. not by requiring an
explicit 2to3 step. With this approach it is almost impossible to
also support Python 2.5, though that can be investigated if that is a
hard requirement.

The testing framework was changed from Twisted.trial to nosetests,
since Twisted does not yet have Python 3.x support. Alternatively,
pytest could be used.

Most changes are related to adding "from __future__ import
unicode_literals" and removing all of the "u" prefixes on string
literals.

Since 3.x drops renames dict.iteritems to dict.items, a function
"iteritems" was added to handle either case.

Likewise, itertools.izip was dropped in favor of just using zip.

Comparisions of strings and numbers no longer works, so the string is
forcibly converted to a float before doing a numeric comparison.

Updated "try .. except" to use the new "Exception as e" syntax.

Python 3 changed the way metaclasses are handled. The metaclass in
tests.py (there are none in the library proper) now uses a crazy
inscrutable syntax that is Python 2.x and 3.x compatible. See
http://mikewatkins.ca/2008/11/29/python-2-and-3-metaclasses/

There is one doctest failing on Python 3.x that fails due to the fact
that in Python 3 the full path to the Exception object is shown in
tracebacks, i.e. jsonschema.ValidationError vs. ValidationError. I'm
not sure how to resolve this in a way that is both Python 2 and 3
compatible. We may just want to skip the doctests on Python 3.