summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEneldo Serrata <eneldoserrata@gmail.com>2013-06-12 20:18:20 +0000
committerEneldo Serrata <eneldoserrata@gmail.com>2013-06-12 20:18:20 +0000
commitaa9fb70b920936b61a4a6c65b680a7bf15d3424f (patch)
tree61aa74c77c187d7a549b7aefdfcbcdf5db4cefb0
parent81bd425e8d2b25ecec5bf9e6874fa9e6823d1234 (diff)
downloadcherrypy-aa9fb70b920936b61a4a6c65b680a7bf15d3424f.tar.gz
fix profiler.py bug when runing in python 3.x
-rw-r--r--cherrypy/lib/profiler.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/cherrypy/lib/profiler.py b/cherrypy/lib/profiler.py
index 5ffe3b30..f7bf2eb3 100644
--- a/cherrypy/lib/profiler.py
+++ b/cherrypy/lib/profiler.py
@@ -53,7 +53,7 @@ import os, os.path
import sys
import warnings
-from cherrypy._cpcompat import BytesIO
+from cherrypy._cpcompat import BytesIO, StringIO
_count = 0
@@ -85,7 +85,10 @@ class Profiler(object):
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()