[pypy-commit] pypy reflex-support: merge default into branch

wlav noreply at buildbot.pypy.org
Thu May 1 09:26:19 CEST 2014


Author: Wim Lavrijsen <WLavrijsen at lbl.gov>
Branch: reflex-support
Changeset: r71124:d37dab820a6a
Date: 2014-04-30 23:46 -0700
http://bitbucket.org/pypy/pypy/changeset/d37dab820a6a/

Log:	merge default into branch

diff too long, truncating to 2000 out of 7401 lines

diff --git a/lib-python/2.7/cProfile.py b/lib-python/2.7/cProfile.py
--- a/lib-python/2.7/cProfile.py
+++ b/lib-python/2.7/cProfile.py
@@ -161,7 +161,7 @@
 # ____________________________________________________________
 
 def main():
-    import os, sys
+    import os, sys, types
     from optparse import OptionParser
     usage = "cProfile.py [-o output_file_path] [-s sort] scriptfile [arg] ..."
     parser = OptionParser(usage=usage)
@@ -184,12 +184,10 @@
         sys.path.insert(0, os.path.dirname(progname))
         with open(progname, 'rb') as fp:
             code = compile(fp.read(), progname, 'exec')
-        globs = {
-            '__file__': progname,
-            '__name__': '__main__',
-            '__package__': None,
-        }
-        runctx(code, globs, None, options.outfile, options.sort)
+        mainmod = types.ModuleType('__main__')
+        mainmod.__file__ = progname
+        mainmod.__package__ = None
+        runctx(code, mainmod.__dict__, None, options.outfile, options.sort)
     else:
         parser.print_usage()
     return parser
diff --git a/pypy/doc/config/objspace.usemodules.oracle.txt b/pypy/doc/config/objspace.usemodules.oracle.txt
deleted file mode 100644
--- a/pypy/doc/config/objspace.usemodules.oracle.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-Use the 'oracle' module.
-This module is off by default, requires oracle client installed.
diff --git a/pypy/doc/cpython_differences.rst b/pypy/doc/cpython_differences.rst
--- a/pypy/doc/cpython_differences.rst
+++ b/pypy/doc/cpython_differences.rst
@@ -58,7 +58,6 @@
     math
     mmap
     operator
-    oracle
     parser
     posix
     pyexpat
diff --git a/pypy/doc/release-2.3.0.rst b/pypy/doc/release-2.3.0.rst
--- a/pypy/doc/release-2.3.0.rst
+++ b/pypy/doc/release-2.3.0.rst
@@ -92,7 +92,7 @@
 * Support for OpenBSD 
 
 * Code cleanup: we continue to prune out old and unused code, and to refactor
-  large parts of the codebase. We have sepearated rpython from the PyPy python
+  large parts of the codebase. We have separated rpython from the PyPy python
   interpreter, and rpython is seeing use in other dynamic language projects.
 
 * Support for precompiled headers in the build process for MSVC
diff --git a/pypy/doc/whatsnew-2.3.0.rst b/pypy/doc/whatsnew-2.3.0.rst
--- a/pypy/doc/whatsnew-2.3.0.rst
+++ b/pypy/doc/whatsnew-2.3.0.rst
@@ -152,3 +152,12 @@
 
 .. branch: small-unroll-improvements
 Improve optimization of small allocation-heavy loops in the JIT
+
+.. branch: reflex-support
+   
+.. branch: asmosoinio/fixed-pip-installation-url-github-githu-1398674840188
+
+.. branch: lexer_token_position_class
+
+.. branch: refactor-buffer-api
+Properly implement old/new buffer API for objects and start work on replacing bufferstr usage
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -3,12 +3,6 @@
 =======================
 
 .. this is a revision shortly after release-2.3.x
-.. startrev: ba569fe1efdb
+.. startrev: 0524dae88c75
 
-.. branch: small-unroll-improvements
-Improve optimiziation of small allocation-heavy loops in the JIT
 
-.. branch: reflex-support
-
-.. branch: refactor-buffer-api
-Properly implement old/new buffer API for objects and start work on replacing bufferstr usage
diff --git a/pypy/interpreter/argument.py b/pypy/interpreter/argument.py
--- a/pypy/interpreter/argument.py
+++ b/pypy/interpreter/argument.py
@@ -321,10 +321,11 @@
                 limit -= len(self.keyword_names_w)
             for i in range(len(self.keywords)):
                 if i < limit:
-                    w_key = space.wrap(self.keywords[i])
+                    key = self.keywords[i]
+                    space.setitem_str(w_kwds, key, self.keywords_w[i])
                 else:
                     w_key = self.keyword_names_w[i - limit]
-                space.setitem(w_kwds, w_key, self.keywords_w[i])
+                    space.setitem(w_kwds, w_key, self.keywords_w[i])
         return w_args, w_kwds
 
 # JIT helper functions
@@ -416,10 +417,10 @@
                 break
         else:
             if i < limit:
-                w_key = space.wrap(keywords[i])
+                space.setitem_str(w_kwds, keywords[i], keywords_w[i])
             else:
                 w_key = keyword_names_w[i - limit]
-            space.setitem(w_kwds, w_key, keywords_w[i])
+                space.setitem(w_kwds, w_key, keywords_w[i])
 
 #
 # ArgErr family of exceptions raised in case of argument mismatch.
diff --git a/pypy/interpreter/test/test_argument.py b/pypy/interpreter/test/test_argument.py
--- a/pypy/interpreter/test/test_argument.py
+++ b/pypy/interpreter/test/test_argument.py
@@ -93,6 +93,7 @@
 
     def setitem(self, obj, key, value):
         obj[key] = value
+    setitem_str = setitem
 
     def getitem(self, obj, key):
         return obj[key]
diff --git a/pypy/interpreter/test/test_typedef.py b/pypy/interpreter/test/test_typedef.py
--- a/pypy/interpreter/test/test_typedef.py
+++ b/pypy/interpreter/test/test_typedef.py
@@ -387,3 +387,9 @@
         # because it's a regular method, and .__objclass__
         # differs from .im_class in case the method is
         # defined in some parent class of l's actual class
+
+    def test_func_closure(self):
+        x = 2
+        def f():
+            return x
+        assert f.__closure__[0].cell_contents is x
diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -809,6 +809,7 @@
     __dict__ = getset_func_dict,
     __defaults__ = getset_func_defaults,
     __globals__ = interp_attrproperty_w('w_func_globals', cls=Function),
+    __closure__ = GetSetProperty(Function.fget_func_closure),
     __module__ = getset___module__,
     __weakref__ = make_weakref_descr(Function),
 )
diff --git a/pypy/module/__builtin__/compiling.py b/pypy/module/__builtin__/compiling.py
--- a/pypy/module/__builtin__/compiling.py
+++ b/pypy/module/__builtin__/compiling.py
@@ -27,6 +27,7 @@
                  consts.PyCF_DONT_IMPLY_DEDENT | consts.PyCF_SOURCE_IS_UTF8):
         raise OperationError(space.w_ValueError,
                              space.wrap("compile() unrecognized flags"))
+
     if not dont_inherit:
         caller = ec.gettopframe_nohidden()
         if caller:
@@ -37,8 +38,7 @@
                              space.wrap("compile() arg 3 must be 'exec' "
                                         "or 'eval' or 'single'"))
 
-    w_ast_type = space.gettypeobject(ast.AST.typedef)
-    if space.isinstance_w(w_source, w_ast_type):
+    if space.isinstance_w(w_source, space.gettypeobject(ast.AST.typedef)):
         ast_node = space.interp_w(ast.mod, w_source)
         ast_node.sync_app_attrs(space)
         code = ec.compiler.compile_ast(ast_node, filename, mode, flags)
@@ -47,20 +47,20 @@
     if space.isinstance_w(w_source, space.w_unicode):
         w_utf_8_source = space.call_method(w_source, "encode",
                                            space.wrap("utf-8"))
-        str_ = space.str_w(w_utf_8_source)
+        source = space.str_w(w_utf_8_source)
         # This flag tells the parser to reject any coding cookies it sees.
         flags |= consts.PyCF_SOURCE_IS_UTF8
     else:
-        str_ = space.readbuf_w(w_source).as_str()
+        source = space.readbuf_w(w_source).as_str()
 
-    if '\x00' in str_:
+    if '\x00' in source:
         raise OperationError(space.w_TypeError, space.wrap(
             "compile() expected string without null bytes"))
 
     if flags & consts.PyCF_ONLY_AST:
-        code = ec.compiler.compile_to_ast(str_, filename, mode, flags)
+        code = ec.compiler.compile_to_ast(source, filename, mode, flags)
     else:
-        code = ec.compiler.compile(str_, filename, mode, flags)
+        code = ec.compiler.compile(source, filename, mode, flags)
     return space.wrap(code)
 
 
diff --git a/pypy/module/_lsprof/interp_lsprof.py b/pypy/module/_lsprof/interp_lsprof.py
--- a/pypy/module/_lsprof/interp_lsprof.py
+++ b/pypy/module/_lsprof/interp_lsprof.py
@@ -189,38 +189,32 @@
                 subentry._stop(tt, it)
 
 
- at jit.elidable_promote()
 def create_spec_for_method(space, w_function, w_type):
-    w_function = w_function
+    class_name = None
     if isinstance(w_function, Function):
         name = w_function.name
+        # try to get the real class that defines the method,
+        # which is a superclass of the class of the instance
+        from pypy.objspace.std.typeobject import W_TypeObject   # xxx
+        if isinstance(w_type, W_TypeObject):
+            w_realclass, _ = space.lookup_in_type_where(w_type, name)
+            if isinstance(w_realclass, W_TypeObject):
+                class_name = w_realclass.get_module_type_name()
     else:
         name = '?'
