[pypy-svn] pypy jit-unroll-loops: hg merge default

hakanardo commits-noreply at bitbucket.org
Sun Dec 19 21:53:59 CET 2010


Author: Hakan Ardo <hakan at debian.org>
Branch: jit-unroll-loops
Changeset: r40136:2661bf51a77c
Date: 2010-12-19 13:11 +0100
http://bitbucket.org/pypy/pypy/changeset/2661bf51a77c/

Log:	hg merge default

diff --git a/pypy/jit/metainterp/compile.py b/pypy/jit/metainterp/compile.py
--- a/pypy/jit/metainterp/compile.py
+++ b/pypy/jit/metainterp/compile.py
@@ -190,6 +190,9 @@
     if not we_are_translated():
         metainterp_sd.stats.compiled()
     metainterp_sd.log("compiled new bridge")
+    if metainterp_sd.warmrunnerdesc is not None:    # for tests
+        metainterp_sd.warmrunnerdesc.memory_manager.keep_loop_alive(
+            original_loop_token)
 
 # ____________________________________________________________
 

diff --git a/pypy/tool/logparser.py b/pypy/tool/logparser.py
--- a/pypy/tool/logparser.py
+++ b/pypy/tool/logparser.py
@@ -1,7 +1,7 @@
 #! /usr/bin/env python
 """
 Syntax:
-    python logparser.py <action> <logfilename> <options...>
+    python logparser.py <action> <logfilename> <output> <options...>
 
 Actions:
     draw-time   draw a timeline image of the log (format PNG by default)

diff --git a/pypy/jit/backend/x86/test/test_ztranslation.py b/pypy/jit/backend/x86/test/test_ztranslation.py
--- a/pypy/jit/backend/x86/test/test_ztranslation.py
+++ b/pypy/jit/backend/x86/test/test_ztranslation.py
@@ -189,14 +189,14 @@
 
         @dont_look_inside
         def f(x, total):
-            if x <= 3:
+            if x <= 30:
                 raise ImDone(total * 10)
-            if x > 20:
+            if x > 200:
                 return 2
             raise ValueError
         @dont_look_inside
         def g(x):
-            if x > 15:
+            if x > 150:
                 raise ValueError
             return 2
         class Base:
@@ -207,7 +207,7 @@
                 return 1
         @dont_look_inside
         def h(x):
-            if x < 2000:
+            if x < 20000:
                 return Sub()
             else:
                 return Base()
@@ -238,8 +238,8 @@
         logfile = udir.join('test_ztranslation.log')
         os.environ['PYPYLOG'] = 'jit-log-opt:%s' % (logfile,)
         try:
-            res = self.meta_interp(main, [40])
-            assert res == main(40)
+            res = self.meta_interp(main, [400])
+            assert res == main(400)
         finally:
             del os.environ['PYPYLOG']
 
@@ -248,5 +248,7 @@
             if 'guard_class' in line:
                 guard_class += 1
         # if we get many more guard_classes, it means that we generate
-        # guards that always fail
-        assert 0 < guard_class <= 4
+        # guards that always fail (the following assert's original purpose
+        # is to catch the following case: each GUARD_CLASS is misgenerated
+        # and always fails with "gcremovetypeptr")
+        assert 0 < guard_class < 10

diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -193,7 +193,7 @@
       the API headers.
     """
     if error is _NOT_SPECIFIED:
-        if restype is PyObject:
+        if isinstance(restype, lltype.Ptr):
             error = lltype.nullptr(restype.TO)
         elif restype is lltype.Void:
             error = CANNOT_FAIL
@@ -308,7 +308,7 @@
     'PyModule_AddObject', 'PyModule_AddIntConstant', 'PyModule_AddStringConstant',
     'Py_BuildValue', 'Py_VaBuildValue', 'PyTuple_Pack',
 
-    'PyErr_Format', 'PyErr_NewException',
+    'PyErr_Format', 'PyErr_NewException', 'PyErr_NewExceptionWithDoc',
 
     'PyEval_CallFunction', 'PyEval_CallMethod', 'PyObject_CallFunction',
     'PyObject_CallMethod', 'PyObject_CallFunctionObjArgs', 'PyObject_CallMethodObjArgs',
@@ -746,6 +746,7 @@
         ("SIZEOF_LONG_LONG", rffi.LONGLONG),
         ("SIZEOF_VOID_P", rffi.VOIDP),
         ("SIZEOF_SIZE_T", rffi.SIZE_T),
+        ("SIZEOF_TIME_T", rffi.TIME_T),
         ("SIZEOF_LONG", rffi.LONG),
         ("SIZEOF_SHORT", rffi.SHORT),
         ("SIZEOF_INT", rffi.INT)

diff --git a/pypy/module/cpyext/pyerrors.py b/pypy/module/cpyext/pyerrors.py
--- a/pypy/module/cpyext/pyerrors.py
+++ b/pypy/module/cpyext/pyerrors.py
@@ -275,3 +275,12 @@
 def PyErr_Print(space):
     """Alias for PyErr_PrintEx(1)."""
     PyErr_PrintEx(space, 1)
