diff options
author | Alexander Shorin <kxepal@gmail.com> | 2012-09-12 08:41:10 +0400 |
---|---|---|
committer | Alexander Shorin <kxepal@gmail.com> | 2012-09-12 08:41:10 +0400 |
commit | 43234d598d1d72faf0bd266cf2422f0c948e6384 (patch) | |
tree | a25d6b76fae61d9e6847995d040855a6258de5cb /jsonpointer.py | |
parent | aef6313b049b08f08dd48eb6173fcb1eb63f8bcf (diff) | |
download | python-json-pointer-43234d598d1d72faf0bd266cf2422f0c948e6384.tar.gz |
Fix compatibility with Python 3.x.
Diffstat (limited to 'jsonpointer.py')
-rw-r--r-- | jsonpointer.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/jsonpointer.py b/jsonpointer.py index 06b9869..58cbdbb 100644 --- a/jsonpointer.py +++ b/jsonpointer.py @@ -40,8 +40,14 @@ __website__ = 'https://github.com/stefankoegl/python-json-pointer' __license__ = 'Modified BSD License' -import urllib -from itertools import tee, izip +try: + from urllib import unquote + from itertools import izip +except ImportError: # Python 3 + from urllib.parse import unquote + izip = zip + +from itertools import tee class JsonPointerException(Exception): @@ -121,7 +127,7 @@ class JsonPointer(object): if parts.pop(0) != '': raise JsonPointerException('location must starts with /') - parts = map(urllib.unquote, parts) + parts = map(unquote, parts) parts = [part.replace('~1', '/') for part in parts] parts = [part.replace('~0', '~') for part in parts] self.parts = parts |