Skip to content

Commit 1a566f9

Browse files
author
Josh Marshall
committed
Fixed cjson import error and random id on Windows error.
1 parent a0cd626 commit 1a566f9

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

jsonrpclib/jsonrpc.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
from xmlrpclib import ServerProxy as XMLServerProxy
5555
from xmlrpclib import _Method as XML_Method
5656
import time
57+
import string
58+
import random
5759

5860
# Library includes
5961
import jsonrpclib
@@ -66,18 +68,19 @@
6668
try:
6769
import cjson
6870
except ImportError:
69-
pass
70-
if not cjson:
7171
try:
7272
import json
7373
except ImportError:
74-
pass
75-
if not cjson and not json:
76-
try:
77-
import simplejson as json
78-
except ImportError:
79-
raise ImportError('You must have the cjson, json, or simplejson ' +
80-
'module(s) available.')
74+
try:
75+
import simplejson as json
76+
except ImportError:
77+
raise ImportError(
78+
'You must have the cjson, json, or simplejson ' +
79+
'module(s) available.'
80+
)
81+
82+
IDCHARS = string.ascii_lowercase+string.digits
83+
8184

8285
#JSON Abstractions
8386

@@ -97,7 +100,7 @@ def jloads(json_string):
97100
return json.loads(json_string)
98101

99102

100-
# XMLRPClib re-implemntations
103+
# XMLRPClib re-implementations
101104

102105
class ProtocolError(Exception):
103106
pass
@@ -359,13 +362,9 @@ def __repr__(self):
359362
return '<Fault %s: %s>' % (self.faultCode, self.faultString)
360363

361364
def random_id(length=8):
362-
import string
363-
import random
364-
random.seed()
365-
choices = string.lowercase+string.digits
366365
return_id = ''
367366
for i in range(length):
368-
return_id += random.choice(choices)
367+
return_id += random.choice(IDCHARS)
369368
return return_id
370369

371370
class Payload(dict):

setup.py

100755100644
File mode changed.

0 commit comments

Comments
 (0)