[pypy-svn] r69662 - in pypy/trunk/pypy/module/oracle: . test

afa at codespeak.net afa at codespeak.net
Thu Nov 26 18:35:19 CET 2009


Author: afa
Date: Thu Nov 26 18:35:18 2009
New Revision: 69662

Modified:
   pypy/trunk/pypy/module/oracle/__init__.py
   pypy/trunk/pypy/module/oracle/interp_variable.py
   pypy/trunk/pypy/module/oracle/test/test_stringvar.py
Log:
Fix check of maximum allowed size for unicode values


Modified: pypy/trunk/pypy/module/oracle/__init__.py
==============================================================================
--- pypy/trunk/pypy/module/oracle/__init__.py	(original)
+++ pypy/trunk/pypy/module/oracle/__init__.py	Thu Nov 26 18:35:18 2009
@@ -6,9 +6,9 @@
     interpleveldefs = {
         'connect': 'interp_connect.W_Connection',
         'Connection': 'interp_connect.W_Connection',
-        'UNICODE': 'interp_variable.VT_NationalCharString',
         'NUMBER': 'interp_variable.VT_Float',
         'STRING': 'interp_variable.VT_String',
+        'UNICODE': 'interp_variable.VT_NationalCharString',
         'DATETIME': 'interp_variable.VT_DateTime',
         'DATE': 'interp_variable.VT_Date',
         'TIMESTAMP': 'interp_variable.VT_Timestamp',
@@ -17,6 +17,7 @@
         'LONG_STRING': 'interp_variable.VT_LongString',
         'LONG_BINARY': 'interp_variable.VT_LongBinary',
         'FIXED_CHAR': 'interp_variable.VT_FixedChar',
+        'FIXED_UNICODE': 'interp_variable.VT_FixedNationalChar',
         'CURSOR': 'interp_variable.VT_Cursor',
         'BLOB': 'interp_variable.VT_BLOB',
         'CLOB': 'interp_variable.VT_CLOB',

Modified: pypy/trunk/pypy/module/oracle/interp_variable.py
==============================================================================
--- pypy/trunk/pypy/module/oracle/interp_variable.py	(original)
+++ pypy/trunk/pypy/module/oracle/interp_variable.py	Thu Nov 26 18:35:18 2009
@@ -528,10 +528,16 @@
                     space.wrap("expecting unicode data"))
 
         try:
-            if buf.size > self.environment.maxStringBytes:
-                raise OperationError(
-                    space.w_ValueError,
-                    space.wrap("string data too large"))
+            if wantBytes:
+                if buf.size > self.environment.maxStringBytes:
+                    raise OperationError(
+                        space.w_ValueError,
+                        space.wrap("string data too large"))
+            else:
+                if buf.size > config.MAX_STRING_CHARS * 2:
+                    raise OperationError(
+                        space.w_ValueError,
+                        space.wrap("unicode data too large"))
 
             # ensure that the buffer is large enough
             if buf.size > self.bufferSize:

Modified: pypy/trunk/pypy/module/oracle/test/test_stringvar.py
==============================================================================
--- pypy/trunk/pypy/module/oracle/test/test_stringvar.py	(original)
+++ pypy/trunk/pypy/module/oracle/test/test_stringvar.py	Thu Nov 26 18:35:18 2009
@@ -155,3 +155,11 @@
         data, = cur.fetchone()
         assert data == value
 
+    def test_large_unicode(self):
+        cur = self.cnx.cursor()
+        var = cur.var(oracle.UNICODE)
+        value = u"1234567890" * 400
+        var.setvalue(0, value)
+        assert var.getvalue() == value
+        value += "X"
+        raises(ValueError, var.setvalue, 0, value)



More information about the Pypy-commit mailing list