+
+ at cpython_api([PyObject, PyObject], rffi.INT_real, error=-1)
+def PyTraceBack_Print(space, w_tb, w_file):
+    space.call_method(w_file, "write", space.wrap(
+        'Traceback (most recent call last):\n'))
+    w_traceback = space.call_method(space.builtin, '__import__',
+                                    space.wrap("traceback"))
+    space.call_method(w_traceback, "print_tb", w_tb, space.w_None, w_file)
+    return 0

diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py
--- a/pypy/module/cpyext/typeobject.py
+++ b/pypy/module/cpyext/typeobject.py
@@ -16,10 +16,10 @@
     track_reference, RefcountState, borrow_from)
 from pypy.interpreter.module import Module
 from pypy.module.cpyext import structmemberdefs
-from pypy.module.cpyext.modsupport import convert_method_defs, PyCFunction
+from pypy.module.cpyext.modsupport import convert_method_defs
 from pypy.module.cpyext.state import State
 from pypy.module.cpyext.methodobject import (
-    PyDescr_NewWrapper, PyCFunction_NewEx)
+    PyDescr_NewWrapper, PyCFunction_NewEx, PyCFunction_typedef)
 from pypy.module.cpyext.pyobject import Py_IncRef, Py_DecRef, _Py_Dealloc
 from pypy.module.cpyext.structmember import PyMember_GetOne, PyMember_SetOne
 from pypy.module.cpyext.typeobjectdefs import (
@@ -208,7 +208,7 @@
 
 def setup_new_method_def(space):
     ptr = get_new_method_def(space)
-    ptr.c_ml_meth = rffi.cast(PyCFunction,
+    ptr.c_ml_meth = rffi.cast(PyCFunction_typedef,
         llhelper(tp_new_wrapper.api_func.functype,
                  tp_new_wrapper.api_func.get_wrapper(space)))
 

diff --git a/pypy/module/cpyext/include/Python.h b/pypy/module/cpyext/include/Python.h
--- a/pypy/module/cpyext/include/Python.h
+++ b/pypy/module/cpyext/include/Python.h
@@ -34,7 +34,23 @@
 # endif
 # define Py_LOCAL_INLINE(type) static __inline type __fastcall
 #endif
-#define DL_IMPORT(RTYPE) PyAPI_FUNC(RTYPE)
+
+/* Deprecated DL_IMPORT and DL_EXPORT macros */
+#ifdef _WIN32
+# if defined(Py_BUILD_CORE)
+#  define DL_IMPORT(RTYPE) __declspec(dllexport) RTYPE
+#  define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE
+# else
+#  define DL_IMPORT(RTYPE) __declspec(dllimport) RTYPE
+#  define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE
+# endif
+#endif
+#ifndef DL_EXPORT
+#       define DL_EXPORT(RTYPE) RTYPE
+#endif
+#ifndef DL_IMPORT
+#       define DL_IMPORT(RTYPE) RTYPE
+#endif
 
 #include <stdlib.h>
 
@@ -57,10 +73,6 @@
 #define Py_CHARMASK(c)		((unsigned char)((c) & 0xff))
 #endif
 
-#ifndef DL_EXPORT	/* declarations for DLL import/export */
-#define DL_EXPORT(RTYPE) RTYPE
-#endif
-
 #define statichere static
 
 #define Py_MEMCPY memcpy
@@ -68,6 +80,7 @@
 #include <pypy_macros.h>
 
 #include "patchlevel.h"
+#include "pyconfig.h"
 
 #include "object.h"
 #include "pyport.h"
@@ -80,8 +93,6 @@
 #include <locale.h>
 #include <ctype.h>
 
-#include "pyconfig.h"
-
 #include "boolobject.h"
 #include "floatobject.h"
 #include "complexobject.h"

diff --git a/pypy/module/cpyext/src/getargs.c b/pypy/module/cpyext/src/getargs.c
--- a/pypy/module/cpyext/src/getargs.c
+++ b/pypy/module/cpyext/src/getargs.c
@@ -558,8 +558,6 @@
 	switch (c) {
 	
 	case 'b': { /* unsigned byte -- very short int */
-    Py_FatalError("'b' unimplemented for PyArg_*\n");
-#if 0
 		char *p = va_arg(*p_va, char *);
 		long ival;
 		if (float_argument_error(arg))
@@ -580,13 +578,10 @@
 		else
 			*p = (unsigned char) ival;
 		break;
-#endif
 	}
 	
 	case 'B': {/* byte sized bitfield - both signed and unsigned
 		      values allowed */  
-    Py_FatalError("'B' unimplemented for PyArg_*\n");
-#if 0
 		char *p = va_arg(*p_va, char *);
 		long ival;
 		if (float_argument_error(arg))
@@ -597,12 +592,9 @@
 		else
 			*p = (unsigned char) ival;
 		break;
-#endif
 	}
 	
 	case 'h': {/* signed short int */
-    Py_FatalError("'h' unimplemented for PyArg_*\n");
-#if 0
 		short *p = va_arg(*p_va, short *);
 		long ival;
 		if (float_argument_error(arg))
@@ -623,13 +615,10 @@
 		else
 			*p = (short) ival;
 		break;
-#endif
 	}
 	
 	case 'H': { /* short int sized bitfield, both signed and
 		       unsigned allowed */ 
-    Py_FatalError("'H' unimplemented for PyArg_*\n");
-#if 0
 		unsigned short *p = va_arg(*p_va, unsigned short *);
 		long ival;
 		if (float_argument_error(arg))
@@ -640,7 +629,6 @@
 		else
 			*p = (unsigned short) ival;
 		break;
-#endif
 	}
 	case 'i': {/* signed int */
 		int *p = va_arg(*p_va, int *);
@@ -666,8 +654,6 @@
 	}
 	case 'I': { /* int sized bitfield, both signed and
 		       unsigned allowed */ 
-    Py_FatalError("'I' unimplemented for PyArg_*\n");
-#if 0
 		unsigned int *p = va_arg(*p_va, unsigned int *);
 		unsigned int ival;
 		if (float_argument_error(arg))
@@ -678,7 +664,6 @@
 		else
 			*p = ival;
 		break;
-#endif	
 	}
 	case 'n': /* Py_ssize_t */
 #if SIZEOF_SIZE_T != SIZEOF_LONG
@@ -709,8 +694,6 @@
 	}
 
 	case 'k': { /* long sized bitfield */
-    Py_FatalError("'k' unimplemented for PyArg_*\n");
-#if 0
 		unsigned long *p = va_arg(*p_va, unsigned long *);
 		unsigned long ival;
 		if (PyInt_Check(arg))
@@ -721,13 +704,10 @@
 			return converterr("integer<k>", arg, msgbuf, bufsize);
 		*p = ival;
 		break;
-#endif
 	}
 	
 #ifdef HAVE_LONG_LONG
 	case 'L': {/* PY_LONG_LONG */
-    Py_FatalError("'L' unimplemented for PyArg_*\n");
-#if 0
 		PY_LONG_LONG *p = va_arg( *p_va, PY_LONG_LONG * );
 		PY_LONG_LONG ival = PyLong_AsLongLong( arg );
 		if (ival == (PY_LONG_LONG)-1 && PyErr_Occurred() ) {
@@ -736,12 +716,9 @@
 			*p = ival;
 		}
 		break;
-#endif
 	}
 
 	case 'K': { /* long long sized bitfield */
-    Py_FatalError("'K' unimplemented for PyArg_*\n");
-#if 0
 		unsigned PY_LONG_LONG *p = va_arg(*p_va, unsigned PY_LONG_LONG *);
 		unsigned PY_LONG_LONG ival;
 		if (PyInt_Check(arg))
@@ -752,7 +729,6 @@
 			return converterr("integer<K>", arg, msgbuf, bufsize);
 		*p = ival;
 		break;
-#endif	
   }
 #endif // HAVE_LONG_LONG
 
@@ -778,8 +754,6 @@
 	
 #ifndef WITHOUT_COMPLEX
 	case 'D': {/* complex double */
-    Py_FatalError("'D' unimplemented for PyArg_*\n");
-#if 0
 		Py_complex *p = va_arg(*p_va, Py_complex *);
 		Py_complex cval;
 		cval = PyComplex_AsCComplex(arg);
@@ -788,7 +762,6 @@
 		else
 			*p = cval;
 		break;
-#endif
 	}
 #endif /* WITHOUT_COMPLEX */
 	
@@ -986,8 +959,6 @@
 		break;
 	}
 	case 'e': {/* encoded string */
-    Py_FatalError("'e' unimplemented for PyArg_*\n");
-#if 0
 		char **buffer;
 		const char *encoding;
 		PyObject *s;
@@ -1151,7 +1122,6 @@
 		}
 		Py_DECREF(s);
 		break;
-#endif
 	}
 
 #ifdef Py_USING_UNICODE

