Author: Brian Kearns <bdkea...@gmail.com>
Branch: py3k
Changeset: r62179:e65d20740bfa
Date: 2013-03-07 14:51 -0500
http://bitbucket.org/pypy/pypy/changeset/e65d20740bfa/

Log:    merge default

diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -800,6 +800,8 @@
         try:
             self.__description = None
             self._reset = False
+            if not isinstance(sql, str):
+                raise ValueError("operation parameter must be str or unicode")
             self.__statement = self.__connection._statement_cache.get(
                 sql, self.row_factory)
 
@@ -845,6 +847,8 @@
         try:
             self.__description = None
             self._reset = False
+            if not isinstance(sql, str):
+                raise ValueError("operation parameter must be str or unicode")
             self.__statement = self.__connection._statement_cache.get(
                 sql, self.row_factory)
 
@@ -876,7 +880,10 @@
         self._reset = False
         self.__check_cursor()
         statement = c_void_p()
-        sql = sql.encode('utf-8')
+        if isinstance(sql, str):
+            sql = sql.encode('utf-8')
+        else:
+            raise ValueError("script argument must be unicode or string.")
         c_sql = c_char_p(sql)
 
         self.__connection.commit()
diff --git a/pypy/module/test_lib_pypy/test_sqlite3.py 
b/pypy/module/test_lib_pypy/test_sqlite3.py
--- a/pypy/module/test_lib_pypy/test_sqlite3.py
+++ b/pypy/module/test_lib_pypy/test_sqlite3.py
@@ -127,6 +127,21 @@
     except _sqlite3.OperationalError:
         pytest.fail("_sqlite3 knew nothing about the implicit ROLLBACK")
 
+def test_statement_arg_checking():
+    con = _sqlite3.connect(':memory:')
+    with pytest.raises(_sqlite3.Warning) as e:
+        con(123)
+    assert str(e.value) == 'SQL is of wrong type. Must be string or unicode.'
+    with pytest.raises(ValueError) as e:
+        con.execute(123)
+    assert str(e.value) == 'operation parameter must be str or unicode'
+    with pytest.raises(ValueError) as e:
+        con.executemany(123, 123)
+    assert str(e.value) == 'operation parameter must be str or unicode'
+    with pytest.raises(ValueError) as e:
+        con.executescript(123)
+    assert str(e.value) == 'script argument must be unicode or string.'
+
 def test_statement_param_checking():
     con = _sqlite3.connect(':memory:')
     con.execute('create table foo(x)')
diff --git a/rpython/translator/c/gcc/trackgcroot.py 
b/rpython/translator/c/gcc/trackgcroot.py
--- a/rpython/translator/c/gcc/trackgcroot.py
+++ b/rpython/translator/c/gcc/trackgcroot.py
@@ -1099,6 +1099,7 @@
         '___assert_rtn': None,
         'L___assert_rtn$stub': None,
         'L___eprintf$stub': None,
+        '__stack_chk_fail': None,
         }
     for _name in FunctionGcRootTracker.BASE_FUNCTIONS_NOT_RETURNING:
         FUNCTIONS_NOT_RETURNING[_name] = None
@@ -1160,6 +1161,7 @@
         '___assert_rtn': None,
         'L___assert_rtn$stub': None,
         'L___eprintf$stub': None,
+        '__stack_chk_fail': None,
         }
     for _name in FunctionGcRootTracker.BASE_FUNCTIONS_NOT_RETURNING:
         FUNCTIONS_NOT_RETURNING[_name] = None
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to