-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Open
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
Snapshot.filter_traces() assumes that the internal traces container supports .copy().
If a Snapshot is constructed with tuple traces, calling filter_traces(()) raises:
AttributeError: 'tuple' object has no attribute 'copy'
Mini Reproducible Script:
import tracemalloc
tracemalloc.start(25)
snap = tracemalloc.take_snapshot()
snap2 = tracemalloc.Snapshot(tuple(snap.traces._traces), snap.traceback_limit)
snap2.filter_traces(())
print("done")
Traceback (on Windows debug build):
D:\MyCode\cpython\PCbuild\amd64>python_d.exe py_tracemalloc.py
Traceback (most recent call last):
File "D:\MyCode\cpython\PCbuild\amd64\py_tracemalloc.py", line 6, in <module>
snap2.filter_traces(())
~~~~~~~~~~~~~~~~~~~^^^^
File "D:\MyCode\cpython\Lib\tracemalloc.py", line 474, in filter_traces
new_traces = self.traces._traces.copy()
^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'tuple' object has no attribute 'copy'
CPython versions tested on:
CPython main branch
Operating systems tested on:
Windows
Linked PRs
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error