@@ -53,6 +53,8 @@ def wrapper(self, *args, **kwargs):
5353
5454def func_returntext ():
5555 return "foo"
56+ def func_returntextwithnull ():
57+ return "1\x00 2"
5658def func_returnunicode ():
5759 return "bar"
5860def func_returnint ():
@@ -168,6 +170,7 @@ def setUp(self):
168170 self .con = sqlite .connect (":memory:" )
169171
170172 self .con .create_function ("returntext" , 0 , func_returntext )
173+ self .con .create_function ("returntextwithnull" , 0 , func_returntextwithnull )
171174 self .con .create_function ("returnunicode" , 0 , func_returnunicode )
172175 self .con .create_function ("returnint" , 0 , func_returnint )
173176 self .con .create_function ("returnfloat" , 0 , func_returnfloat )
@@ -211,6 +214,12 @@ def test_func_return_text(self):
211214 self .assertEqual (type (val ), str )
212215 self .assertEqual (val , "foo" )
213216
217+ def test_func_return_text_with_null_char (self ):
218+ cur = self .con .cursor ()
219+ res = cur .execute ("select returntextwithnull()" ).fetchone ()[0 ]
220+ self .assertEqual (type (res ), str )
221+ self .assertEqual (res , "1\x00 2" )
222+
214223 def test_func_return_unicode (self ):
215224 cur = self .con .cursor ()
216225 cur .execute ("select returnunicode()" )
0 commit comments