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
8b245065
Commit
8b245065
authored
Feb 21, 2012
by
Petri Lehtinen
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '3.2'
Closes #8033.
parents
307da2b0
4fe85aba
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
6 deletions
+24
-6
Lib/sqlite3/test/userfunctions.py
Lib/sqlite3/test/userfunctions.py
+18
-0
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS
Misc/NEWS
+3
-0
Modules/_sqlite/connection.c
Modules/_sqlite/connection.c
+2
-6
No files found.
Lib/sqlite3/test/userfunctions.py
View file @
8b245065
...
...
@@ -37,6 +37,8 @@ def func_returnnull():
return
None
def
func_returnblob
():
return
b"blob"
def
func_returnlonglong
():
return
1
<<
31
def
func_raiseexception
():
5
/
0
...
...
@@ -50,6 +52,8 @@ def func_isnone(v):
return
type
(
v
)
is
type
(
None
)
def
func_isblob
(
v
):
return
isinstance
(
v
,
(
bytes
,
memoryview
))
def
func_islonglong
(
v
):
return
isinstance
(
v
,
int
)
and
v
>=
1
<<
31
class
AggrNoStep
:
def
__init__
(
self
):
...
...
@@ -127,6 +131,7 @@ class FunctionTests(unittest.TestCase):
self
.
con
.
create_function
(
"returnfloat"
,
0
,
func_returnfloat
)
self
.
con
.
create_function
(
"returnnull"
,
0
,
func_returnnull
)
self
.
con
.
create_function
(
"returnblob"
,
0
,
func_returnblob
)
self
.
con
.
create_function
(
"returnlonglong"
,
0
,
func_returnlonglong
)
self
.
con
.
create_function
(
"raiseexception"
,
0
,
func_raiseexception
)
self
.
con
.
create_function
(
"isstring"
,
1
,
func_isstring
)
...
...
@@ -134,6 +139,7 @@ class FunctionTests(unittest.TestCase):
self
.
con
.
create_function
(
"isfloat"
,
1
,
func_isfloat
)
self
.
con
.
create_function
(
"isnone"
,
1
,
func_isnone
)
self
.
con
.
create_function
(
"isblob"
,
1
,
func_isblob
)
self
.
con
.
create_function
(
"islonglong"
,
1
,
func_islonglong
)
def
tearDown
(
self
):
self
.
con
.
close
()
...
...
@@ -200,6 +206,12 @@ class FunctionTests(unittest.TestCase):
self
.
assertEqual
(
type
(
val
),
bytes
)
self
.
assertEqual
(
val
,
b"blob"
)
def
CheckFuncReturnLongLong
(
self
):
cur
=
self
.
con
.
cursor
()
cur
.
execute
(
"select returnlonglong()"
)
val
=
cur
.
fetchone
()[
0
]
self
.
assertEqual
(
val
,
1
<<
31
)
def
CheckFuncException
(
self
):
cur
=
self
.
con
.
cursor
()
try
:
...
...
@@ -239,6 +251,12 @@ class FunctionTests(unittest.TestCase):
val
=
cur
.
fetchone
()[
0
]
self
.
assertEqual
(
val
,
1
)
def
CheckParamLongLong
(
self
):
cur
=
self
.
con
.
cursor
()
cur
.
execute
(
"select islonglong(?)"
,
(
1
<<
42
,))
val
=
cur
.
fetchone
()[
0
]
self
.
assertEqual
(
val
,
1
)
class
AggregateTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
con
=
sqlite
.
connect
(
":memory:"
)
...
...
Misc/ACKS
View file @
8b245065
...
...
@@ -242,6 +242,7 @@ Konrad Delong
Erik Demaine
John Dennis
Roger Dev
Philippe Devalkeneer
Raghuram Devarakonda
Caleb Deveraux
Catherine Devlin
...
...
Misc/NEWS
View file @
8b245065
...
...
@@ -479,6 +479,9 @@ Core and Builtins
Library
-------
-
Issue
#
8033
:
sqlite3
:
Fix
64
-
bit
integer
handling
in
user
functions
on
32
-
bit
architectures
.
Initial
patch
by
Philippe
Devalkeneer
.
-
HTMLParser
is
now
able
to
handle
slashes
in
the
start
tag
.
-
Issue
#
13641
:
Decoding
functions
in
the
base64
module
now
accept
ASCII
-
only
...
...
Modules/_sqlite/connection.c
View file @
8b245065
...
...
@@ -484,7 +484,6 @@ error:
void
_pysqlite_set_result
(
sqlite3_context
*
context
,
PyObject
*
py_val
)
{
long
longval
;
const
char
*
buffer
;
Py_ssize_t
buflen
;
...
...
@@ -493,8 +492,7 @@ void _pysqlite_set_result(sqlite3_context* context, PyObject* py_val)
}
else
if
(
py_val
==
Py_None
)
{
sqlite3_result_null
(
context
);
}
else
if
(
PyLong_Check
(
py_val
))
{
longval
=
PyLong_AsLong
(
py_val
);
sqlite3_result_int64
(
context
,
(
PY_LONG_LONG
)
longval
);
sqlite3_result_int64
(
context
,
PyLong_AsLongLong
(
py_val
));
}
else
if
(
PyFloat_Check
(
py_val
))
{
sqlite3_result_double
(
context
,
PyFloat_AsDouble
(
py_val
));
}
else
if
(
PyUnicode_Check
(
py_val
))
{
...
...
@@ -519,7 +517,6 @@ PyObject* _pysqlite_build_py_params(sqlite3_context *context, int argc, sqlite3_
sqlite3_value
*
cur_value
;
PyObject
*
cur_py_value
;
const
char
*
val_str
;
PY_LONG_LONG
val_int
;
Py_ssize_t
buflen
;
args
=
PyTuple_New
(
argc
);
...
...
@@ -531,8 +528,7 @@ PyObject* _pysqlite_build_py_params(sqlite3_context *context, int argc, sqlite3_
cur_value
=
argv
[
i
];
switch
(
sqlite3_value_type
(
argv
[
i
]))
{
case
SQLITE_INTEGER
:
val_int
=
sqlite3_value_int64
(
cur_value
);
cur_py_value
=
PyLong_FromLong
((
long
)
val_int
);
cur_py_value
=
PyLong_FromLongLong
(
sqlite3_value_int64
(
cur_value
));
break
;
case
SQLITE_FLOAT
:
cur_py_value
=
PyFloat_FromDouble
(
sqlite3_value_double
(
cur_value
));
...
...
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