Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
be257bca
Commit
be257bca
authored
Sep 17, 2019
by
Serhiy Storchaka
Committed by
GitHub
Sep 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.7] bpo-38175: Fix a memory leak in comparison of sqlite3.Row objects. (GH-16155). (GH-16215)
(cherry picked from commit
8debfa50
)
parent
5d55d52b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
12 deletions
+20
-12
Lib/sqlite3/test/factory.py
Lib/sqlite3/test/factory.py
+12
-7
Misc/NEWS.d/next/Library/2019-09-15-10-30-33.bpo-38175.61XlUv.rst
...S.d/next/Library/2019-09-15-10-30-33.bpo-38175.61XlUv.rst
+1
-0
Modules/_sqlite/row.c
Modules/_sqlite/row.c
+7
-5
No files found.
Lib/sqlite3/test/factory.py
View file @
be257bca
...
@@ -159,19 +159,24 @@ class RowFactoryTests(unittest.TestCase):
...
@@ -159,19 +159,24 @@ class RowFactoryTests(unittest.TestCase):
row_1
=
self
.
con
.
execute
(
"select 1 as a, 2 as b"
).
fetchone
()
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_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_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
.
assertTrue
(
row_1
==
row_1
)
self
.
assertEqual
(
row_1
,
row_2
)
self
.
assertTrue
(
row_1
==
row_2
)
self
.
assertTrue
(
row_2
!=
row_3
)
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_1
)
self
.
assertFalse
(
row_1
!=
row_2
)
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
())
self
.
assertEqual
(
row_1
,
row_2
)
self
.
assertEqual
(
hash
(
row_1
),
hash
(
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
):
def
CheckSqliteRowAsSequence
(
self
):
""" Checks if the row object can act like a sequence """
""" Checks if the row object can act like a sequence """
...
...
Misc/NEWS.d/next/Library/2019-09-15-10-30-33.bpo-38175.61XlUv.rst
0 → 100644
View file @
be257bca
Fix a memory leak in comparison of :class:`sqlite3.Row` objects.
Modules/_sqlite/row.c
View file @
be257bca
...
@@ -199,14 +199,16 @@ static PyObject* pysqlite_row_richcompare(pysqlite_Row *self, PyObject *_other,
...
@@ -199,14 +199,16 @@ static PyObject* pysqlite_row_richcompare(pysqlite_Row *self, PyObject *_other,
Py_INCREF
(
Py_NotImplemented
);
Py_INCREF
(
Py_NotImplemented
);
return
Py_NotImplemented
;
return
Py_NotImplemented
;
}
}
if
(
Py
Type_IsSubtype
(
Py_TYPE
(
_other
)
,
&
pysqlite_RowType
))
{
if
(
Py
Object_TypeCheck
(
_other
,
&
pysqlite_RowType
))
{
pysqlite_Row
*
other
=
(
pysqlite_Row
*
)
_other
;
pysqlite_Row
*
other
=
(
pysqlite_Row
*
)
_other
;
PyObject
*
res
=
PyObject_RichCompare
(
self
->
description
,
other
->
description
,
opid
);
int
eq
=
PyObject_RichCompareBool
(
self
->
description
,
other
->
description
,
Py_EQ
);
if
((
opid
==
Py_EQ
&&
res
==
Py_True
)
if
(
eq
<
0
)
{
||
(
opid
==
Py_NE
&&
res
==
Py_False
))
{
return
NULL
;
Py_DECREF
(
res
);
}
if
(
eq
)
{
return
PyObject_RichCompare
(
self
->
data
,
other
->
data
,
opid
);
return
PyObject_RichCompare
(
self
->
data
,
other
->
data
,
opid
);
}
}
return
PyBool_FromLong
(
opid
!=
Py_EQ
);
}
}
Py_INCREF
(
Py_NotImplemented
);
Py_INCREF
(
Py_NotImplemented
);
return
Py_NotImplemented
;
return
Py_NotImplemented
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment