[pypy-svn] r69356 - pypy/trunk/pypy/module/oracle

afa at codespeak.net afa at codespeak.net
Tue Nov 17 18:43:49 CET 2009


Author: afa
Date: Tue Nov 17 18:43:49 2009
New Revision: 69356

Modified:
   pypy/trunk/pypy/module/oracle/__init__.py
   pypy/trunk/pypy/module/oracle/interp_cursor.py
   pypy/trunk/pypy/module/oracle/interp_error.py
   pypy/trunk/pypy/module/oracle/interp_variable.py
Log:
Expose the STRING variable type.
Now all tests pass in cx_Oracle's in Cursor.py.

I'm not sure that "variableTypeByTypedef" will translate though.
But how can I get the interp-level class from its applevel object?


Modified: pypy/trunk/pypy/module/oracle/__init__.py
==============================================================================
--- pypy/trunk/pypy/module/oracle/__init__.py	(original)
+++ pypy/trunk/pypy/module/oracle/__init__.py	Tue Nov 17 18:43:49 2009
@@ -7,6 +7,7 @@
         'connect': 'interp_connect.W_Connection',
         'UNICODE': 'interp_variable.VT_NationalCharString',
         'NUMBER': 'interp_variable.VT_Float',
+        'STRING': 'interp_variable.VT_String',
         'Variable': 'interp_variable.W_Variable',
     }
 

Modified: pypy/trunk/pypy/module/oracle/interp_cursor.py
==============================================================================
--- pypy/trunk/pypy/module/oracle/interp_cursor.py	(original)
+++ pypy/trunk/pypy/module/oracle/interp_cursor.py	Tue Nov 17 18:43:49 2009
@@ -366,6 +366,8 @@
         for i, w_value in enumerate(space.viewiterable(w_vars)):
             if i < len(self.bindList):
                 origVar = self.bindList[i]
+                if space.is_w(origVar, space.w_None):
+                    origVar = None
             else:
                 origVar = None
             newVar = self._setBindVariableHelper(space, w_value, origVar,

Modified: pypy/trunk/pypy/module/oracle/interp_error.py
==============================================================================
--- pypy/trunk/pypy/module/oracle/interp_error.py	(original)
+++ pypy/trunk/pypy/module/oracle/interp_error.py	Tue Nov 17 18:43:49 2009
@@ -17,7 +17,6 @@
         self.w_NotSupportedError = get('NotSupportedError')
         self.w_IntegrityError = get('IntegrityError')
         self.w_Variable = get('Variable')
-        self.w_NUMBER = get('NUMBER')
 
         w_import = space.builtin.get('__import__')
         w_decimal = space.call(w_import, space.newlist(

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	Tue Nov 17 18:43:49 2009
@@ -579,11 +579,15 @@
 class VT_Object(W_Variable):
     pass
 
-for cls in (VT_NationalCharString, VT_String):
+variableTypeByTypedef = {}
+for name, cls in globals().items():
+    if not name.startswith('VT_') or not isinstance(cls, type):
+        continue
     cls.typedef = TypeDef(
         cls.__name__, W_Variable.typedef,
         )
-    
+    variableTypeByTypedef[cls.typedef] = cls
+
 def _typeByOracleDescriptor(param, environment):
     # retrieve datatype of the parameter
     attrptr = lltype.malloc(rffi.CArrayPtr(roci.ub2).TO, 1, flavor='raw')
@@ -669,8 +673,8 @@
 def typeByPythonType(space, cursor, w_type):
     """Return a variable type given a Python type object"""
     moduledict = get(space)
-    if space.is_w(w_type, moduledict.w_NUMBER):
-        return VT_Float
+    if w_type.instancetypedef in variableTypeByTypedef:
+        return variableTypeByTypedef[w_type.instancetypedef]
     if space.is_w(w_type, space.w_int):
         return VT_Integer
     raise OperationError(



More information about the Pypy-commit mailing list