Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
e63af905
Kaydet (Commit)
e63af905
authored
Agu 29, 2016
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #27861: Fixed a crash in sqlite3.Connection.cursor() when a factory
creates not a cursor. Patch by Xiang Zhang.
üst
eac40fdf
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
9 deletions
+35
-9
sqlite3.rst
Doc/library/sqlite3.rst
+4
-4
factory.py
Lib/sqlite3/test/factory.py
+17
-3
NEWS
Misc/NEWS
+3
-0
connection.c
Modules/_sqlite/connection.c
+11
-2
No files found.
Doc/library/sqlite3.rst
Dosyayı görüntüle @
e63af905
...
@@ -256,11 +256,11 @@ Connection Objects
...
@@ -256,11 +256,11 @@ Connection Objects
:ref:`sqlite3-controlling-transactions` for a more detailed explanation.
:ref:`sqlite3-controlling-transactions` for a more detailed explanation.
.. method:: cursor(
[cursorClass]
)
.. method:: cursor(
factory=Cursor
)
The cursor method accepts a single optional parameter *
cursorClass
*. If
The cursor method accepts a single optional parameter *
factory
*. If
supplied, this must be a c
ustom cursor class that extends
supplied, this must be a c
allable returning an instance of :class:`Cursor`
:class:`sqlite3.Cursor`
.
or its subclasses
.
.. method:: commit()
.. method:: commit()
...
...
Lib/sqlite3/test/factory.py
Dosyayı görüntüle @
e63af905
...
@@ -58,9 +58,21 @@ class CursorFactoryTests(unittest.TestCase):
...
@@ -58,9 +58,21 @@ class CursorFactoryTests(unittest.TestCase):
self
.
con
.
close
()
self
.
con
.
close
()
def
CheckIsInstance
(
self
):
def
CheckIsInstance
(
self
):
cur
=
self
.
con
.
cursor
(
factory
=
MyCursor
)
cur
=
self
.
con
.
cursor
()
self
.
assertIsInstance
(
cur
,
sqlite
.
Cursor
)
cur
=
self
.
con
.
cursor
(
MyCursor
)
self
.
assertIsInstance
(
cur
,
MyCursor
)
cur
=
self
.
con
.
cursor
(
factory
=
lambda
con
:
MyCursor
(
con
))
self
.
assertIsInstance
(
cur
,
MyCursor
)
self
.
assertIsInstance
(
cur
,
MyCursor
)
def
CheckInvalidFactory
(
self
):
# not a callable at all
self
.
assertRaises
(
TypeError
,
self
.
con
.
cursor
,
None
)
# invalid callable with not exact one argument
self
.
assertRaises
(
TypeError
,
self
.
con
.
cursor
,
lambda
:
None
)
# invalid callable returning non-cursor
self
.
assertRaises
(
TypeError
,
self
.
con
.
cursor
,
lambda
con
:
None
)
class
RowFactoryTestsBackwardsCompat
(
unittest
.
TestCase
):
class
RowFactoryTestsBackwardsCompat
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
con
=
sqlite
.
connect
(
":memory:"
)
self
.
con
=
sqlite
.
connect
(
":memory:"
)
...
@@ -173,10 +185,12 @@ class RowFactoryTests(unittest.TestCase):
...
@@ -173,10 +185,12 @@ class RowFactoryTests(unittest.TestCase):
def
CheckFakeCursorClass
(
self
):
def
CheckFakeCursorClass
(
self
):
# Issue #24257: Incorrect use of PyObject_IsInstance() caused
# Issue #24257: Incorrect use of PyObject_IsInstance() caused
# segmentation fault.
# segmentation fault.
# Issue #27861: Also applies for cursor factory.
class
FakeCursor
(
str
):
class
FakeCursor
(
str
):
__class__
=
sqlite
.
Cursor
__class__
=
sqlite
.
Cursor
cur
=
self
.
con
.
cursor
(
factory
=
FakeCursor
)
self
.
con
.
row_factory
=
sqlite
.
Row
self
.
assertRaises
(
TypeError
,
sqlite
.
Row
,
cur
,
())
self
.
assertRaises
(
TypeError
,
self
.
con
.
cursor
,
FakeCursor
)
self
.
assertRaises
(
TypeError
,
sqlite
.
Row
,
FakeCursor
(),
())
def
tearDown
(
self
):
def
tearDown
(
self
):
self
.
con
.
close
()
self
.
con
.
close
()
...
...
Misc/NEWS
Dosyayı görüntüle @
e63af905
...
@@ -33,6 +33,9 @@ Core and Builtins
...
@@ -33,6 +33,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #27861: Fixed a crash in sqlite3.Connection.cursor() when a factory
creates not a cursor. Patch by Xiang Zhang.
- Issue #19884: Avoid spurious output on OS X with Gnu Readline.
- Issue #19884: Avoid spurious output on OS X with Gnu Readline.
- Issue #10513: Fix a regression in Connection.commit(). Statements should
- Issue #10513: Fix a regression in Connection.commit(). Statements should
...
...
Modules/_sqlite/connection.c
Dosyayı görüntüle @
e63af905
...
@@ -324,7 +324,7 @@ error:
...
@@ -324,7 +324,7 @@ error:
PyObject
*
pysqlite_connection_cursor
(
pysqlite_Connection
*
self
,
PyObject
*
args
,
PyObject
*
kwargs
)
PyObject
*
pysqlite_connection_cursor
(
pysqlite_Connection
*
self
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
{
static
char
*
kwlist
[]
=
{
"factory"
,
NULL
,
NULL
};
static
char
*
kwlist
[]
=
{
"factory"
,
NULL
};
PyObject
*
factory
=
NULL
;
PyObject
*
factory
=
NULL
;
PyObject
*
cursor
;
PyObject
*
cursor
;
...
@@ -341,7 +341,16 @@ PyObject* pysqlite_connection_cursor(pysqlite_Connection* self, PyObject* args,
...
@@ -341,7 +341,16 @@ PyObject* pysqlite_connection_cursor(pysqlite_Connection* self, PyObject* args,
factory
=
(
PyObject
*
)
&
pysqlite_CursorType
;
factory
=
(
PyObject
*
)
&
pysqlite_CursorType
;
}
}
cursor
=
PyObject_CallFunction
(
factory
,
"O"
,
self
);
cursor
=
PyObject_CallFunctionObjArgs
(
factory
,
(
PyObject
*
)
self
,
NULL
);
if
(
cursor
==
NULL
)
return
NULL
;
if
(
!
PyObject_TypeCheck
(
cursor
,
&
pysqlite_CursorType
))
{
PyErr_Format
(
PyExc_TypeError
,
"factory must return a cursor, not %.100s"
,
Py_TYPE
(
cursor
)
->
tp_name
);
Py_DECREF
(
cursor
);
return
NULL
;
}
_pysqlite_drop_unused_cursor_references
(
self
);
_pysqlite_drop_unused_cursor_references
(
self
);
...
...
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