[PATCH] morph2: Improve compatibility with python < 2.7
richard.maw at codethink.co.uk
Fri Jan 18 17:08:50 GMT 2013
On Fri, Jan 18, 2013 at 05:03:26PM +0000, Richard Maw wrote:
> On Fri, Jan 18, 2013 at 11:30:33AM +0000, Javier Jardón wrote:
> > ---
> > morphlib/morph2.py | 29 +++++++++--------------------
> > 1 file changed, 9 insertions(+), 20 deletions(-)
> > diff --git a/morphlib/morph2.py b/morphlib/morph2.py
> > index 73d55d1..6af9e9e 100644
> > --- a/morphlib/morph2.py
> > +++ b/morphlib/morph2.py
> > @@ -14,16 +14,16 @@
> > +try:
> > + from collections import OrderedDict
> > + import json
> > +except ImportError: # pragma: no cover
> > + from ordereddict import OrderedDict
> > + import simplejson as json
> > +
> This implies that if your collections module doesn't have OrderedDict
> then you also don't have json with object_pairs_hook.
> I can't decide if this is elegant or incomplete.
> I'll have to check what simplejson has before I can merge this.
Yeah, that is pretty elegant, since OrderedDict is missing before 2.7,
so json would also be missing the required hook, but simplejson does and
the backported OrderedDict works.
I'll merge and add a comment.
More information about the baserock-dev