FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.13] gh-156189: Fix a crash when deleting frame.f_trace_opcodes by serhiy-storchaka · Pull Request #156190 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) .py  (1) .rst  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
8 changes: 8 additions & 0 deletions Lib/test/test_frame.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,14 @@ def test_locals_clear_locals(self):
self.assertEqual(outer.f_locals, {})
self.assertEqual(inner.f_locals, {})

def test_f_trace_opcodes_del(self):
f, _, _ = self.make_frames()
f.f_trace_opcodes = True
with self.assertRaisesRegex(AttributeError, 'cannot delete attribute'):
del f.f_trace_opcodes
# a failed deletion does not change the value
self.assertIs(f.f_trace_opcodes, True)

def test_f_lineno_del_segfault(self):
f, _, _ = self.make_frames()
with self.assertRaises(AttributeError):
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix a crash when deleting the :attr:`~frame.f_trace_opcodes` attribute of
a frame object. It now raises :exc:`AttributeError`.
5 changes: 5 additions & 0 deletions Objects/frameobject.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,11 @@ frame_gettrace_opcodes(PyFrameObject *f, void *closure)
static int
frame_settrace_opcodes(PyFrameObject *f, PyObject* value, void *Py_UNUSED(ignored))
{
if (value == NULL) {
PyErr_SetString(PyExc_AttributeError,
"cannot delete attribute f_trace_opcodes");
return -1;
}
if (!PyBool_Check(value)) {
PyErr_SetString(PyExc_TypeError,
"attribute value type must be bool");
Expand Down
Loading

Back | FazBrowse Home | New Git URL