diff --git a/pypy/module/cpyext/stubs.py b/pypy/module/cpyext/stubs.py
--- a/pypy/module/cpyext/stubs.py
+++ b/pypy/module/cpyext/stubs.py
@@ -4,73 +4,34 @@
 from pypy.rpython.lltypesystem import rffi, lltype
 
 # we don't really care
-PyTypeObjectPtr = lltype.Void
-Py_ssize_t = lltype.Void
-PyMethodDef = lltype.Void
-PyGetSetDef = lltype.Void
-PyMemberDef = lltype.Void
-Py_buffer = lltype.Void
-Py_complex = lltype.Void
-va_list = lltype.Void
-PyDateTime_Date = lltype.Void
-PyDateTime_DateTime = lltype.Void
-PyDateTime_Time = lltype.Void
-wrapperbase = lltype.Void
-FILE = lltype.Void
-PyFileObject = lltype.Void
-PyCodeObject = lltype.Void
-PyFrameObject = lltype.Void
-_inittab = lltype.Void
-PyThreadState = lltype.Void
-PyInterpreterState = lltype.Void
-#PyOS_sighandler_t = lltype.Void
-Py_UNICODE = lltype.Void
-PyCompilerFlags = lltype.Void
-_node = lltype.Void
+PyTypeObjectPtr = rffi.VOIDP
+Py_ssize_t = rffi.VOIDP
+PyMethodDef = rffi.VOIDP
+PyGetSetDef = rffi.VOIDP
+PyMemberDef = rffi.VOIDP
+Py_buffer = rffi.VOIDP
+Py_complex = rffi.VOIDP
+va_list = rffi.VOIDP
+PyDateTime_Date = rffi.VOIDP
+PyDateTime_DateTime = rffi.VOIDP
+PyDateTime_Time = rffi.VOIDP
+wrapperbase = rffi.VOIDP
+FILE = rffi.VOIDP
+PyFileObject = rffi.VOIDP
+PyCodeObject = rffi.VOIDP
+PyFrameObject = rffi.VOIDP
+_inittab = rffi.VOIDP
+PyThreadState = rffi.VOIDP
+PyInterpreterState = rffi.VOIDP
+PyOS_sighandler_t = rffi.VOIDP
+Py_UNICODE = rffi.VOIDP
+PyCompilerFlags = rffi.VOIDP
+_node = rffi.VOIDP
 
 @cpython_api([PyObject], lltype.Void)
 def _PyObject_Del(space, op):
     raise NotImplementedError
 
