diff Lib/sqlite3/test/regression.py @ 45581:fc6f90545cb4

Make sure we get usable error messages when text could not be decoded when fetched from the database.
author Gerhard Häring <gh@ghaering.de>
date Fri, 29 Feb 2008 22:22:09 +0000
parents a6eb6acfe04a
children e06e08e8fdce
line wrap: on
line diff
--- a/Lib/sqlite3/test/regression.py	Fri Feb 29 21:03:38 2008 +0000
+++ b/Lib/sqlite3/test/regression.py	Fri Feb 29 22:22:09 2008 +0000
@@ -79,6 +79,20 @@
         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,))