-    # try to get the real class that defines the method,
-    # which is a superclass of the class of the instance
-    from pypy.objspace.std.typeobject import W_TypeObject   # xxx
-    class_name = w_type.getname(space)    # if the rest doesn't work
-    if isinstance(w_type, W_TypeObject) and name != '?':
-        w_realclass, _ = space.lookup_in_type_where(w_type, name)
-        if isinstance(w_realclass, W_TypeObject):
-            class_name = w_realclass.get_module_type_name()
+    if class_name is None:
+        class_name = w_type.getname(space)    # if the rest doesn't work
     return "{method '%s' of '%s' objects}" % (name, class_name)
 
 
- at jit.elidable_promote()
 def create_spec_for_function(space, w_func):
-    if w_func.w_module is None:
-        module = ''
-    else:
+    if w_func.w_module is not None:
         module = space.str_w(w_func.w_module)
-        if module == '__builtin__':
-            module = ''
-        else:
-            module += '.'
-    return '{%s%s}' % (module, w_func.name)
+        if module != '__builtin__':
+            return '{%s.%s}' % (module, w_func.name)
+    return '{%s}' % w_func.name
 
 
- at jit.elidable_promote()
 def create_spec_for_object(space, w_obj):
     class_name = space.type(w_obj).getname(space)
     return "{'%s' object}" % (class_name,)
@@ -345,6 +339,7 @@
 
     def _enter_builtin_call(self, key):
         self = jit.promote(self)
+        key = jit.promote_string(key)
         entry = self._get_or_make_builtin_entry(key)
         self.current_context = ProfilerContext(self, entry)
 
@@ -353,6 +348,7 @@
         if context is None:
             return
         self = jit.promote(self)
+        key = jit.promote_string(key)
         try:
             entry = self._get_or_make_builtin_entry(key, False)
         except KeyError:
diff --git a/pypy/module/_socket/interp_socket.py b/pypy/module/_socket/interp_socket.py
--- a/pypy/module/_socket/interp_socket.py
+++ b/pypy/module/_socket/interp_socket.py
@@ -600,7 +600,8 @@
     method = getattr(W_RSocket, methodname + '_w')
     socketmethods[methodname] = interp2app(method)
 