- at cpython_api([rffi.CCHARP, PyMethodDef], PyObject)
-def Py_InitModule(space, name, methods):
-    """Create a new module object based on a name and table of functions,
-    returning the new module object.
-    
-    Older versions of Python did not support NULL as the value for the
-    methods argument."""
-    borrow_from()
-    raise NotImplementedError
-
- at cpython_api([rffi.CCHARP, PyMethodDef, rffi.CCHARP], PyObject)
-def Py_InitModule3(space, name, methods, doc):
-    """Create a new module object based on a name and table of functions,
-    returning the new module object.  If doc is non-NULL, it will be used
-    to define the docstring for the module.
-    
-    Older versions of Python did not support NULL as the value for the
-    methods argument."""
-    borrow_from()
-    raise NotImplementedError
-
- at cpython_api([PyObject, rffi.CCHARP, va_list], rffi.INT_real, error=0)
-def PyArg_VaParse(space, args, format, vargs):
-    """Identical to PyArg_ParseTuple(), except that it accepts a va_list
-    rather than a variable number of arguments."""
-    raise NotImplementedError
-
- at cpython_api([PyObject, PyObject, rffi.CCHARP, rffi.CCHARP, va_list], rffi.INT_real, error=0)
-def PyArg_VaParseTupleAndKeywords(space, args, kw, format, keywords, vargs):
-    """Identical to PyArg_ParseTupleAndKeywords(), except that it accepts a
-    va_list rather than a variable number of arguments."""
-    raise NotImplementedError
-
- at cpython_api([rffi.CCHARP, va_list], PyObject)
-def Py_VaBuildValue(space, format, vargs):
-    """Identical to Py_BuildValue(), except that it accepts a va_list
-    rather than a variable number of arguments."""
-    raise NotImplementedError
-
 @cpython_api([PyObject], rffi.INT_real, error=0)
 def PyObject_CheckBuffer(space, obj):
     """Return 1 if obj supports the buffer interface otherwise 0."""
@@ -261,11 +222,6 @@
     length.  Return 0 on success and -1 (with raising an error) on error."""
     raise NotImplementedError
 
- at cpython_api([PyObject], PyObject)
-def PyMemoryView_FromObject(space, obj):
-    """Return a memoryview object from an object that defines the buffer interface."""
-    raise NotImplementedError
-
 @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
 def PyByteArray_Check(space, o):
     """Return true if the object o is a bytearray object or an instance of a
@@ -402,13 +358,6 @@
     version since the definition of the bytecode changes often."""
     raise NotImplementedError
 
- at cpython_api([rffi.CCHARP, rffi.CCHARP, rffi.INT_real], PyObject)
-def PyCode_NewEmpty(space, filename, funcname, firstlineno):
-    """Return a new empty code object with the specified filename,
-    function name, and first line number.  It is illegal to
-    exec or eval() the resulting code object."""
-    raise NotImplementedError
-
 @cpython_api([Py_complex, Py_complex], Py_complex)
 def _Py_c_sum(space, left, right):
     """Return the sum of two complex numbers, using the C Py_complex
