@@ -240,19 +240,16 @@ dummy_func(void) {
240240 if (sym_matches_type_version (owner , type_version )) {
241241 ADD_OP (_NOP , 0 , 0 );
242242 } else {
243- // add watcher so that whenever the type changes we invalidate this
244- PyTypeObject * type = _PyType_LookupByVersion (type_version );
245- // if the type is null, it was not found in the cache (there was a conflict)
246- // with the key, in which case we can't trust the version
247- if (type ) {
248- // if the type version was set properly, then add a watcher
249- // if it wasn't this means that the type version was previously set to something else
250- // and we set the owner to bottom, so we don't need to add a watcher because we must have
251- // already added one earlier.
252- if (sym_set_type_version (owner , type_version )) {
253- PyType_Watch (TYPE_WATCHER_ID , (PyObject * )type );
254- _Py_BloomFilter_Add (dependencies , type );
255- }
243+ PyTypeObject * probable_type = sym_get_probable_type (owner );
244+ if (probable_type != NULL &&
245+ probable_type -> tp_version_tag == type_version &&
246+ sym_set_type_version (owner , type_version )) {
247+ PyType_Watch (TYPE_WATCHER_ID , (PyObject * )probable_type );
248+ _Py_BloomFilter_Add (dependencies , probable_type );
249+ } else {
250+ ctx -> contradiction = true;
251+ ctx -> done = true;
252+ break ;
256253 }
257254 }
258255 }
0 commit comments