Issue #24257: Fixed incorrect uses of PyObject_IsInstance().
Fixed segmentation fault in sqlite3.Row constructor with faked cursor type.
Fixed system error in the comparison of faked types.SimpleNamespace.
diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py
index ec10752..849cba9 100644
--- a/Lib/test/test_types.py
+++ b/Lib/test/test_types.py
@@ -1169,6 +1169,22 @@
self.assertEqual(ns, ns_roundtrip, pname)
+ def test_fake_namespace_compare(self):
+ # Issue #24257: Incorrect use of PyObject_IsInstance() caused
+ # SystemError.
+ class FakeSimpleNamespace(str):
+ __class__ = types.SimpleNamespace
+ self.assertFalse(types.SimpleNamespace() == FakeSimpleNamespace())
+ self.assertTrue(types.SimpleNamespace() != FakeSimpleNamespace())
+ with self.assertRaises(TypeError):
+ types.SimpleNamespace() < FakeSimpleNamespace()
+ with self.assertRaises(TypeError):
+ types.SimpleNamespace() <= FakeSimpleNamespace()
+ with self.assertRaises(TypeError):
+ types.SimpleNamespace() > FakeSimpleNamespace()
+ with self.assertRaises(TypeError):
+ types.SimpleNamespace() >= FakeSimpleNamespace()
+
def test_main():
run_unittest(TypesTests, MappingProxyTests, ClassCreationTests,