@@ -627,14 +576,6 @@
     """
     raise NotImplementedError
 
- at cpython_api([PyObject, PyObject], rffi.INT_real, error=-1)
-def PyDict_Contains(space, p, key):
-    """Determine if dictionary p contains key.  If an item in p is matches
-    key, return 1, otherwise return 0.  On error, return -1.
-    This is equivalent to the Python expression key in p.
-    """
-    raise NotImplementedError
-
 @cpython_api([PyObject, rffi.CCHARP], rffi.INT_real, error=-1)
 def PyDict_DelItemString(space, p, key):
     """Remove the entry in dictionary p which has a key specified by the string
@@ -716,13 +657,6 @@
     described there."""
     raise NotImplementedError
 
- at cpython_api([rffi.CCHARP, rffi.INT_real], rffi.INT_real, error=-1)
-def PyErr_WarnPy3k(space, message, stacklevel):
-    """Issue a DeprecationWarning with the given message and stacklevel
-    if the Py_Py3kWarningFlag flag is enabled.
-    """
-    raise NotImplementedError
-
 @cpython_api([], lltype.Void)
 def PyErr_SetInterrupt(space, ):
     """
@@ -748,14 +682,6 @@
     only be called from the main thread."""
     raise NotImplementedError
 
- at cpython_api([rffi.CCHARP, rffi.CCHARP, PyObject, PyObject], PyObject)
-def PyErr_NewExceptionWithDoc(space, name, doc, base, dict):
-    """Same as PyErr_NewException(), except that the new exception class can
-    easily be given a docstring: If doc is non-NULL, it will be used as the
-    docstring for the exception class.
-    """
-    raise NotImplementedError
-
 @cpython_api([PyObject], lltype.Void)
 def PyErr_WriteUnraisable(space, obj):
     """This utility function prints a warning message to sys.stderr when an
@@ -879,13 +805,6 @@
     failure; the appropriate exception will be set."""
     raise NotImplementedError
 
- at cpython_api([PyObject, rffi.CCHARPP], PyObject)
-def PyFloat_FromString(space, str, pend):
-    """Create a PyFloatObject object based on the string value in str, or
-    NULL on failure.  The pend argument is ignored.  It remains only for
-    backward compatibility."""
-    raise NotImplementedError
-
 @cpython_api([rffi.VOIDP_real], PyObject)
 def PyFloat_GetInfo(space, info):
     """Return a structseq instance which contains information about the
@@ -1024,22 +943,6 @@
     extension modules."""
     raise NotImplementedError
 
- at cpython_api([PyObject], lltype.Void)
-def Py_VISIT(space, o):
-    """Call the visit callback, with arguments o and arg. If visit returns
-    a non-zero value, then return it.  Using this macro, tp_traverse
-    handlers look like:
-    
-    static int
-    my_traverse(Noddy *self, visitproc visit, void *arg)
-    {
-        Py_VISIT(self->foo);
-        Py_VISIT(self->bar);
-        return 0;
-    }
-    """
-    raise NotImplementedError
-
 @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
 def PyGen_Check(space, gen):
     """Return true if ob is a generator object; ob must not be NULL."""
@@ -1058,18 +961,6 @@
     NULL."""
     raise NotImplementedError
 
- at cpython_api([rffi.CCHARP], PyObject)
-def PyImport_ImportModuleNoBlock(space, name):
-    """This version of PyImport_ImportModule() does not block. It's intended
-    to be used in C functions that import other modules to execute a function.
-    The import may block if another thread holds the import lock. The function
-    PyImport_ImportModuleNoBlock() never blocks. It first tries to fetch
-    the module from sys.modules and falls back to PyImport_ImportModule()
-    unless the lock is held, in which case the function will raise an
-    ImportError.
-    """
-    raise NotImplementedError
-
 @cpython_api([rffi.CCHARP, PyObject, PyObject, PyObject], PyObject)
 def PyImport_ImportModuleEx(space, name, globals, locals, fromlist):
     """
@@ -1789,23 +1680,6 @@
     """
     raise NotImplementedError
 
- at cpython_api([rffi.CCHARP, rffi.CCHARPP, rffi.INT_real], PyObject)
-def PyInt_FromString(space, str, pend, base):
-    """Return a new PyIntObject or PyLongObject based on the string
-    value in str, which is interpreted according to the radix in base.  If
-    pend is non-NULL, *pend will point to the first character in str which
-    follows the representation of the number.  If base is 0, the radix will be
-    determined based on the leading characters of str: if str starts with
-    '0x' or '0X', radix 16 will be used; if str starts with '0', radix
-    8 will be used; otherwise radix 10 will be used.  If base is not 0, it
-    must be between 2 and 36, inclusive.  Leading spaces are ignored.  If
-    there are no digits, ValueError will be raised.  If the string represents
-    a number too large to be contained within the machine's long int type
-    and overflow warnings are being suppressed, a PyLongObject will be
-    returned.  If overflow warnings are not being suppressed, NULL will be
-    returned in this case."""
-    raise NotImplementedError
-
 @cpython_api([rffi.SIZE_T], PyObject)
 def PyInt_FromSize_t(space, ival):
     """Create a new integer object with a value of ival. If the value exceeds
@@ -1813,22 +1687,6 @@
     """
     raise NotImplementedError
 
