Skip to content

Commit ef2b55f

Browse files
committed
Allow passing the module object itself to json.use().
--HG-- extra : convert_revision : svn%3A7a298fb0-333a-0410-83e7-658617cd9cf3/trunk%40172
1 parent 05f1428 commit ef2b55f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

couchdb/json.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,18 @@ def use(module=None, decode=None, encode=None):
7979
corresponding JSON string. Exceptions raised by decoding and encoding
8080
should be propagated up unaltered.
8181
82-
:param module: the name of the JSON library module to use.
83-
:type module: str
82+
:param module: the name of the JSON library module to use, or the module
83+
object itself
84+
:type module: str or module
8485
:param decode: a function for decoding JSON strings
8586
:type decode: callable
8687
:param encode: a function for encoding objects as JSON strings
8788
:type encode: callable
8889
"""
8990
global _decode, _encode, _initialized, _using
9091
if module is not None:
92+
if not isinstance(module, basestring):
93+
module = module.__name__
9194
if module not in ('cjson', 'json', 'simplejson'):
9295
raise ValueError('Unsupported JSON module %s' % module)
9396
_using = module

0 commit comments

Comments
 (0)