diff options
author | 2014-02-01 04:07:02 +0100 | |
---|---|---|
committer | 2014-02-01 04:07:02 +0100 | |
commit | 524be3056e29a86741ba355c759ff304adf6cc3c (patch) | |
tree | 45f10ab8b321ffbda59da8cc2ceeb0aeeeaeee72 /Lib/tracemalloc.py | |
parent | Issue #20354: Mention the fix in Misc/NEWS (diff) | |
download | cpython-524be3056e29a86741ba355c759ff304adf6cc3c.tar.gz cpython-524be3056e29a86741ba355c759ff304adf6cc3c.tar.bz2 cpython-524be3056e29a86741ba355c759ff304adf6cc3c.zip |
tracemalloc: Fix slicing traces and fix slicing a traceback.
Diffstat (limited to 'Lib/tracemalloc.py')
-rw-r--r-- | Lib/tracemalloc.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Lib/tracemalloc.py b/Lib/tracemalloc.py index 816f7346d64..b0759469397 100644 --- a/Lib/tracemalloc.py +++ b/Lib/tracemalloc.py @@ -182,8 +182,10 @@ class Traceback(Sequence): return len(self._frames) def __getitem__(self, index): - trace = self._frames[index] - return Frame(trace) + if isinstance(index, slice): + return tuple(Frame(trace) for trace in self._frames[index]) + else: + return Frame(self._frames[index]) def __contains__(self, frame): return frame._frame in self._frames @@ -259,8 +261,10 @@ class _Traces(Sequence): return len(self._traces) def __getitem__(self, index): - trace = self._traces[index] - return Trace(trace) + if isinstance(index, slice): + return tuple(Trace(trace) for trace in self._traces[index]) + else: + return Trace(self._traces[index]) def __contains__(self, trace): return trace._trace in self._traces |