- at cpython_api([PyObject], rffi.ULONG, error=-1)
-def PyInt_AsUnsignedLongMask(space, io):
-    """Will first attempt to cast the object to a PyIntObject or
-    PyLongObject, if it is not already one, and then return its value as
-    unsigned long.  This function does not check for overflow.
-    """
-    raise NotImplementedError
-
- at cpython_api([PyObject], rffi.LONGLONG, error=-1)
-def PyInt_AsUnsignedLongLongMask(space, io):
-    """Will first attempt to cast the object to a PyIntObject or
-    PyLongObject, if it is not already one, and then return its value as
-    unsigned long long, without checking for overflow.
-    """
-    raise NotImplementedError
-
 @cpython_api([], lltype.Signed, error=CANNOT_FAIL)
 def PyInt_GetMax(space, ):
     """
@@ -1855,29 +1713,6 @@
     """
     raise NotImplementedError
 
- at cpython_api([PyObject, Py_ssize_t], PyObject)
-def PyList_GET_ITEM(space, list, i):
-    """Macro form of PyList_GetItem() without error checking.
-    
-    This macro used an int for i. This might require changes in
-    your code for properly supporting 64-bit systems."""
-    borrow_from()
-    raise NotImplementedError
-
- at cpython_api([PyObject, Py_ssize_t, PyObject], lltype.Void)
-def PyList_SET_ITEM(space, list, i, o):
-    """Macro form of PyList_SetItem() without error checking. This is
-    normally only used to fill in new lists where there is no previous content.
-    
-    This macro "steals" a reference to item, and, unlike
-    PyList_SetItem(), does not discard a reference to any item that
-    it being replaced; any reference in list at position i will be
-    leaked.
-    
-    This macro used an int for i. This might require
-    changes in your code for properly supporting 64-bit systems."""
-    raise NotImplementedError
-
 @cpython_api([PyObject, Py_ssize_t, Py_ssize_t], PyObject)
 def PyList_GetSlice(space, list, low, high):
     """Return a list of the objects in list containing the objects between low
@@ -1917,30 +1752,6 @@
     changes in your code for properly supporting 64-bit systems."""
     raise NotImplementedError
 
- at cpython_api([PyObject, rffi.INTP], lltype.Signed, error=-1)
-def PyLong_AsLongAndOverflow(space, pylong, overflow):
-    """Return a C long representation of the contents of
-    pylong.  If pylong is greater than LONG_MAX or less
-    than LONG_MIN, set *overflow to 1 or -1,
-    respectively, and return -1; otherwise, set *overflow to
-    0.  If any other exception occurs (for example a TypeError or
-    MemoryError), then -1 will be returned and *overflow will
-    be 0.
-    """
-    raise NotImplementedError
-
- at cpython_api([PyObject, rffi.INTP], rffi.LONGLONG, error=-1)
-def PyLong_AsLongLongAndOverflow(space, pylong, overflow):
-    """Return a C long long representation of the contents of
-    pylong.  If pylong is greater than PY_LLONG_MAX or less
-    than PY_LLONG_MIN, set *overflow to 1 or -1,
-    respectively, and return -1; otherwise, set *overflow to
-    0.  If any other exception occurs (for example a TypeError or
-    MemoryError), then -1 will be returned and *overflow will
-    be 0.
-    """
-    raise NotImplementedError
-
 @cpython_api([PyObject], Py_ssize_t)
 def PyLong_AsSsize_t(space, pylong):
     """
@@ -1953,20 +1764,6 @@
     """
     raise NotImplementedError
 
- at cpython_api([PyObject], rffi.ULONG, error=-1)
-def PyLong_AsUnsignedLongMask(space, io):
-    """Return a C unsigned long from a Python long integer, without checking
-    for overflow.
-    """
-    raise NotImplementedError
-
- at cpython_api([PyObject], rffi.ULONGLONG, error=-1)
-def PyLong_AsUnsignedLongLongMask(space, io):
-    """Return a C unsigned long long from a Python long integer, without
-    checking for overflow.
-    """
-    raise NotImplementedError
-
 @cpython_api([PyObject, rffi.CCHARP], rffi.INT_real, error=-1)
 def PyMapping_DelItemString(space, o, key):
     """Remove the mapping for object key from the object o. Return -1 on
@@ -2398,20 +2195,6 @@
     changes in your code for properly supporting 64-bit systems."""
     raise NotImplementedError
 
