Skip to content

Commit 0c27603

Browse files
Rémy HUBSCHERdjc
authored andcommitted
Fix the python3 tests.
1 parent 4473b09 commit 0c27603

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

couchdb/json.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,12 @@ def _init_cjson():
125125
def _init_stdlib():
126126
global _decode, _encode
127127
json = __import__('json', {}, {})
128-
_decode = lambda string, loads=json.loads: loads(string)
128+
129+
def _decode(string_, loads=json.loads):
130+
if isinstance(string_, util.btype):
131+
string_ = string_.decode("utf-8")
132+
return loads(string_)
133+
129134
_encode = lambda obj, dumps=json.dumps: \
130135
dumps(obj, allow_nan=False, ensure_ascii=False)
131136

couchdb/util2.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11

22
__all__ = [
33
'StringIO', 'urlsplit', 'urlunsplit', 'urlquote', 'urlunquote',
4-
'urlencode', 'utype', 'ltype', 'strbase', 'funcode', 'urlparse',
4+
'urlencode', 'utype', 'btype', 'ltype', 'strbase', 'funcode', 'urlparse',
55
]
66

77
utype = unicode
8+
btype = str
89
ltype = long
910
strbase = str, bytes, unicode
1011

@@ -14,5 +15,6 @@
1415
from urllib import unquote as urlunquote
1516
from urllib import urlencode
1617

18+
1719
def funcode(fun):
1820
return fun.func_code

couchdb/util3.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11

22
__all__ = [
33
'StringIO', 'urlsplit', 'urlunsplit', 'urlquote', 'urlunquote',
4-
'urlencode', 'utype', 'ltype', 'strbase', 'funcode', 'urlparse',
4+
'urlencode', 'utype', 'btype', 'ltype', 'strbase', 'funcode', 'urlparse',
55
]
66

77
utype = str
8+
btype = bytes
89
ltype = int
910
strbase = str, bytes
1011

@@ -13,5 +14,6 @@
1314
from urllib.parse import quote as urlquote
1415
from urllib.parse import unquote as urlunquote
1516

17+
1618
def funcode(fun):
1719
return fun.__code__

0 commit comments

Comments
 (0)