summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-05-22 08:13:20 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-05-22 08:13:20 (GMT)
commite79ec70801e410de9c3110ffe78f98e08114ae16 (patch)
tree4dffcd5f09a018f6b67feaeab43963aed6726eab /Lib
parent5cbd8331ff567ee568713dc5e63820ffb453ac4b (diff)
parent08d230a5408e9fac3adbb357f5fb4a43958991d4 (diff)
downloadcpython-e79ec70801e410de9c3110ffe78f98e08114ae16.zip
cpython-e79ec70801e410de9c3110ffe78f98e08114ae16.tar.gz
cpython-e79ec70801e410de9c3110ffe78f98e08114ae16.tar.bz2
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.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/sqlite3/test/factory.py8
-rw-r--r--Lib/test/test_types.py16
2 files changed, 24 insertions, 0 deletions
diff --git a/Lib/sqlite3/test/factory.py b/Lib/sqlite3/test/factory.py
index 3d4eb0b..f587596 100644
--- a/Lib/sqlite3/test/factory.py
+++ b/Lib/sqlite3/test/factory.py
@@ -180,6 +180,14 @@ class RowFactoryTests(unittest.TestCase):
self.assertEqual(list(reversed(row)), list(reversed(as_tuple)))
self.assertIsInstance(row, Sequence)
+ def CheckFakeCursorClass(self):
+ # Issue #24257: Incorrect use of PyObject_IsInstance() caused
+ # segmentation fault.
+ class FakeCursor(str):
+ __class__ = sqlite.Cursor
+ cur = self.con.cursor(factory=FakeCursor)
+ self.assertRaises(TypeError, sqlite.Row, cur, ())
+
def tearDown(self):
self.con.close()
diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py
index c5a35f9..ccaf414 100644
--- a/Lib/test/test_types.py
+++ b/Lib/test/test_types.py
@@ -1172,6 +1172,22 @@ class SimpleNamespaceTests(unittest.TestCase):
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()
+
class CoroutineTests(unittest.TestCase):
def test_wrong_args(self):