Opened 8 years ago

Closed 8 years ago

#761 closed defect (fixed)

[Python 2.6] OrderedDict ImportError

Reported by: rsd Owned by:
Priority: major Milestone:
Component: programming Keywords: ordereddict python2.6
Cc: cwebber@… Parent Tickets:

Description

When using Python 2.6, the ./bin/gmg dbupdate command throws an ImportError[1].

The source of error is in the mediagoblin/processing/__init__.py file, which imports 'OrderedDict' from 'collections'[2].

Fortunately, we've ordereddict[3]. When I imported 'OrderedDict' from this module. Bingo, it worked[4].

A possible fix for this bug would be to first test whether importing OrderedDict from 'collections' doesn't throw an ImportError, if it does (meaning the user has Python 2.6), import OrderedDict from 'ordereddict'.

[1]: http://pastebin.com/c06J5H7j
[2]: In Python 2.6, there is no OrderedDict in 'collections'.
[3]: https://pypi.python.org/pypi/ordereddict
[4]: here is the diff http://pastebin.com/VYtQFW3a

Subtickets

Change History (7)

comment:1 Changed 8 years ago by rsd

Keywords: python2.6 added

comment:2 in reply to:  description Changed 8 years ago by rsd

Replying to rsd:

A possible fix for this bug would be to first test whether importing OrderedDict from 'collections' doesn't throw an ImportError, if it does (meaning the user has Python 2.6), import OrderedDict from 'ordereddict'.

I've attached a patch, which fixes this issue.

Thanks.

comment:3 Changed 8 years ago by rodney757

Status: newreview

comment:4 Changed 8 years ago by rsd

The previous patch, I submitted is not clean as it (inadvertently) removes a period (`.') from the license block.

I've made a fresh patch, which is based on the latest commit (at the time of this comment); 6375cf735c.

This new patch is the second attachment in this ticket.


comment:5 Changed 8 years ago by Christopher Allan Webber

Resolution: fixed
Status: reviewclosed

Thanks for reporting this. Should have caught it before we went live with this release... erk ;|

Anyway, fixed in master, but not by providing the optional ordereddict module... really, we actually do not need OrderedDict necessarily, it just provides some nice, but not critical, ordering when displaying options on the command line. I updated git master so that when not OrderedDict is not supported that it uses a normal dict. I consider that a sufficient fix that doesn't add another dependency for 2.6.

Note: See TracTickets for help on using tickets.