[issue29021] Custom functions in sqlite receive None on invalid UTF-8

2016-12-20 Thread Ingo Ruhnke

New submission from Ingo Ruhnke:

When a sqlite database contains invalid UTF-8 code in a TEXT column, Python can 
query that data normally when .text_factory is set appropriately. However when 
a custom function is created with .create_function() and applied to that column 
the custom function will receive 'None' as argument instead of the value of the 
column.

The following example demonstrate the issue:

Example:


import sqlite3
import sys
import os

con = sqlite3.connect(":memory:")
con.text_factory = os.fsdecode

con.create_function("py_identity", 1, lambda x: x)

cur = con.cursor()
cur.execute("CREATE TABLE foo(bar TEXT)")

# insert some invalid UTF-8 into the database
cur.execute("INSERT INTO foo(bar) VALUES(cast(? AS TEXT))", [b"\xff"])

# try to call a custom function on the invalid UTF-8
cur.execute("SELECT "
"  typeof(bar), "
"  bar, " # this works
"  py_identity(bar), " # this returns None instead of the content 
of 'bar'
"  cast(py_identity(cast(bar as BLOB)) AS TEXT) " # this works 
around the issue
"FROM foo")

for row in cur:
print(row)

Output:
---

('text', '\udcff', None, '\udcff')


Expected:
-----

('text', '\udcff', '\udcff', '\udcff')

--
components: Library (Lib)
messages: 283674
nosy: Ingo Ruhnke
priority: normal
severity: normal
status: open
title: Custom functions in sqlite receive None on invalid UTF-8
type: behavior
versions: Python 3.6

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29021>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16041] poplib: unlimited readline() from connection

2015-06-28 Thread Ingo Ruhnke

Ingo Ruhnke added the comment:

This fix has broken mail retrieval from both gmx.de, gmail.com and plenty of 
other provider.

It manifests in getmail as:

Retrieval error: server for BrokenUIDLPOP3SSLRetriever:1860...@pop.gmx.net:995 
is broken; offered message 239 but failed to provide it.  Please notify the 
administrator of the server.  Skipping message...

After setting the _MAXLINE in /usr/lib/python2.7/poplib.py to something higher 
everything was working again.

See issue #23906

--
nosy: +Ingo Ruhnke

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16041
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23906] poplib maxline behaviour may be wrong

2015-06-28 Thread Ingo Ruhnke

Ingo Ruhnke added the comment:

This also breaks mail retrieval from both gmx.de and gmail.com (two rather 
large and popular mail provider). After setting _MAXLINE 
in/usr/lib/python2.7/poplib.py to some arbitrary higher number mail retrieval 
from both services worked fine again.

This this 2048 does definitively looks badly broken.

--
nosy: +Ingo Ruhnke

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23906
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com