Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions 5 Lib/test/test_capi/test_watchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,9 @@ def test_watch_unassigned_watcher_id(self):

def test_unwatch_non_dict(self):
with self.watcher() as wid:
with self.assertRaisesRegex(ValueError, r"Cannot watch non-dictionary"):
self.unwatch(wid, 1)
for wrong_type in (frozendict(), 5, [123], object()):
with self.assertRaisesRegex(ValueError, r"Cannot watch non-dictionary"):
self.unwatch(wid, wrong_type)

def test_unwatch_out_of_range_watcher_id(self):
d = {}
Expand Down
4 changes: 2 additions & 2 deletions 4 Objects/dictobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -7912,7 +7912,7 @@ validate_watcher_id(PyInterpreterState *interp, int watcher_id)
int
PyDict_Watch(int watcher_id, PyObject* dict)
{
if (!PyAnyDict_Check(dict)) {
if (!PyDict_Check(dict)) {
PyErr_SetString(PyExc_ValueError, "Cannot watch non-dictionary");
return -1;
}
Expand All @@ -7927,7 +7927,7 @@ PyDict_Watch(int watcher_id, PyObject* dict)
int
PyDict_Unwatch(int watcher_id, PyObject* dict)
{
if (!PyAnyDict_Check(dict)) {
if (!PyDict_Check(dict)) {
PyErr_SetString(PyExc_ValueError, "Cannot watch non-dictionary");
return -1;
}
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.