summaryrefslogtreecommitdiffstats
path: root/Lib/sqlite3
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2019-09-16 17:15:18 (GMT)
committerGitHub <noreply@github.com>2019-09-16 17:15:18 (GMT)
commit8debfa50407107ff2329d01081cdc12d359f1d12 (patch)
tree37668c95d2aad9ac11e6c9a97a2b0cccce3526b8 /Lib/sqlite3
parenta9187c31185fe7ea47271839898416400cc3d976 (diff)
downloadcpython-8debfa50407107ff2329d01081cdc12d359f1d12.zip
cpython-8debfa50407107ff2329d01081cdc12d359f1d12.tar.gz
cpython-8debfa50407107ff2329d01081cdc12d359f1d12.tar.bz2
bpo-38175: Fix a memory leak in comparison of sqlite3.Row objects. (GH-16155)
Diffstat (limited to 'Lib/sqlite3')
-rw-r--r--Lib/sqlite3/test/factory.py28
1 files changed, 21 insertions, 7 deletions
diff --git a/Lib/sqlite3/test/factory.py b/Lib/sqlite3/test/factory.py
index ced8445..f103211 100644
--- a/Lib/sqlite3/test/factory.py
+++ b/Lib/sqlite3/test/factory.py
@@ -169,19 +169,33 @@ class RowFactoryTests(unittest.TestCase):
row_1 = self.con.execute("select 1 as a, 2 as b").fetchone()
row_2 = self.con.execute("select 1 as a, 2 as b").fetchone()
row_3 = self.con.execute("select 1 as a, 3 as b").fetchone()
+ row_4 = self.con.execute("select 1 as b, 2 as a").fetchone()
+ row_5 = self.con.execute("select 2 as b, 1 as a").fetchone()
- self.assertEqual(row_1, row_1)
- self.assertEqual(row_1, row_2)
- self.assertTrue(row_2 != row_3)
+ self.assertTrue(row_1 == row_1)
+ self.assertTrue(row_1 == row_2)
+ self.assertFalse(row_1 == row_3)
+ self.assertFalse(row_1 == row_4)
+ self.assertFalse(row_1 == row_5)
+ self.assertFalse(row_1 == object())
self.assertFalse(row_1 != row_1)
self.assertFalse(row_1 != row_2)
- self.assertFalse(row_2 == row_3)
+ self.assertTrue(row_1 != row_3)
+ self.assertTrue(row_1 != row_4)
+ self.assertTrue(row_1 != row_5)
+ self.assertTrue(row_1 != object())
+
+ with self.assertRaises(TypeError):
+ row_1 > row_2
+ with self.assertRaises(TypeError):
+ row_1 < row_2
+ with self.assertRaises(TypeError):
+ row_1 >= row_2
+ with self.assertRaises(TypeError):
+ row_1 <= row_2
- self.assertEqual(row_1, row_2)
self.assertEqual(hash(row_1), hash(row_2))
- self.assertNotEqual(row_1, row_3)
- self.assertNotEqual(hash(row_1), hash(row_3))
def CheckSqliteRowAsSequence(self):
""" Checks if the row object can act like a sequence """