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