mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
tracemalloc: filter_traces() raises a TypeError if filters is not an iterable
This commit is contained in:
parent
bcfcfc51f8
commit
8ce8ff9ac7
2 changed files with 6 additions and 1 deletions
|
@ -346,6 +346,8 @@ class TestSnapshot(unittest.TestCase):
|
||||||
self.assertIsNot(snapshot5.traces, snapshot.traces)
|
self.assertIsNot(snapshot5.traces, snapshot.traces)
|
||||||
self.assertEqual(snapshot5.traces, snapshot.traces)
|
self.assertEqual(snapshot5.traces, snapshot.traces)
|
||||||
|
|
||||||
|
self.assertRaises(TypeError, snapshot.filter_traces, filter1)
|
||||||
|
|
||||||
def test_snapshot_group_by_line(self):
|
def test_snapshot_group_by_line(self):
|
||||||
snapshot, snapshot2 = create_snapshots()
|
snapshot, snapshot2 = create_snapshots()
|
||||||
tb_0 = traceback_lineno('<unknown>', 0)
|
tb_0 = traceback_lineno('<unknown>', 0)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from collections import Sequence
|
from collections import Sequence, Iterable
|
||||||
from functools import total_ordering
|
from functools import total_ordering
|
||||||
import fnmatch
|
import fnmatch
|
||||||
import linecache
|
import linecache
|
||||||
|
@ -382,6 +382,9 @@ class Snapshot:
|
||||||
is a list of Filter instances. If filters is an empty list, return a
|
is a list of Filter instances. If filters is an empty list, return a
|
||||||
new Snapshot instance with a copy of the traces.
|
new Snapshot instance with a copy of the traces.
|
||||||
"""
|
"""
|
||||||
|
if not isinstance(filters, Iterable):
|
||||||
|
raise TypeError("filters must be a list of filters, not %s"
|
||||||
|
% type(filters).__name__)
|
||||||
if filters:
|
if filters:
|
||||||
include_filters = []
|
include_filters = []
|
||||||
exclude_filters = []
|
exclude_filters = []
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue