Don't accept frozendict in PyDict_Watch() and PyDict_Unwatch().
A frozendict cannot be modified, so it's not useful to watch for
modifications.
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 = {}
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;
}
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;
}