Commits

Eneldo Serrata committed cf8617b Merge

Merged in eneldoserrata/fix-profilerpy-bug-when-runing-in-python-1371068218314 (pull request #1)

fix profiler.py bug when runing in python 3.x

  • Participants
  • Parent commits f2a993b, d6edaa6

Comments (0)

Files changed (1)

File cherrypy/lib/profiler.py

 import sys
 import warnings
 
-from cherrypy._cpcompat import BytesIO
+from cherrypy._cpcompat import BytesIO, StringIO
 
 _count = 0
 
     def stats(self, filename, sortby='cumulative'):
         """:rtype stats(index): output of print_stats() for the given profile.
         """
-        sio = BytesIO()
+        if sys.version_info >= (3, 0):
+            sio = StringIO()
+        else:
+            sio = BytesIO()
         if sys.version_info >= (2, 5):
             s = pstats.Stats(os.path.join(self.path, filename), stream=sio)
             s.strip_dirs()