Show More
@@ -226,20 +226,12 b' python-profiler package from non-free.""")' | |||
|
226 | 226 | |
|
227 | 227 | # Trap output. |
|
228 | 228 | stdout_trap = StringIO() |
|
229 | ||
|
230 | if hasattr(stats,'stream'): | |
|
231 | # In newer versions of python, the stats object has a 'stream' | |
|
232 | # attribute to write into. | |
|
229 | stats_stream = stats.stream | |
|
230 | try: | |
|
233 | 231 | stats.stream = stdout_trap |
|
234 | 232 | stats.print_stats(*lims) |
|
235 |
|
|
|
236 | # For older versions, we manually redirect stdout during printing | |
|
237 | sys_stdout = sys.stdout | |
|
238 | try: | |
|
239 | sys.stdout = stdout_trap | |
|
240 | stats.print_stats(*lims) | |
|
241 | finally: | |
|
242 | sys.stdout = sys_stdout | |
|
233 | finally: | |
|
234 | stats.stream = stats_stream | |
|
243 | 235 | |
|
244 | 236 | output = stdout_trap.getvalue() |
|
245 | 237 | output = output.rstrip() |
General Comments 0
You need to be logged in to leave comments.
Login now