-W_RSocket.typedef = TypeDef("_socket.socket",
+W_RSocket.typedef = TypeDef("socket",
+    __module__ = "_socket",
     __doc__ = """\
 socket([family[, type[, proto]]]) -> socket object
 
diff --git a/pypy/module/_socket/test/test_sock_app.py b/pypy/module/_socket/test/test_sock_app.py
--- a/pypy/module/_socket/test/test_sock_app.py
+++ b/pypy/module/_socket/test/test_sock_app.py
@@ -313,6 +313,11 @@
         cls.space = space
         cls.w_udir = space.wrap(str(udir))
 
+    def test_module(self):
+        import _socket
+        assert _socket.socket.__name__ == 'socket'
+        assert _socket.socket.__module__ == '_socket'
+
     def test_ntoa_exception(self):
         import _socket
         raises(_socket.error, _socket.inet_ntoa, "ab")
diff --git a/pypy/module/array/interp_array.py b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -448,6 +448,9 @@
         self.descr_delitem(space, space.newslice(w_start, w_stop,
                                                  space.w_None))
 
+    def descr_iter(self, space):
+        return space.newseqiter(self)
+
     def descr_add(self, space, w_other):
         raise NotImplementedError
 
@@ -503,6 +506,7 @@
     __setslice__ = interp2app(W_ArrayBase.descr_setslice),
     __delitem__ = interp2app(W_ArrayBase.descr_delitem),
     __delslice__ = interp2app(W_ArrayBase.descr_delslice),
+    __iter__ = interp2app(W_ArrayBase.descr_iter),
 
     __add__ = interpindirect2app(W_ArrayBase.descr_add),
     __iadd__ = interpindirect2app(W_ArrayBase.descr_inplace_add),
diff --git a/pypy/module/array/test/test_array.py b/pypy/module/array/test/test_array.py
--- a/pypy/module/array/test/test_array.py
+++ b/pypy/module/array/test/test_array.py
@@ -697,6 +697,8 @@
         for i in a:
             b.append(i)
         assert repr(b) == "array('i', [1, 2, 3])"
+        assert hasattr(b, '__iter__')
+        assert next(b.__iter__()) == 1
 
     def test_lying_iterable(self):
         class lier(object):
diff --git a/pypy/module/cpyext/patches/cx_Oracle.patch b/pypy/module/cpyext/patches/cx_Oracle.patch
deleted file mode 100644
--- a/pypy/module/cpyext/patches/cx_Oracle.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-Index: cx_Oracle.c
-===================================================================
---- cx_Oracle.c	(r�vision 333)
-+++ cx_Oracle.c	(copie de travail)
-@@ -65,6 +65,13 @@
- #define CXORA_BASE_EXCEPTION    PyExc_StandardError
- #endif
- 
-+// define missing PyDateTime_DELTA macros
-+#ifndef PYPY_VERSION
-+PyDateTime_DELTA_GET_DAYS(o)         (((PyDateTime_Delta*)o)->days)
-+PyDateTime_DELTA_GET_SECONDS(o)      (((PyDateTime_Delta*)o)->seconds)
-+PyDateTime_DELTA_GET_MICROSECONDS(o) (((PyDateTime_Delta*)o)->microseconds)
-+#endif
-+
- // define simple construct for determining endianness of the platform
- // Oracle uses native encoding with OCI_UTF16 but bails when a BOM is written
- #define IS_LITTLE_ENDIAN (int)*(unsigned char*) &one
-@@ -138,6 +145,7 @@
-     *exception = PyErr_NewException(buffer, baseException, NULL);
-     if (!*exception)
-         return -1;
-+    Py_INCREF(*exception);
-     return PyModule_AddObject(module, name, *exception);
- }
- 
-Index: IntervalVar.c
-===================================================================
---- IntervalVar.c	(r�vision 333)
-+++ IntervalVar.c	(copie de travail)
-@@ -121,7 +121,7 @@
-     unsigned pos,                       // array position to set
-     PyObject *value)                    // value to set
- {
--    sb4 hours, minutes, seconds;
-+    sb4 days, hours, minutes, seconds, microseconds;
-     PyDateTime_Delta *delta;
-     sword status;
- 
-@@ -131,13 +131,16 @@
-     }
- 
-     delta = (PyDateTime_Delta*) value;
--    hours = (sb4) delta->seconds / 3600;
--    seconds = delta->seconds - hours * 3600;
-+    days = PyDateTime_DELTA_GET_DAYS(delta);
-+    seconds = PyDateTime_DELTA_GET_SECONDS(delta);
-+    hours = (sb4) seconds / 3600;
-+    seconds -= hours * 3600;
-     minutes = (sb4) seconds / 60;
-     seconds -= minutes * 60;
-+    microseconds = PyDateTime_DELTA_GET_MICROSECONDS(delta);
-     status = OCIIntervalSetDaySecond(var->environment->handle,
--            var->environment->errorHandle, delta->days, hours, minutes,
--            seconds, delta->microseconds, var->data[pos]);
-+            var->environment->errorHandle, days, hours, minutes,
-+            seconds, microseconds, var->data[pos]);
-     if (Environment_CheckForError(var->environment, status,
-                 "IntervalVar_SetValue()") < 0)
-         return -1;
diff --git a/pypy/module/micronumpy/descriptor.py b/pypy/module/micronumpy/descriptor.py
--- a/pypy/module/micronumpy/descriptor.py
+++ b/pypy/module/micronumpy/descriptor.py
@@ -1,3 +1,4 @@
+import string
 from pypy.interpreter.argument import Arguments
 from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.error import OperationError, oefmt
@@ -28,9 +29,11 @@
 
     if not space.is_none(out):
         return out
-    dtype = w_arr_list[0].get_dtype()
-    for w_arr in w_arr_list[1:]:
-        dtype = find_binop_result_dtype(space, dtype, w_arr.get_dtype())
+    dtype = None
+    for w_arr in w_arr_list:
+        if not space.is_none(w_arr):
+            dtype = find_binop_result_dtype(space, dtype, w_arr.get_dtype())
+    assert dtype is not None
     out = base.W_NDimArray.from_shape(space, shape, dtype)
     return out
 
@@ -468,6 +471,23 @@
         return dtype_from_list(space, w_lst, True)
 
 
+def _check_for_commastring(s):
+    if s[0] in string.digits or s[0] in '<>=|' and s[1] in string.digits:
+        return True
+    if s[0] == '(' and s[1] == ')' or s[0] in '<>=|' and s[1] == '(' and s[2] == ')':
+        return True
+    sqbracket = 0
+    for c in s:
+        if c == ',':
+            if sqbracket == 0:
+                return True
+        elif c == '[':
+            sqbracket += 1
+        elif c == ']':
+            sqbracket -= 1
+    return False
+
+
 def descr__new__(space, w_subtype, w_dtype, w_align=None, w_copy=None, w_shape=None):
     # w_align and w_copy are necessary for pickling
     cache = get_dtype_cache(space)
@@ -497,7 +517,7 @@
         return w_dtype
     elif space.isinstance_w(w_dtype, space.w_str):
         name = space.str_w(w_dtype)
-        if ',' in name:
+        if _check_for_commastring(name):
             return dtype_from_spec(space, w_dtype)
         cname = name[1:] if name[0] == NPY.OPPBYTE else name
         try:
@@ -508,7 +528,7 @@
             if name[0] == NPY.OPPBYTE:
                 dtype = dtype.descr_newbyteorder(space)
             return dtype
-        if name[0] in 'VSUc' or name[0] in '<>=|' and name[1] in 'VSUc':
+        if name[0] in 'VSUca' or name[0] in '<>=|' and name[1] in 'VSUca':
             return variable_dtype(space, name)
         raise oefmt(space.w_TypeError, 'data type "%s" not understood', name)
     elif space.isinstance_w(w_dtype, space.w_list):
@@ -589,7 +609,7 @@
             raise oefmt(space.w_TypeError, "data type not understood")
     if char == NPY.CHARLTR:
         return new_string_dtype(space, 1, NPY.CHARLTR)
-    elif char == NPY.STRINGLTR:
+    elif char == NPY.STRINGLTR or char == NPY.STRINGLTR2:
         return new_string_dtype(space, size)
     elif char == NPY.UNICODELTR:
         return new_unicode_dtype(space, size)
diff --git a/pypy/module/micronumpy/loop.py b/pypy/module/micronumpy/loop.py
--- a/pypy/module/micronumpy/loop.py
+++ b/pypy/module/micronumpy/loop.py
@@ -606,25 +606,34 @@
                             reds = 'auto')
 
 def clip(space, arr, shape, min, max, out):
+    assert min or max
     arr_iter, arr_state = arr.create_iter(shape)
+    if min is not None:
+        min_iter, min_state = min.create_iter(shape)
+    else:
+        min_iter, min_state = None, None
+    if max is not None:
+        max_iter, max_state = max.create_iter(shape)
+    else:
+        max_iter, max_state = None, None
+    out_iter, out_state = out.create_iter(shape)
+    shapelen = len(shape)
     dtype = out.get_dtype()
-    shapelen = len(shape)
-    min_iter, min_state = min.create_iter(shape)
-    max_iter, max_state = max.create_iter(shape)
-    out_iter, out_state = out.create_iter(shape)
     while not arr_iter.done(arr_state):
         clip_driver.jit_merge_point(shapelen=shapelen, dtype=dtype)
         w_v = arr_iter.getitem(arr_state).convert_to(space, dtype)
-        w_min = min_iter.getitem(min_state).convert_to(space, dtype)
-        w_max = max_iter.getitem(max_state).convert_to(space, dtype)
-        if dtype.itemtype.lt(w_v, w_min):
-            w_v = w_min
-        elif dtype.itemtype.gt(w_v, w_max):
-            w_v = w_max
+        arr_state = arr_iter.next(arr_state)
+        if min_iter is not None:
+            w_min = min_iter.getitem(min_state).convert_to(space, dtype)
+            if dtype.itemtype.lt(w_v, w_min):
+                w_v = w_min
+            min_state = min_iter.next(min_state)
+        if max_iter is not None:
+            w_max = max_iter.getitem(max_state).convert_to(space, dtype)
+            if dtype.itemtype.gt(w_v, w_max):
+                w_v = w_max
+            max_state = max_iter.next(max_state)
         out_iter.setitem(out_state, w_v)
-        arr_state = arr_iter.next(arr_state)
-        min_state = min_iter.next(min_state)
-        max_state = max_iter.next(max_state)
         out_state = out_iter.next(out_state)
 
 round_driver = jit.JitDriver(name='numpy_round_driver',
diff --git a/pypy/module/micronumpy/ndarray.py b/pypy/module/micronumpy/ndarray.py
--- a/pypy/module/micronumpy/ndarray.py
+++ b/pypy/module/micronumpy/ndarray.py
@@ -593,17 +593,25 @@
     def descr_choose(self, space, w_choices, w_out=None, w_mode=None):
         return choose(space, self, w_choices, w_out, w_mode)
 
-    def descr_clip(self, space, w_min, w_max, w_out=None):
+    def descr_clip(self, space, w_min=None, w_max=None, w_out=None):
+        if space.is_none(w_min):
+            w_min = None
+        else:
+            w_min = convert_to_array(space, w_min)
+        if space.is_none(w_max):
+            w_max = None
+        else:
+            w_max = convert_to_array(space, w_max)
         if space.is_none(w_out):
             w_out = None
         elif not isinstance(w_out, W_NDimArray):
             raise OperationError(space.w_TypeError, space.wrap(
                 "return arrays must be of ArrayType"))
-        min = convert_to_array(space, w_min)
-        max = convert_to_array(space, w_max)
-        shape = shape_agreement_multiple(space, [self, min, max, w_out])
-        out = descriptor.dtype_agreement(space, [self, min, max], shape, w_out)
-        loop.clip(space, self, shape, min, max, out)
+        if not w_min and not w_max:
+            raise oefmt(space.w_ValueError, "One of max or min must be given.")
+        shape = shape_agreement_multiple(space, [self, w_min, w_max, w_out])
+        out = descriptor.dtype_agreement(space, [self, w_min, w_max], shape, w_out)
+        loop.clip(space, self, shape, w_min, w_max, out)
         return out
 
     def descr_get_ctypes(self, space):
diff --git a/pypy/module/micronumpy/test/test_dtypes.py b/pypy/module/micronumpy/test/test_dtypes.py
--- a/pypy/module/micronumpy/test/test_dtypes.py
+++ b/pypy/module/micronumpy/test/test_dtypes.py
@@ -191,6 +191,9 @@
         d = dtype('S5')
         assert repr(d) == "dtype('S5')"
         assert str(d) == "|S5"
+        d = dtype('a5')
+        assert repr(d) == "dtype('S5')"
+        assert str(d) == "|S5"
         d = dtype('U5')
         assert repr(d) == "dtype('%sU5')" % b
         assert str(d) == "%sU5" % b
diff --git a/pypy/module/micronumpy/test/test_ndarray.py b/pypy/module/micronumpy/test/test_ndarray.py
--- a/pypy/module/micronumpy/test/test_ndarray.py
+++ b/pypy/module/micronumpy/test/test_ndarray.py
@@ -2229,7 +2229,13 @@
     def test_clip(self):
         from numpypy import array
         a = array([1, 2, 17, -3, 12])
+        exc = raises(ValueError, a.clip)
+        assert str(exc.value) == "One of max or min must be given."
         assert (a.clip(-2, 13) == [1, 2, 13, -2, 12]).all()
+        assert (a.clip(min=-2) == [1, 2, 17, -2, 12]).all()
+        assert (a.clip(min=-2, max=None) == [1, 2, 17, -2, 12]).all()
+        assert (a.clip(max=13) == [1, 2, 13, -3, 12]).all()
+        assert (a.clip(min=None, max=13) == [1, 2, 13, -3, 12]).all()
         assert (a.clip(-1, 1, out=None) == [1, 1, 1, -1, 1]).all()
         assert (a == [1, 2, 17, -3, 12]).all()
         assert (a.clip(-1, [1, 2, 3, 4, 5]) == [1, 2, 3, -1, 5]).all()
diff --git a/pypy/module/micronumpy/test/test_ufuncs.py b/pypy/module/micronumpy/test/test_ufuncs.py
--- a/pypy/module/micronumpy/test/test_ufuncs.py
+++ b/pypy/module/micronumpy/test/test_ufuncs.py
@@ -310,7 +310,7 @@
             assert math.isnan(fmod(v, 2))
 
     def test_minimum(self):
-        from numpypy import array, minimum
+        from numpypy import array, minimum, nan, isnan
 
         a = array([-5.0, -0.0, 1.0])
         b = array([ 3.0, -2.0,-3.0])
@@ -318,8 +318,12 @@
         for i in range(3):
             assert c[i] == min(a[i], b[i])
 
+        arg1 = array([0, nan, nan])
+        arg2 = array([nan, 0, nan])
+        assert isnan(minimum(arg1, arg2)).all()
+
     def test_maximum(self):
-        from numpypy import array, maximum
+        from numpypy import array, maximum, nan, isnan
 
         a = array([-5.0, -0.0, 1.0])
         b = array([ 3.0, -2.0,-3.0])
@@ -327,6 +331,10 @@
         for i in range(3):
             assert c[i] == max(a[i], b[i])
 
+        arg1 = array([0, nan, nan])
+        arg2 = array([nan, 0, nan])
+        assert isnan(maximum(arg1, arg2)).all()
+
         x = maximum(2, 3)
         assert x == 3
         assert isinstance(x, (int, long))
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -705,20 +705,20 @@
         return math.fabs(v)
 
     @simple_binary_op
+    def max(self, v1, v2):
+        return v1 if v1 >= v2 or rfloat.isnan(v1) else v2
+
+    @simple_binary_op
+    def min(self, v1, v2):
+        return v1 if v1 <= v2 or rfloat.isnan(v1) else v2
+
+    @simple_binary_op
     def fmax(self, v1, v2):
-        if rfloat.isnan(v2):
-            return v1
-        elif rfloat.isnan(v1):
-            return v2
-        return max(v1, v2)
+        return v1 if v1 >= v2 or rfloat.isnan(v2) else v2
 
     @simple_binary_op
     def fmin(self, v1, v2):
-        if rfloat.isnan(v2):
-            return v1
-        elif rfloat.isnan(v1):
-            return v2
-        return min(v1, v2)
+        return v1 if v1 <= v2 or rfloat.isnan(v2) else v2
 
     @simple_binary_op
     def fmod(self, v1, v2):
diff --git a/pypy/module/micronumpy/ufuncs.py b/pypy/module/micronumpy/ufuncs.py
--- a/pypy/module/micronumpy/ufuncs.py
+++ b/pypy/module/micronumpy/ufuncs.py
@@ -477,6 +477,8 @@
         promote_bools=False):
     if dt2 is None:
         return dt1
+    if dt1 is None:
+        return dt2
     # dt1.num should be <= dt2.num
     if dt1.num > dt2.num:
         dt1, dt2 = dt2, dt1
diff --git a/pypy/module/oracle/__init__.py b/pypy/module/oracle/__init__.py
deleted file mode 100644
--- a/pypy/module/oracle/__init__.py
+++ /dev/null
@@ -1,54 +0,0 @@
-from pypy.interpreter.mixedmodule import MixedModule
-
-class Module(MixedModule):
-    applevel_name = 'cx_Oracle'
-
-    interpleveldefs = {
-        'connect': 'interp_connect.W_Connection',
-        'Connection': 'interp_connect.W_Connection',
-        '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',
-        'INTERVAL': 'interp_variable.VT_Interval',
-        'BINARY': 'interp_variable.VT_Binary',
-        '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',
-        'OBJECT': 'interp_variable.VT_Object',
-        'Variable': 'interp_variable.W_Variable',
-        'SessionPool': 'interp_pool.W_SessionPool',
-    }
-
-    appleveldefs = {
-        'version': 'app_oracle.version',
-        'paramstyle': 'app_oracle.paramstyle',
-        'makedsn': 'app_oracle.makedsn',
-        'TimestampFromTicks': 'app_oracle.TimestampFromTicks',
-    }
-    for name in """DataError DatabaseError Error IntegrityError InterfaceError
-                   InternalError NotSupportedError OperationalError
-                   ProgrammingError Warning""".split():
-        appleveldefs[name] = "app_oracle.%s" % (name,)
-
-    def startup(self, space):
-        from pypy.module.oracle.interp_error import get
-        state = get(space)
-        state.startup(space)
-        (state.w_DecimalType,
-         state.w_DateTimeType, state.w_DateType, state.w_TimedeltaType,
-         ) = space.fixedview(space.appexec([], """():
-             import decimal, datetime
-             return (decimal.Decimal,
-                     datetime.datetime, datetime.date, datetime.timedelta)
-        """))
-        space.setattr(space.wrap(self),
-                      space.wrap("Timestamp"), state.w_DateTimeType)
-        space.setattr(space.wrap(self),
-                      space.wrap("Date"), state.w_DateType)
diff --git a/pypy/module/oracle/app_oracle.py b/pypy/module/oracle/app_oracle.py
deleted file mode 100644
--- a/pypy/module/oracle/app_oracle.py
+++ /dev/null
@@ -1,42 +0,0 @@
-version = '5.0.0'
-paramstyle = 'named'
-
-class Warning(StandardError):
-    pass
-
-class Error(StandardError):
-    pass
-
-class InterfaceError(Error):
-    pass
-
-class DatabaseError(Error):
-    pass
-
-class DataError(DatabaseError):
-    pass
-
-class OperationalError(DatabaseError):
-    pass
-
-class IntegrityError(DatabaseError):
-    pass
-
-class InternalError(DatabaseError):
-    pass
-
-class ProgrammingError(DatabaseError):
-    pass
-
-class NotSupportedError(DatabaseError):
-    pass
-
-
-def makedsn(host, port, sid):
-    return ("(DESCRIPTION=(ADDRESS_LIST=(ADDRESS="
-            "(PROTOCOL=TCP)(HOST=%s)(PORT=%s)))"
-            "(CONNECT_DATA=(SID=%s)))" % (host, port, sid))
-
-def TimestampFromTicks(*args):
-    import datetime
-    return datetime.datetime.fromtimestamp(*args)
diff --git a/pypy/module/oracle/config.py b/pypy/module/oracle/config.py
deleted file mode 100644
--- a/pypy/module/oracle/config.py
+++ /dev/null
@@ -1,54 +0,0 @@
-from rpython.rtyper.lltypesystem import rffi, lltype
-from pypy.module.oracle import roci
-
-WITH_UNICODE = False
-
-MAX_STRING_CHARS = 4000
-MAX_BINARY_BYTES = 4000
-
-if WITH_UNICODE:
-    CHARSETID = roci.OCI_UTF16ID
-    BYTES_PER_CHAR = 2
-    def string_w(space, w_obj):
-        return space.unicode_w(w_obj)
-else:
-    def string_w(space, w_obj):
-        return space.str_w(w_obj)
-
-    def w_string(space, buf, len=-1):
-        #assert type(len) is int
-        if len < 0:
-            return space.wrap(rffi.charp2str(buf))
-        else:
-            return space.wrap(rffi.charpsize2str(buf, len))
-    CHARSETID = 0
-    BYTES_PER_CHAR = 1
-
-    class StringBuffer:
-        "Fill a char* buffer with data, suitable to pass to Oracle functions"
-        def __init__(self):
-            self.ptr = lltype.nullptr(roci.oratext.TO)
-            self.size = 0
-
-        def fill(self, space, w_value):
-            if w_value is None or space.is_w(w_value, space.w_None):
-                self.clear()
-            else:
-                strvalue = space.str_w(w_value)
-                self.ptr = rffi.str2charp(strvalue)
-                self.size = len(strvalue)
-
-        def fill_with_unicode(self, space, w_value):
-            if w_value is None or space.is_w(w_value, space.w_None):
-                self.clear()
-            else:
-                # XXX ucs2 only probably
-                univalue = space.unicode_w(w_value)
-                self.ptr = rffi.cast(roci.oratext, rffi.unicode2wcharp(univalue))
-                self.size = len(univalue) * 2
-
-        def clear(self):
-            if self.ptr:
-                rffi.free_charp(self.ptr)
-                self.ptr = lltype.nullptr(roci.oratext.TO)
-            self.size = 0
diff --git a/pypy/module/oracle/conftest.py b/pypy/module/oracle/conftest.py
deleted file mode 100644
--- a/pypy/module/oracle/conftest.py
+++ /dev/null
@@ -1,9 +0,0 @@
-import os
-
-def pytest_addoption(parser):
-    group = parser.getgroup("Oracle module options")
-    group.addoption('--oracle-home', dest="oracle_home",
-                    help="Home directory of Oracle client installation",
-                    default=os.environ.get("ORACLE_HOME"))
-    group.addoption('--oracle-connect', dest="oracle_connect",
-                    help="connect string (user/pwd at db) used for tests")
diff --git a/pypy/module/oracle/interp_connect.py b/pypy/module/oracle/interp_connect.py
deleted file mode 100644
--- a/pypy/module/oracle/interp_connect.py
+++ /dev/null
@@ -1,551 +0,0 @@
-from pypy.interpreter.baseobjspace import W_Root
-from pypy.interpreter.gateway import unwrap_spec
-from pypy.interpreter.typedef import (TypeDef, interp_attrproperty_w,
-                                      GetSetProperty)
-from pypy.interpreter.gateway import interp2app
-from pypy.interpreter.error import OperationError
-from rpython.rtyper.lltypesystem import rffi, lltype
-
-from pypy.module.oracle import roci, interp_error
-from pypy.module.oracle.config import string_w, StringBuffer, MAX_STRING_CHARS
-from pypy.module.oracle.interp_environ import Environment
-from pypy.module.oracle.interp_cursor import W_Cursor
-from pypy.module.oracle.interp_pool import W_SessionPool
-from pypy.module.oracle.interp_variable import VT_String
-
-
-class W_Connection(W_Root):
-    def __init__(self):
-        self.commitMode = roci.OCI_DEFAULT
-        self.environment = None
-        self.autocommit = False
-
-        self.sessionHandle = lltype.nullptr(roci.OCISession.TO)
-        self.serverHandle = lltype.nullptr(roci.OCIServer.TO)
-
-        self.w_inputTypeHandler = None
-        self.w_outputTypeHandler = None
-
-        self.w_version = None
-        self.release = False
-
-
-    @unwrap_spec(mode=int, handle=int,
-                 threaded=bool, twophase=bool, events=bool,
-                 purity=bool)
-    def descr_new(space, w_subtype,
-                  w_user=None,
-                  w_password=None,
-                  w_dsn=None,
-                  mode=roci.OCI_DEFAULT,
-                  handle=0,         # XXX should be a ptr type
-                  w_pool=None,
-                  threaded=False,
-                  twophase=False,
-                  events=False,
-                  w_cclass=None,
-                  purity=0,
-                  w_newpassword=None):
-        self = space.allocate_instance(W_Connection, w_subtype)
-        W_Connection.__init__(self)
-
-        # set up the environment
-        if w_pool:
-            pool = space.interp_w(W_SessionPool, w_pool)
-            self.environment = pool.environment.clone()
-        else:
-            pool = None
-            self.environment = Environment.create(space, threaded, events)
-
-        self.w_username = w_user
-        self.w_password = w_password
-        self.w_tnsentry = w_dsn
-
-        # perform some parsing, if necessary
-        if (self.w_username and not self.w_password and
-            space.is_true(space.contains(self.w_username, space.wrap('/')))):
-            (self.w_username, self.w_password) = space.listview(
-                space.call_method(self.w_username, 'split',
-                                  space.wrap('/'), space.wrap(1)))
-
-        if (self.w_password and not self.w_tnsentry and
-            space.is_true(space.contains(self.w_password, space.wrap('@')))):
-            (self.w_password, self.w_tnsentry) = space.listview(
-                space.call_method(self.w_password, 'split',
-                                  space.wrap('@'), space.wrap(1)))
-
-        if pool or w_cclass is not None:
-            self.getConnection(space, pool, w_cclass, purity)
-        else:
-            self.connect(space, mode, twophase)
-        return space.wrap(self)
-
-    def __del__(self):
-        self.enqueue_for_destruction(self.environment.space,
-                                     W_Connection.destructor,
-                                     '__del__ method of ')
-
-    def destructor(self):
-        assert isinstance(self, W_Connection)
-        if self.release:
-            roci.OCITransRollback(
-                self.handle, self.environment.errorHandle,
-                roci.OCI_DEFAULT)
-            roci.OCISessionRelease(
-                self.handle, self.environment.errorHandle,
-                None, 0, roci.OCI_DEFAULT)
-        else:
-            if self.sessionHandle:
-                roci.OCITransRollback(
-                    self.handle, self.environment.errorHandle,
-                    roci.OCI_DEFAULT)
-                roci.OCISessionEnd(
-                    self.handle, self.environment.errorHandle,
-                    self.sessionHandle, roci.OCI_DEFAULT)
-            if self.serverHandle:
-                roci.OCIServerDetach(
-                    self.serverHandle, self.environment.errorHandle,
-                    roci.OCI_DEFAULT)
-
-    def connect(self, space, mode, twophase):
-        stringBuffer = StringBuffer()
-
-        # allocate the server handle
-        handleptr = lltype.malloc(rffi.CArrayPtr(roci.OCIServer).TO,
-                                  1, flavor='raw')
-        try:
-            status = roci.OCIHandleAlloc(
-                self.environment.handle,
-                handleptr, roci.OCI_HTYPE_SERVER, 0,
-                lltype.nullptr(rffi.CArray(roci.dvoidp)))
-            self.environment.checkForError(
-                status, "Connection_Connect(): allocate server handle")
-            self.serverHandle = handleptr[0]
-        finally:
-            lltype.free(handleptr, flavor='raw')
-
-        # attach to the server
-        stringBuffer.fill(space, self.w_tnsentry)
-        try:
-            status = roci.OCIServerAttach(
-                self.serverHandle,
-                self.environment.errorHandle,
-                stringBuffer.ptr, stringBuffer.size,
-                roci.OCI_DEFAULT)
-            self.environment.checkForError(
-                status, "Connection_Connect(): server attach")
-        finally:
-            stringBuffer.clear()
-
-        # allocate the service context handle
-        handleptr = lltype.malloc(rffi.CArrayPtr(roci.OCISvcCtx).TO,
-                                  1, flavor='raw')
-
-        try:
-            status = roci.OCIHandleAlloc(
-                self.environment.handle,
-                handleptr, roci.OCI_HTYPE_SVCCTX, 0,
-                lltype.nullptr(rffi.CArray(roci.dvoidp)))
-            self.environment.checkForError(
-                status, "Connection_Connect(): allocate service context handle")
-            self.handle = handleptr[0]
-        finally:
-            lltype.free(handleptr, flavor='raw')
-
-        # set attribute for server handle
-        status = roci.OCIAttrSet(
-            self.handle, roci.OCI_HTYPE_SVCCTX,
-            self.serverHandle, 0,
-            roci.OCI_ATTR_SERVER,
-            self.environment.errorHandle)
-        self.environment.checkForError(
-            status, "Connection_Connect(): set server handle")
-
-        # set the internal and external names; these are needed for global
-        # transactions but are limited in terms of the lengths of the strings
-        if twophase:
-            status = roci.OCIAttrSet(
-                self.serverHandle, roci.OCI_HTYPE_SERVER,
-                "cx_Oracle", 0,
-                roci.OCI_ATTR_INTERNAL_NAME,
-                self.environment.errorHandle)
-            self.environment.checkForError(
-                status, "Connection_Connect(): set internal name")
-            status = roci.OCIAttrSet(
-                self.serverHandle, roci.OCI_HTYPE_SERVER,
-                "cx_Oracle", 0,
-                roci.OCI_ATTR_EXTERNAL_NAME,
-                self.environment.errorHandle)
-            self.environment.checkForError(
-                status, "Connection_Connect(): set external name")
-
-        # allocate the session handle
-        handleptr = lltype.malloc(rffi.CArrayPtr(roci.OCISession).TO,
-                                  1, flavor='raw')
-        try:
-            status = roci.OCIHandleAlloc(
-                self.environment.handle,
-                handleptr, roci.OCI_HTYPE_SESSION, 0,
-                lltype.nullptr(rffi.CArray(roci.dvoidp)))
-            self.environment.checkForError(
-                status, "Connection_Connect(): allocate session handle")
-            self.sessionHandle = handleptr[0]
-        finally:
-            lltype.free(handleptr, flavor='raw')
-
-        credentialType = roci.OCI_CRED_EXT
-
-        # set user name in session handle
-        stringBuffer.fill(space, self.w_username)
-        try:
-            if stringBuffer.size > 0:
-                credentialType = roci.OCI_CRED_RDBMS
-                status = roci.OCIAttrSet(
-                    self.sessionHandle,
-                    roci.OCI_HTYPE_SESSION,
-                    stringBuffer.ptr, stringBuffer.size,
-                    roci.OCI_ATTR_USERNAME,
-                    self.environment.errorHandle)
-                self.environment.checkForError(
-                    status, "Connection_Connect(): set user name")
-        finally:
-            stringBuffer.clear()
-
-        # set password in session handle
-        stringBuffer.fill(space, self.w_password)
-        try:
-            if stringBuffer.size > 0:
-                credentialType = roci.OCI_CRED_RDBMS
-                status = roci.OCIAttrSet(
-                    self.sessionHandle,
-                    roci.OCI_HTYPE_SESSION,
-                    stringBuffer.ptr, stringBuffer.size,
-                    roci.OCI_ATTR_PASSWORD,
-                    self.environment.errorHandle)
-                self.environment.checkForError(
-                    status, "Connection_Connect(): set password")
-        finally:
-            stringBuffer.clear()
-
-        # set the session handle on the service context handle
-        status = roci.OCIAttrSet(
-            self.handle, roci.OCI_HTYPE_SVCCTX,
-            self.sessionHandle, 0,
-            roci.OCI_ATTR_SESSION,
-            self.environment.errorHandle)
-        self.environment.checkForError(
-            status, "Connection_Connect(): set session handle")
-    
-        # if a new password has been specified, change it which will also
-        # establish the session
-
-        # begin the session
-        status = roci.OCISessionBegin(
-            self.handle, self.environment.errorHandle,
-            self.sessionHandle, credentialType, mode)
-        try:
-            self.environment.checkForError(
-                status, "Connection_Connect(): begin session")
-        except:
-            self.sessionHandle = lltype.nullptr(roci.OCISession.TO)
-            raise
-
-    def getConnection(self, space, pool, w_cclass, purity):
-        """Get a connection using the OCISessionGet() interface
-        rather than using the low level interface for connecting."""
-
-        proxyCredentials = False
-        authInfo = lltype.nullptr(roci.OCIAuthInfo.TO)
-
-        if pool:
-            w_dbname = pool.w_name
-            mode = roci.OCI_SESSGET_SPOOL
-            if not pool.homogeneous and pool.w_username and self.w_username:
-                proxyCredentials = space.is_true(space.ne(pool.w_username, self.w_username))
-                mode |= roci.OCI_SESSGET_CREDPROXY
-        else:
-            w_dbname = self.w_tnsentry
-            mode = roci.OCI_SESSGET_STMTCACHE
-
-        stringBuffer = StringBuffer()
-
-        # set up authorization handle, if needed
-        if not pool or w_cclass or proxyCredentials:
-            # create authorization handle
-            handleptr = lltype.malloc(rffi.CArrayPtr(roci.OCIAuthInfo).TO,
-                                      1, flavor='raw')
-            try:
-                status = roci.OCIHandleAlloc(
-                    self.environment.handle,
-                    handleptr,
-                    roci.OCI_HTYPE_AUTHINFO,
-                    0, lltype.nullptr(rffi.CArray(roci.dvoidp)))
-                self.environment.checkForError(
-                    status, "Connection_GetConnection(): allocate handle")
-
-                authInfo = handleptr[0]
-            finally:
-                lltype.free(handleptr, flavor='raw')
-
-            externalCredentials = True
-
-            # set the user name, if applicable
-            stringBuffer.fill(space, self.w_username)
-            try:
-                if stringBuffer.size > 0:
-                    externalCredentials = False
-                    status = roci.OCIAttrSet(
-                        authInfo,
-                        roci.OCI_HTYPE_AUTHINFO,
-                        stringBuffer.ptr, stringBuffer.size,
-                        roci.OCI_ATTR_USERNAME,
-                        self.environment.errorHandle)
-                    self.environment.checkForError(
-                        status, "Connection_GetConnection(): set user name")
-            finally:
-                stringBuffer.clear()
-
-            # set the password, if applicable
-            stringBuffer.fill(space, self.w_password)
-            try:
-                if stringBuffer.size > 0:
-                    externalCredentials = False
-                    status = roci.OCIAttrSet(
-                        authInfo,
-                        roci.OCI_HTYPE_AUTHINFO,
-                        stringBuffer.ptr, stringBuffer.size,
-                        roci.OCI_ATTR_PASSWORD,
-                        self.environment.errorHandle)
-                    self.environment.checkForError(
-                        status, "Connection_GetConnection(): set password")
-            finally:
-                stringBuffer.clear()
-
-            # if no user name or password are set, using external credentials
-            if not pool and externalCredentials:
-                mode |= roci.OCI_SESSGET_CREDEXT
-
-            # set the connection class, if applicable
-            if roci.OCI_ATTR_CONNECTION_CLASS is not None:
-                stringBuffer.fill(space, w_cclass)
-                try:
-                    if stringBuffer.size > 0:
-                        externalCredentials = False
-                        status = roci.OCIAttrSet(
-                            authInfo,
-                            roci.OCI_HTYPE_AUTHINFO,
-                            stringBuffer.ptr, stringBuffer.size,
-                            roci.OCI_ATTR_CONNECTION_CLASS,
-                            self.environment.errorHandle)
-                        self.environment.checkForError(
-                            status,
-                            "Connection_GetConnection(): set connection class")
-                finally:
-                    stringBuffer.clear()
-
-            # set the purity, if applicable
-            if (roci.OCI_ATTR_PURITY is not None
-                and purity != roci.OCI_ATTR_PURITY_DEFAULT):
-                purityptr = lltype.malloc(rffi.CArrayPtr(roci.ub4).TO,
-                                          1, flavor='raw')
-                purityptr[0] = rffi.cast(roci.ub4, purity)
-                try:
-                    status = roci.OCIAttrSet(
-                        authInfo,
-                        roci.OCI_HTYPE_AUTHINFO,
-                        rffi.cast(roci.dvoidp, purityptr),
-                        rffi.sizeof(roci.ub4),
-                        roci.OCI_ATTR_PURITY,
-                        self.environment.errorHandle)
-                    self.environment.checkForError(
-                        status, "Connection_GetConnection(): set purity")
-                finally:
-                    lltype.free(purityptr, flavor='raw')
-
-        # acquire the new session
-        stringBuffer.fill(space, w_dbname)
-        foundptr = lltype.malloc(rffi.CArrayPtr(roci.boolean).TO,
-                                 1, flavor='raw')
-        handleptr = lltype.malloc(rffi.CArrayPtr(roci.OCISvcCtx).TO,
-                                  1, flavor='raw')
-        try:
-            status = roci.OCISessionGet(
-                self.environment.handle,
-                self.environment.errorHandle,
-                handleptr,
-                authInfo,
-                stringBuffer.ptr, stringBuffer.size,
-                None, 0,
-                lltype.nullptr(roci.Ptr(roci.oratext).TO),
-                lltype.nullptr(roci.Ptr(roci.ub4).TO),
-                foundptr,
-                mode)
-            self.environment.checkForError(
-                status, "Connection_GetConnection(): get connection")
-
-            self.handle = handleptr[0]
-        finally:
-            stringBuffer.clear()
-            lltype.free(foundptr, flavor='raw')
-            lltype.free(handleptr, flavor='raw')
-
-        # eliminate the authorization handle immediately, if applicable
-        if authInfo:
-            roci.OCIHandleFree(authInfo, roci.OCI_HTYPE_AUTHINFO)
-
-        # copy members in the case where a pool is being used
-        if pool:
-            if not proxyCredentials:
-                self.w_username = pool.w_username
-                self.w_password = pool.w_password
-            self.w_tnsentry = pool.w_tnsentry
-            self.sessionPool = pool
-
-        self.release = True
-
-    def _checkConnected(self, space):
-        if not self.handle:
-            raise OperationError(
-                interp_error.get(space).w_InterfaceError,
-                space.wrap("not connected"))
-
-    def close(self, space):
-        # make sure we are actually connnected
-        self._checkConnected(space)
-
-        # perform a rollback
-        status = roci.OCITransRollback(
-            self.handle, self.environment.errorHandle,
-            roci.OCI_DEFAULT)
-        self.environment.checkForError(
-            status, "Connection_Close(): rollback")
-
-        # logoff of the server
-        if self.sessionHandle:
-            status = roci.OCISessionEnd(
-                self.handle, self.environment.errorHandle,
-                self.sessionHandle, roci.OCI_DEFAULT)
-            self.environment.checkForError(
-                status, "Connection_Close(): end session")
-            roci.OCIHandleFree(self.handle, roci.OCI_HTYPE_SVCCTX)
-
-        self.handle = lltype.nullptr(roci.OCISvcCtx.TO)
-
-    def commit(self, space):
-        # make sure we are actually connected
-        self._checkConnected(space)
-
-        status = roci.OCITransCommit(
-            self.handle, self.environment.errorHandle,
-            self.commitMode)
-        self.environment.checkForError(
-            status, "Connection_Commit()")
-
-        self.commitMode = roci.OCI_DEFAULT
-
-    def rollback(self, space):
-        # make sure we are actually connected
-        self._checkConnected(space)
-
-        status = roci.OCITransRollback(
-            self.handle, self.environment.errorHandle,
-            roci.OCI_DEFAULT)
-        self.environment.checkForError(
-            status, "Connection_Rollback()")
-
-    def newCursor(self, space):
-        return space.wrap(W_Cursor(space, self))
-
-    def _getCharacterSetName(self, space, attribute):
-        # get character set id
-        charsetIdPtr = lltype.malloc(rffi.CArrayPtr(roci.ub2).TO,
-                                  1, flavor='raw')
-        try:
-            status = roci.OCIAttrGet(
-                self.environment.handle, roci.OCI_HTYPE_ENV,
-                rffi.cast(roci.dvoidp, charsetIdPtr),
-                lltype.nullptr(roci.Ptr(roci.ub4).TO),
-                attribute,
-                self.environment.errorHandle)
-            self.environment.checkForError(
-                status, "Connection_GetCharacterSetName(): get charset id")
-            charsetId = charsetIdPtr[0]
-        finally:
-            lltype.free(charsetIdPtr, flavor='raw')
-
-        # get character set name
-        charsetname_buf, charsetname = rffi.alloc_buffer(roci.OCI_NLS_MAXBUFSZ)
-        try:
-            status = roci.OCINlsCharSetIdToName(
-                self.environment.handle,
-                charsetname_buf, roci.OCI_NLS_MAXBUFSZ,
-                charsetId)
-            self.environment.checkForError(
-                status,
-                "Connection_GetCharacterSetName(): get Oracle charset name")
-
-            ianacharset_buf, ianacharset = rffi.alloc_buffer(
-                roci.OCI_NLS_MAXBUFSZ)
-
-            try:
-                # get IANA character set name
-                status = roci.OCINlsNameMap(
-                    self.environment.handle,
-                    ianacharset_buf, roci.OCI_NLS_MAXBUFSZ,
-                    charsetname_buf, roci.OCI_NLS_CS_ORA_TO_IANA)
-                self.environment.checkForError(
-                    status,
-                    "Connection_GetCharacterSetName(): translate NLS charset")
-                charset = rffi.charp2str(ianacharset_buf)
-            finally:
-                rffi.keep_buffer_alive_until_here(ianacharset_buf, ianacharset)
-        finally:
-            rffi.keep_buffer_alive_until_here(charsetname_buf, charsetname)
-        return space.wrap(charset)
-
-    def get_encoding(self, space):
-        return self._getCharacterSetName(space, roci.OCI_ATTR_ENV_CHARSET_ID)
-    def get_nationalencoding(self, space):
-        return self._getCharacterSetName(space, roci.OCI_ATTR_ENV_CHARSET_ID)
-    def get_maxbytespercharacter(self, space):
-        return space.wrap(self.environment.maxBytesPerCharacter)
-
-    def get_version(self, space):
-        # if version has already been determined, no need to determine again
-        if self.w_version:
-            return self.w_version
-
-        # allocate a cursor to retrieve the version
-        cursor = W_Cursor(space, self)
-
-        # allocate version and compatibility variables
-        versionVar = VT_String(cursor, cursor.arraySize, MAX_STRING_CHARS)
-        compatVar = VT_String(cursor, cursor.arraySize, MAX_STRING_CHARS)
-
-        # call stored procedure
-        cursor._call(space, "dbms_utility.db_version",
-                     None, space.newlist([space.wrap(versionVar),
-                                          space.wrap(compatVar)]))
-
-        # retrieve value
-        self.w_version = versionVar.getValue(space, 0)
-        return self.w_version
-
-W_Connection.typedef = TypeDef(
-    "Connection",
-    __new__ = interp2app(W_Connection.descr_new.im_func),
-    username = interp_attrproperty_w('w_username', W_Connection),
-    password = interp_attrproperty_w('w_password', W_Connection),
-    tnsentry = interp_attrproperty_w('w_tnsentry', W_Connection),
-
-    close = interp2app(W_Connection.close),
-    commit = interp2app(W_Connection.commit),
-    rollback = interp2app(W_Connection.rollback),
-
-    cursor = interp2app(W_Connection.newCursor),
-
-    encoding = GetSetProperty(W_Connection.get_encoding),
-    nationalencoding = GetSetProperty(W_Connection.get_nationalencoding),
-    maxBytesPerCharacter = GetSetProperty(W_Connection.get_maxbytespercharacter),
-    version = GetSetProperty(W_Connection.get_version),
-    )
diff --git a/pypy/module/oracle/interp_cursor.py b/pypy/module/oracle/interp_cursor.py
deleted file mode 100644
--- a/pypy/module/oracle/interp_cursor.py
+++ /dev/null
@@ -1,1094 +0,0 @@
-from pypy.interpreter.baseobjspace import W_Root
-from pypy.interpreter.typedef import TypeDef, GetSetProperty
-from pypy.interpreter.typedef import interp_attrproperty, interp_attrproperty_w
-from pypy.interpreter.gateway import interp2app, unwrap_spec
-from pypy.interpreter.error import OperationError
-from rpython.rtyper.lltypesystem import rffi, lltype
-
-from pypy.module.oracle import roci, interp_error
-from pypy.module.oracle.config import w_string, string_w, StringBuffer
-from pypy.module.oracle import interp_variable
-from pypy.module.oracle.interp_error import get
-
-# XXX are those "assert isinstance(xxx, interp_variable.W_Variable)" necessary?
-# the bindList should annotate to SomeList(SomeInstance(W_Variable))
-
-class W_Cursor(W_Root):
-    def __init__(self, space, connection):
-        self.connection = connection
-        self.environment = connection.environment
-
-        self.w_statement = None
-        self.statementType = -1
-        self.handle = lltype.nullptr(roci.OCIStmt.TO)
-        self.isOpen = True
-        self.isOwned = False
-
-        self.setInputSizes = False
-        self.arraySize = 50
-        self.fetchArraySize = 50
-        self.bindArraySize = 1
-        self.bindList = None
-        self.bindDict = None
-        self.numbersAsStrings = False
-        self.outputSize = -1
-        self.outputSizeColumn = -1
-
-        self.w_inputTypeHandler = None
-        self.w_outputTypeHandler = None
-        self.w_rowFactory = None
-
-    def execute(self, space, w_stmt, __args__):
-        args_w, kw_w = __args__.unpack()
-
-        if space.is_w(w_stmt, space.w_None):
-            w_stmt = None
-
-        if len(args_w) > 1:
-            raise OperationError(
-                space.w_TypeError,
-                space.wrap("Too many arguments"))
-        elif len(args_w) == 1:
-            if len(kw_w) > 0:
-                raise OperationError(
-                    interp_error.get(space).w_InterfaceError,
-                    space.wrap(
-                        "expecting argument or keyword arguments, not both"))
-            w_vars = args_w[0]
-        elif len(kw_w) > 0:
-            w_vars = space.newdict()
-            for key, w_value in kw_w.iteritems():
-                space.setitem(w_vars, space.wrap(key), w_value)
-        else:
-            w_vars = None
-
-        # make sure the cursor is open
-        self._checkOpen(space)
-
-        return self._execute(space, w_stmt, w_vars)
-
-    def prepare(self, space, w_stmt, w_tag=None):
-        # make sure the cursor is open
-        self._checkOpen(space)
-
-        # prepare the statement
-        self._internalPrepare(space, w_stmt, w_tag)
-
-    def _execute(self, space, w_stmt, w_vars):
-
-        # prepare the statement, if applicable
-        self._internalPrepare(space, w_stmt, None)
-
-        # perform binds
-        if w_vars is None:
-            pass
-        elif space.isinstance_w(w_vars, space.w_dict):
-            self._setBindVariablesByName(space, w_vars, 1, 0, 0)
-        else:
-            self._setBindVariablesByPos(space, w_vars, 1, 0, 0)
-        self._performBind(space)
-
-        # execute the statement
-        isQuery = self.statementType == roci.OCI_STMT_SELECT
-        if isQuery:
-            numIters = 0
-        else:
-            numIters = 1
-        self._internalExecute(space, numIters=numIters)
-
-        # perform defines, if necessary
-        if isQuery and self.fetchVariables is None:
-            self._performDefine()
-
-        # reset the values of setoutputsize()
-        self.outputSize = -1
-        self.outputSizeColumn = -1
-
-        # for queries, return the cursor for convenience
-        if isQuery:
-            return space.wrap(self)
-
-        # for all other statements, simply return None
-        return space.w_None
-
-    def executemany(self, space, w_stmt, w_list_of_args):
-        if space.is_w(w_stmt, space.w_None):
-            w_stmt = None
-        if not space.isinstance_w(w_list_of_args, space.w_list):
-            raise OperationError(
-                space.w_TypeError,
-                space.wrap("list expected"))
-
-        # make sure the cursor is open
-        self._checkOpen(space)
-
-        # prepare the statement
-        self._internalPrepare(space, w_stmt, None)
-
-        # queries are not supported as the result is undefined
-        if self.statementType == roci.OCI_STMT_SELECT:
-            raise OperationError(
-                get(space).w_NotSupportedError,
-                space.wrap("queries not supported: results undefined"))
-
-        # perform binds
-        args_w = space.listview(w_list_of_args)
-        numrows = len(args_w)
-        for i in range(numrows):
-            w_arguments = args_w[i]
-            deferred = i < numrows - 1
-            if space.isinstance_w(w_arguments, space.w_dict):
-                self._setBindVariablesByName(
-                    space, w_arguments, numrows, i, deferred)
-            else:
-                self._setBindVariablesByPos(
-                    space, w_arguments, numrows, i, deferred)
-        self._performBind(space)
-
-        # execute the statement, but only if the number of rows is greater than
-        # zero since Oracle raises an error otherwise
-        if numrows > 0:
-            self._internalExecute(space, numIters=numrows)
-
-    def close(self, space):
-        # make sure we are actually open
-        self._checkOpen(space)
-
-        # close the cursor
-        self.freeHandle(space, raiseError=True)
-
-        self.isOpen = False
-        self.handle = lltype.nullptr(roci.OCIStmt.TO)
-
-    @unwrap_spec(name=str)
-    def callfunc(self, space, name, w_returnType, w_parameters=None):
-        retvar = interp_variable.newVariableByType(space, self, w_returnType, 1)
-        if space.is_none(w_parameters):
-            w_parameters = None
-
-        self._call(space, name, retvar, w_parameters)
-
-        # determine the results
-        return retvar.getValue(space, 0)
-
-    @unwrap_spec(name=str)
-    def callproc(self, space, name, w_parameters=None):
-        if space.is_none(w_parameters):
-            w_parameters = None
-
-        self._call(space, name, None, w_parameters)
-
-        # create the return value
-        ret_w = []
-        if self.bindList:
-            for v in self.bindList:
-                assert isinstance(v, interp_variable.W_Variable)
-                ret_w.append(v.getValue(space, 0))
-        return space.newlist(ret_w)
-
-    def _call(self, space, name, retvar, w_args):
-        # determine the number of arguments passed
-        if w_args:
-            numArguments = space.len_w(w_args)
-        else:
-            numArguments = 0
-
-        # make sure we are actually open
-        self._checkOpen(space)
-
-        # add the return value, if applicable
-        if retvar:
-            offset = 1
-            w_vars = space.newlist([retvar])
-            if w_args:
-                space.call_method(w_vars, "extend", w_args)
-        else:
-            offset = 0
-            w_vars = w_args
-
-        # build up the statement
-        args = ', '.join([':%d' % (i + offset + 1,)
-                          for i in range(numArguments)])
-        if retvar:
-            stmt = "begin :1 := %s(%s); end;" % (name, args)
-        else:
-            stmt = "begin %s(%s); end;" % (name, args)
-
-        self._execute(space, space.wrap(stmt), w_vars)
-
-    def _checkOpen(self, space):
-        if not self.isOpen:
-            raise OperationError(
-                interp_error.get(space).w_InterfaceError,
-                space.wrap("not open"))
-
-    def allocateHandle(self):
-        handleptr = lltype.malloc(rffi.CArrayPtr(roci.OCIStmt).TO,
-                                  1, flavor='raw')
-        try:
-            status = roci.OCIHandleAlloc(
-                self.environment.handle,
-                handleptr, roci.OCI_HTYPE_STMT, 0,
-                lltype.nullptr(rffi.CArray(roci.dvoidp)))
-            self.environment.checkForError(
-                status, "Cursor_New()")
-            self.handle = handleptr[0]
-        finally:
-            lltype.free(handleptr, flavor='raw')
-        self.isOwned = True
-
-    def freeHandle(self, space, raiseError=True):
-        if not self.handle:
-            return
-        if self.isOwned:
-            roci.OCIHandleFree(self.handle, roci.OCI_HTYPE_STMT)
-        elif self.connection.handle:
-            tagBuffer = StringBuffer()
-            tagBuffer.fill(space, self.w_statementTag)
-            try:
-                status = roci.OCIStmtRelease(
-                    self.handle, self.environment.errorHandle,
-                    tagBuffer.ptr, tagBuffer.size,
-                    roci.OCI_DEFAULT)
-                self.environment.checkForError(
-                    status, "Cursor_FreeHandle()")
-            finally:
-                tagBuffer.clear()
-
-    def _internalPrepare(self, space, w_stmt, w_tag):
-        # make sure we don't get a situation where nothing is to be executed
-        if w_stmt is None and self.w_statement is None:
-            raise OperationError(
-                interp_error.get(space).w_ProgrammingError,
-                space.wrap("no statement specified "
-                           "and no prior statement prepared"))
-
-        # nothing to do if the statement is identical to the one already stored
-        # but go ahead and prepare anyway for create, alter and drop statments
-        if w_stmt is None or w_stmt == self.w_statement:
-            if self.statementType not in (roci.OCI_STMT_CREATE,
-                                          roci.OCI_STMT_DROP,
-                                          roci.OCI_STMT_ALTER):
-                return
-            w_stmt = self.w_statement
-        else:
-            self.w_statement = w_stmt
-
-        # release existing statement, if necessary
-        self.w_statementTag = w_tag
-        self.freeHandle(space)
-
-        # prepare statement
-        self.isOwned = False
-        handleptr = lltype.malloc(roci.Ptr(roci.OCIStmt).TO,
-                                  1, flavor='raw')
-        stmtBuffer = StringBuffer()
-        tagBuffer = StringBuffer()
-        stmtBuffer.fill(space, w_stmt)
-        tagBuffer.fill(space, w_tag)
-        try:
-            status = roci.OCIStmtPrepare2(
-                self.connection.handle, handleptr,
-                self.environment.errorHandle,
-                stmtBuffer.ptr, stmtBuffer.size,
-                tagBuffer.ptr, tagBuffer.size,
-                roci.OCI_NTV_SYNTAX, roci.OCI_DEFAULT)
-
-            self.environment.checkForError(
-                status, "Connection_InternalPrepare(): prepare")
-            self.handle = handleptr[0]
-        finally:
-            lltype.free(handleptr, flavor='raw')
-            stmtBuffer.clear()
-            tagBuffer.clear()
-
-        # clear bind variables, if applicable
-        if not self.setInputSizes:
-            self.bindList = None
-            self.bindDict = None
-
-        # clear row factory, if applicable
-        self.rowFactory = None
-
-        # determine if statement is a query
-        self._getStatementType()
-
-    def _setErrorOffset(self, space, e):
-        if e.match(space, get(space).w_DatabaseError):
-            attrptr = lltype.malloc(rffi.CArrayPtr(roci.ub4).TO, 1, flavor='raw')
-            try:
-                roci.OCIAttrGet(
-                    self.handle, roci.OCI_HTYPE_STMT,
-                    rffi.cast(roci.dvoidp, attrptr),
-                    lltype.nullptr(roci.Ptr(roci.ub4).TO),
-                    roci.OCI_ATTR_PARSE_ERROR_OFFSET,
-                    self.environment.errorHandle)
-                e.offset = attrptr[0]
-            finally:
-                lltype.free(attrptr, flavor='raw')
-
-    def _internalExecute(self, space, numIters):
-        if self.connection.autocommit:
-            mode = roci.OCI_COMMIT_ON_SUCCESS
-        else:
-            mode = roci.OCI_DEFAULT
-
-        status = roci.OCIStmtExecute(
-            self.connection.handle,
-            self.handle,
-            self.environment.errorHandle,
-            numIters, 0,
-            lltype.nullptr(roci.OCISnapshot.TO),
-            lltype.nullptr(roci.OCISnapshot.TO),
-            mode)
-        try:
-            self.environment.checkForError(
-                status, "Cursor_InternalExecute()")
-        except OperationError, e:
-            self._setErrorOffset(space, e)
-            raise
-        finally:
-            self._setRowCount()
-
-    def _getStatementType(self):
-        attrptr = lltype.malloc(rffi.CArrayPtr(roci.ub2).TO, 1, flavor='raw')
-        try:
-            status = roci.OCIAttrGet(
-                self.handle, roci.OCI_HTYPE_STMT,
-                rffi.cast(roci.dvoidp, attrptr),
-                lltype.nullptr(roci.Ptr(roci.ub4).TO),
-                roci.OCI_ATTR_STMT_TYPE,
-                self.environment.errorHandle)
-
-            self.environment.checkForError(
-                status, "Cursor_GetStatementType()")
-            self.statementType = rffi.cast(lltype.Signed, attrptr[0])
-        finally:
-            lltype.free(attrptr, flavor='raw')
-
-        self.fetchVariables = None
-
-    def getDescription(self, space):
-        "Return a list of 7-tuples consisting of the description of "
-        "the define variables"
-
-        # make sure the cursor is open
-        self._checkOpen(space)
-
-        # fixup bound cursor, if necessary
-        self._fixupBoundCursor()
-
-        # if not a query, return None
-        if self.statementType != roci.OCI_STMT_SELECT:
-            return
-
-        # determine number of items in select-list
-        attrptr = lltype.malloc(rffi.CArrayPtr(roci.ub1).TO, 1, flavor='raw')
-        try:
-            status = roci.OCIAttrGet(
-                self.handle, roci.OCI_HTYPE_STMT,
-                rffi.cast(roci.dvoidp, attrptr),
-                lltype.nullptr(roci.Ptr(roci.ub4).TO),
-                roci.OCI_ATTR_PARAM_COUNT,
-                self.environment.errorHandle)
-            self.environment.checkForError(
-                status,
-                "Cursor_GetDescription()")
-            numItems = attrptr[0]
-        finally:
-            lltype.free(attrptr, flavor='raw')
-
-        return space.newlist(
-            [space.newtuple(self._itemDescription(space, i + 1))
-             for i in range(numItems)])
-
-    def _itemDescription(self, space, pos):
-        "Return a tuple describing the item at the given position"
-
-        # acquire parameter descriptor
-        paramptr = lltype.malloc(roci.Ptr(roci.OCIParam).TO,
-                                 1, flavor='raw')
-        try:
-            status = roci.OCIParamGet(
-                self.handle, roci.OCI_HTYPE_STMT,
-                self.environment.errorHandle,
-                rffi.cast(roci.dvoidpp, paramptr),
-                pos)
-            self.environment.checkForError(
-                status,
-                "Cursor_GetDescription(): parameter")
-            param = paramptr[0]
-        finally:
-            lltype.free(paramptr, flavor='raw')
-
-        try:
-            # acquire usable type of item
-            varType = interp_variable.typeByOracleDescriptor(
-                param, self.environment)
-
-            # acquire internal size of item
-            attrptr = lltype.malloc(rffi.CArrayPtr(roci.ub2).TO, 1,
-                                    flavor='raw')
-            try:
-                status = roci.OCIAttrGet(
-                    param, roci.OCI_HTYPE_DESCRIBE,
-                    rffi.cast(roci.dvoidp, attrptr),
-                    lltype.nullptr(roci.Ptr(roci.ub4).TO),
-                    roci.OCI_ATTR_DATA_SIZE,
-                    self.environment.errorHandle)
-                self.environment.checkForError(
-                    status,
-                    "Cursor_ItemDescription(): internal size")
-                internalSize = rffi.cast(lltype.Signed, attrptr[0])
-            finally:
-                lltype.free(attrptr, flavor='raw')
-
-            # acquire name of item
-            nameptr = lltype.malloc(rffi.CArrayPtr(roci.oratext).TO, 1,
-                                    flavor='raw')
-            lenptr = lltype.malloc(rffi.CArrayPtr(roci.ub4).TO, 1,
-                                    flavor='raw')
-            try:
-                status = roci.OCIAttrGet(
-                    param, roci.OCI_HTYPE_DESCRIBE,
-                    rffi.cast(roci.dvoidp, nameptr),
-                    lenptr,
-                    roci.OCI_ATTR_NAME,
-                    self.environment.errorHandle)
-                self.environment.checkForError(
-                    status,
-                    "Cursor_ItemDescription(): name")
-                name = rffi.charpsize2str(nameptr[0], rffi.cast(lltype.Signed, lenptr[0]))
-            finally:
-                lltype.free(nameptr, flavor='raw')
-                lltype.free(lenptr, flavor='raw')
-
-            # lookup precision and scale
-            if varType is interp_variable.VT_Float:
-                attrptr = lltype.malloc(rffi.CArrayPtr(roci.sb1).TO, 1,
-                                        flavor='raw')
-                try:
-                    status = roci.OCIAttrGet(
-                        param, roci.OCI_HTYPE_DESCRIBE,
-                        rffi.cast(roci.dvoidp, attrptr),
-                        lltype.nullptr(roci.Ptr(roci.ub4).TO),
-                        roci.OCI_ATTR_SCALE,
-                        self.environment.errorHandle)
-                    self.environment.checkForError(
-                        status,
-                        "Cursor_ItemDescription(): scale")
-                    scale = rffi.cast(lltype.Signed, attrptr[0])
-                finally:
-                    lltype.free(attrptr, flavor='raw')
-
-                attrptr = lltype.malloc(rffi.CArrayPtr(roci.ub2).TO, 1,
-                                        flavor='raw')
-                try:
-                    status = roci.OCIAttrGet(
-                        param, roci.OCI_HTYPE_DESCRIBE,
-                        rffi.cast(roci.dvoidp, attrptr),
-                        lltype.nullptr(roci.Ptr(roci.ub4).TO),
-                        roci.OCI_ATTR_PRECISION,
-                        self.environment.errorHandle)
-                    self.environment.checkForError(
-                        status,
-                        "Cursor_ItemDescription(): precision")
-                    precision = rffi.cast(lltype.Signed, attrptr[0])
-                finally:
-                    lltype.free(attrptr, flavor='raw')
-            else:
-                scale = 0
-                precision = 0
-
-            # lookup whether null is permitted for the attribute
-            attrptr = lltype.malloc(rffi.CArrayPtr(roci.ub1).TO, 1,
-                                    flavor='raw')
-            try:
-                status = roci.OCIAttrGet(
-                    param, roci.OCI_HTYPE_DESCRIBE,
-                    rffi.cast(roci.dvoidp, attrptr),
-                    lltype.nullptr(roci.Ptr(roci.ub4).TO),
-                    roci.OCI_ATTR_IS_NULL,
-                    self.environment.errorHandle)
-                self.environment.checkForError(
-                    status,
-                    "Cursor_ItemDescription(): nullable")
-                nullable = rffi.cast(lltype.Signed, attrptr[0]) != 0
-            finally:
-                lltype.free(attrptr, flavor='raw')
-
-            # set display size based on data type
-            if varType is interp_variable.VT_String:
-                displaySize = internalSize
-            elif varType is interp_variable.VT_NationalCharString:
-                displaySize = internalSize / 2
-            elif varType is interp_variable.VT_Binary:
-                displaySize = internalSize
-            elif varType is interp_variable.VT_FixedChar:
-                displaySize = internalSize
-            elif varType is interp_variable.VT_FixedNationalChar:
-                displaySize = internalSize / 2
-            elif varType is interp_variable.VT_Float:
-                if precision:
-                    displaySize = precision + 1
-                    if scale > 0:
-                        displaySize += scale + 1
-                else:
-                    displaySize = 127
-            elif varType is interp_variable.VT_DateTime:
-                displaySize = 23
-            else:
-                displaySize = -1
-
-            # return the tuple
-            return [space.wrap(name), space.gettypeobject(varType.typedef),
-                    space.wrap(displaySize), space.wrap(internalSize),
-                    space.wrap(precision), space.wrap(scale),
-                    space.wrap(nullable)]
-
-        finally:
-            roci.OCIDescriptorFree(param, roci.OCI_DTYPE_PARAM)
-
-    def _setBindVariablesByPos(self, space,
-                               w_vars, numElements, arrayPos, defer):
-        "handle positional binds"
-        # make sure positional and named binds are not being intermixed
-        if self.bindDict is not None:
-            raise OperationError(
-                get(space).w_ProgrammingError,
-                space.wrap("positional and named binds cannot be intermixed"))
-
-        if self.bindList is None:
-            self.bindList = []
-
-        vars_w = space.fixedview(w_vars)
-        for i in range(len(vars_w)):
-            w_value = vars_w[i]
-            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,
-                                                 numElements, arrayPos, defer)
-            if newVar:
-                if i < len(self.bindList):
-                    self.bindList[i] = newVar
-                else:
-                    assert i == len(self.bindList)
-                    self.bindList.append(newVar)
-
-    def _setBindVariablesByName(self, space,
-                                w_vars, numElements, arrayPos, defer):
-        "handle named binds"
-        # make sure positional and named binds are not being intermixed


More information about the pypy-commit mailing list