- at cpython_api([PyObject], Py_ssize_t)
-def PyString_GET_SIZE(space, string):
-    """Macro form of PyString_Size() but without error checking.
-    
-    This macro returned an int type. This might require changes in
-    your code for properly supporting 64-bit systems."""
-    raise NotImplementedError
-
- at cpython_api([PyObject], rffi.CCHARP, error=CANNOT_FAIL)
-def PyString_AS_STRING(space, string):
-    """Macro form of PyString_AsString() but without error checking.  Only
-    string objects are supported; no Unicode objects should be passed."""
-    raise NotImplementedError
-
 @cpython_api([PyObjectP], lltype.Void)
 def PyString_InternInPlace(space, string):
     """Intern the argument *string in place.  The argument must be the address of a
@@ -2590,15 +2373,6 @@
     the cleanup function, no Python APIs should be called by func."""
     raise NotImplementedError
 
- at cpython_api([PyObject, Py_ssize_t], PyObject)
-def PyTuple_GET_ITEM(space, p, pos):
-    """Like PyTuple_GetItem(), but does no checking of its arguments.
-    
-    This function used an int type for pos. This might require
-    changes in your code for properly supporting 64-bit systems."""
-    borrow_from()
-    raise NotImplementedError
-
 @cpython_api([PyObject, Py_ssize_t, Py_ssize_t], PyObject)
 def PyTuple_GetSlice(space, p, low, high):
     """Take a slice of the tuple pointed to by p from low to high and return it
@@ -2608,17 +2382,6 @@
     require changes in your code for properly supporting 64-bit systems."""
     raise NotImplementedError
 
- at cpython_api([PyObject, Py_ssize_t, PyObject], lltype.Void)
-def PyTuple_SET_ITEM(space, p, pos, o):
-    """Like PyTuple_SetItem(), but does no error checking, and should only be
-    used to fill in brand new tuples.
-    
-    This function "steals" a reference to o.
-    
-    This function used an int type for pos. This might require
-    changes in your code for properly supporting 64-bit systems."""
-    raise NotImplementedError
-
 @cpython_api([], rffi.INT_real, error=CANNOT_FAIL)
 def PyTuple_ClearFreeList(space, ):
     """Clear the free list. Return the total number of freed items.
@@ -2639,12 +2402,6 @@
     """
     raise NotImplementedError
 
- at cpython_api([PyObject, rffi.INT_real], rffi.INT_real, error=CANNOT_FAIL)
-def PyType_HasFeature(space, o, feature):
-    """Return true if the type object o sets the feature feature.  Type features
-    are denoted by single bit flags."""
-    raise NotImplementedError
-
 @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
 def PyType_IS_GC(space, o):
     """Return true if the type object includes support for the cycle detector; this
@@ -2701,12 +2458,6 @@
     possible.  This macro does not raise exceptions."""
     raise NotImplementedError
 
- at cpython_api([PyObject], PyObject)
-def PyUnicode_FromObject(space, obj):
-    """Shortcut for PyUnicode_FromEncodedObject(obj, NULL, "strict") which is used
-    throughout the interpreter whenever coercion to Unicode is needed."""
-    raise NotImplementedError
-
 @cpython_api([rffi.CWCHARP, Py_ssize_t, rffi.CCHARP, rffi.CCHARP], PyObject)
 def PyUnicode_Encode(space, s, size, encoding, errors):
     """Encode the Py_UNICODE buffer of the given size and return a Python
@@ -3093,12 +2844,6 @@
     require changes in your code for properly supporting 64-bit systems."""
     raise NotImplementedError
 
