summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPawel Polewicz <p.polewicz@gmail.com>2016-08-07 00:47:39 +0200
committerPawel Polewicz <p.polewicz@gmail.com>2016-09-27 04:14:43 +0200
commit3181afe358dabe625b484e879132466c9ac385e7 (patch)
tree5cb45324efcf14f0c16f55496078227bcda0484d
parent07e5b4653509d78350ce6dcb5529a6ae1e67d738 (diff)
Restore compatibility with python 2.6
63895ec09d5e28f4c3a308c737503c61e4e3bb43 accidentally broke python 2.6 compatibility due to usage of OrderedDict, which is not available in the collections module in that version. Possible fixes were: 1. Skip defining FrozenOrderedDict when running 2.6 2. Depend on ordereddict module when running 2.6 and import it when needed 3. Copy OrderedDict recipe and use it when needed 4. Do not provide FrozenOrderedDict on 2.6 the last one was chosen due to maintainer preference to keep the code base compact.
-rw-r--r--frozendict/__init__.py13
-rw-r--r--setup.py2
2 files changed, 13 insertions, 2 deletions
diff --git a/frozendict/__init__.py b/frozendict/__init__.py
index 9a63a65..2a6923a 100644
--- a/frozendict/__init__.py
+++ b/frozendict/__init__.py
@@ -1,6 +1,13 @@
import collections
import operator
import functools
+import sys
+
+
+try:
+ from collections import OrderedDict
+except ImportError: # python < 2.7
+ OrderedDict = NotImplemented
class frozendict(collections.Mapping):
@@ -46,4 +53,8 @@ class FrozenOrderedDict(frozendict):
A FrozenDict subclass that maintains key order
"""
- dict_cls = collections.OrderedDict
+ dict_cls = OrderedDict
+
+
+if sys.version >= (2, 7):
+ del FrozenOrderedDict
diff --git a/setup.py b/setup.py
index 8258bf4..31efe0a 100644
--- a/setup.py
+++ b/setup.py
@@ -2,7 +2,7 @@ from setuptools import setup
setup(
name = 'frozendict',
- version = '1.0',
+ version = '1.1',
url = 'https://github.com/slezica/python-frozendict',
author = 'Santiago Lezica',