Robert Brewer avatar Robert Brewer committed ae1b2e3

A couple more Python 2.3 fixes.

Comments (0)

Files changed (2)

cherrypy/_cpcompat.py

 import binascii
 try:
     os.urandom(20)
+    def random20():
+        return binascii.hexlify(os.urandom(20)).decode('ascii')
 except (AttributeError, NotImplementedError):
+    import random
     # os.urandom not available until Python 2.4. Fall back to random.random.
     def random20():
-        return binascii.hexlify(sha(random.random())).decode('ascii')
-else:
-    def random20():
-        return binascii.hexlify(os.urandom(20)).decode('ascii')
+        return sha('%s' % random.random()).hexdigest()
 
 try:
     from _thread import get_ident as get_thread_ident

cherrypy/test/test_json.py

     
     def test_json_output(self):
         if json is None:
-            self.skip("json not found")
+            self.skip("json not found ")
+            return
         
         self.getPage("/plain")
         self.assertBody("hello")
 
     def test_json_input(self):
         if json is None:
-            self.skip("json not found")
+            self.skip("json not found ")
+            return
         
         body = '[13, "c"]'
         headers = [('Content-Type', 'application/json'),
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.