- at cpython_api([PyObject, PyObject], rffi.INT_real, error=-2)
-def PyUnicode_Compare(space, left, right):
-    """Compare two strings and return -1, 0, 1 for less than, equal, and greater than,
-    respectively."""
-    raise NotImplementedError
-
 @cpython_api([PyObject, PyObject, rffi.INT_real], PyObject)
 def PyUnicode_RichCompare(space, left, right, op):
     """Rich compare two unicode strings and return one of the following:

diff --git a/pypy/objspace/std/dictmultiobject.py b/pypy/objspace/std/dictmultiobject.py
--- a/pypy/objspace/std/dictmultiobject.py
+++ b/pypy/objspace/std/dictmultiobject.py
@@ -809,42 +809,6 @@
                              space.wrap("popitem(): dictionary is empty"))
     return space.newtuple([w_key, w_value])
 
-app = gateway.applevel('''
-    def dictrepr(currently_in_repr, d):
-        # Now we only handle one implementation of dicts, this one.
-        # The fix is to move this to dicttype.py, and do a
-        # multimethod lookup mapping str to StdObjSpace.str
-        # This cannot happen until multimethods are fixed. See dicttype.py
-            dict_id = id(d)
-            if dict_id in currently_in_repr:
-                return '{...}'
-            currently_in_repr[dict_id] = 1
-            try:
-                items = []
-                # XXX for now, we cannot use iteritems() at app-level because
-                #     we want a reasonable result instead of a RuntimeError
-                #     even if the dict is mutated by the repr() in the loop.
-                for k, v in dict.items(d):
-                    items.append(repr(k) + ": " + repr(v))
-                return "{" +  ', '.join(items) + "}"
-            finally:
-                try:
-                    del currently_in_repr[dict_id]
-                except:
-                    pass
-''', filename=__file__)
-
-dictrepr = app.interphook("dictrepr")
-
-def repr__DictMulti(space, w_dict):
-    if w_dict.length() == 0:
-        return space.wrap('{}')
-    ec = space.getexecutioncontext()
-    w_currently_in_repr = ec._py_repr
-    if w_currently_in_repr is None:
-        w_currently_in_repr = ec._py_repr = space.newdict()
-    return dictrepr(space, w_currently_in_repr, w_dict)
-
 
 # ____________________________________________________________
 # Iteration

diff --git a/pypy/doc/cpython_differences.txt b/pypy/doc/cpython_differences.txt
--- a/pypy/doc/cpython_differences.txt
+++ b/pypy/doc/cpython_differences.txt
@@ -204,4 +204,16 @@
 lets the exception propagate instead.
 
 
+Miscellaneous
+-------------
+
+* ``sys.setrecursionlimit()`` is ignored (and not needed) on
+  PyPy.  On CPython it would set the maximum number of nested
+  calls that can occur before a RuntimeError is raised; on PyPy
+  overflowing the stack also causes RuntimeErrors, but the limit
+  is checked at a lower level.  (The limit is currenty hard-coded
+  at 768 KB, corresponding to roughly 1480 Python calls on
+  Linux.)
+
+
 .. include:: _ref.txt

diff --git a/pypy/doc/config/objspace.std.immutable_builtintypes.txt b/pypy/doc/config/objspace.std.immutable_builtintypes.txt
deleted file mode 100644
--- a/pypy/doc/config/objspace.std.immutable_builtintypes.txt
+++ /dev/null
@@ -1,1 +0,0 @@
-Disallow modification of builtin types.  Enabled by default.

diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -301,7 +301,7 @@
                    default=False),
         BoolOption("newshortcut",
                    "cache and shortcut calling __new__ from builtin types",
-                   default=False),        
+                   default=False),
 
         BoolOption("logspaceoptypes",
                    "a instrumentation option: before exit, print the types seen by "
@@ -310,8 +310,9 @@
         ChoiceOption("multimethods", "the multimethod implementation to use",
                      ["doubledispatch", "mrd"],
                      default="mrd"),
-        BoolOption("immutable_builtintypes",
-                   "Forbid the changing of builtin types", default=True),
+        BoolOption("mutable_builtintypes",
+                   "Allow the changing of builtin types", default=False,
+                   requires=[("objspace.std.builtinshortcut", True)]),
      ]),
 ])
 

diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -134,7 +134,7 @@
 
     def mutated(w_self):
         space = w_self.space
-        assert w_self.is_heaptype() or not space.config.objspace.std.immutable_builtintypes
+        assert w_self.is_heaptype() or space.config.objspace.std.mutable_builtintypes
         if (not space.config.objspace.std.withtypeversion and
             not space.config.objspace.std.getattributeshortcut and
             not space.config.objspace.std.newshortcut):
@@ -157,8 +157,8 @@
             w_subclass.mutated()
 
     def version_tag(w_self):
-        if (not we_are_jitted() or w_self.is_heaptype() or not
-            w_self.space.config.objspace.std.immutable_builtintypes):
+        if (not we_are_jitted() or w_self.is_heaptype() or
+            w_self.space.config.objspace.std.mutable_builtintypes):
             return w_self._version_tag
         # heap objects cannot get their version_tag changed
         return w_self._pure_version_tag()
@@ -784,7 +784,7 @@
             space.set(w_descr, w_type, w_value)
             return
     
-    if (space.config.objspace.std.immutable_builtintypes
+    if (not space.config.objspace.std.mutable_builtintypes
             and not w_type.is_heaptype()):
         msg = "can't set attributes on type object '%s'"
         raise operationerrfmt(space.w_TypeError, msg, w_type.name)
@@ -803,7 +803,7 @@
         if space.is_data_descr(w_descr):
             space.delete(w_descr, w_type)
             return
-    if (space.config.objspace.std.immutable_builtintypes
+    if (not space.config.objspace.std.mutable_builtintypes
             and not w_type.is_heaptype()):
         msg = "can't delete attributes on type object '%s'"
         raise operationerrfmt(space.w_TypeError, msg, w_type.name)

diff --git a/pypy/module/cpyext/conftest.py b/pypy/module/cpyext/conftest.py
deleted file mode 100644
--- a/pypy/module/cpyext/conftest.py
+++ /dev/null
@@ -1,16 +0,0 @@
-import py
-from pypy.conftest import option, gettestobjspace
-
-def pytest_ignore_collect(path, config):
-    if config.option.runappdirect:
-        return True # "cannot be run by py.test -A"
-    # ensure additional functions are registered
-    import pypy.module.cpyext.test.test_cpyext
-    return False
-
-def pytest_funcarg__space(request):
-    return gettestobjspace(usemodules=['cpyext', 'thread'])
-
-def pytest_funcarg__api(request):
-    return request.cls.api
-


More information about the Pypy-commit mailing list