mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Make sure we get usable error messages when text could not be decoded when fetched from the database.
This commit is contained in:
parent
20c892db10
commit
873d9ff84c
2 changed files with 29 additions and 1 deletions
|
@ -79,6 +79,20 @@ class RegressionTests(unittest.TestCase):
|
|||
cur.fetchone()
|
||||
cur.fetchone()
|
||||
|
||||
def CheckErrorMsgDecodeError(self):
|
||||
# When porting the module to Python 3.0, the error message about
|
||||
# decoding errors disappeared. This verifies they're back again.
|
||||
failure = None
|
||||
try:
|
||||
self.con.execute("select 'xxx' || ? || 'yyy' colname", (bytes(bytearray([250])),)).fetchone()
|
||||
failure = "should have raised an OperationalError with detailed description"
|
||||
except sqlite.OperationalError as e:
|
||||
msg = e.args[0]
|
||||
if not msg.startswith("Could not decode to UTF-8 column 'colname' with text 'xxx"):
|
||||
failure = "OperationalError did not have expected description text"
|
||||
if failure:
|
||||
self.fail(failure)
|
||||
|
||||
def suite():
|
||||
regression_suite = unittest.makeSuite(RegressionTests, "Check")
|
||||
return unittest.TestSuite((regression_suite,))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue