1. Pypy
  2. Untitled project
  3. pypy

Commits

Hakan Ardo  committed 772b7ad Merge

hg merge default

  • Participants
  • Parent commits d532da6, 88b090e
  • Branches jit-usable_retrace

Comments (0)

Files changed (851)

File .gitignore

View file
  • Ignore whitespace
 pypy/doc/*.html
 pypy/doc/config/*.html
 pypy/doc/discussion/*.html
+pypy/module/cpyext/src/*.o
+pypy/module/cpyext/test/*.o
 pypy/module/test_lib_pypy/ctypes_tests/*.o
 pypy/translator/c/src/dtoa.o
 pypy/translator/goal/pypy-c

File .hgignore

View file
  • Ignore whitespace
 ^pypy/doc/discussion/.+\.html$
 ^include/.+\.h$
 ^include/.+\.inl$
+^pypy/doc/_build/.*$
 ^pypy/doc/config/.+\.html$
 ^pypy/doc/config/style\.css$
 ^pypy/doc/jit/.+\.html$

File .hgsub

  • Ignore whitespace
-greenlet = [svn]http://codespeak.net/svn/greenlet/trunk/c
-testrunner = [svn]http://codespeak.net/svn/pypy/build/testrunner
-lib_pypy/pyrepl = [svn]http://codespeak.net/svn/pyrepl/trunk/pyrepl/pyrepl

File .hgsubstate

  • Ignore whitespace
-80037 greenlet
-80348 lib_pypy/pyrepl
-80409 testrunner

File LICENSE

View file
  • Ignore whitespace
     Anders Qvist
     Alan McIntyre
     Bert Freudenberg
+    Tav
 
     Heinrich-Heine University, Germany 
     Open End AB (formerly AB Strakt), Sweden

File README

View file
  • Ignore whitespace
-======================================
-PyPy: Python in Python implementation 
-======================================
+=====================================
+PyPy: Python in Python Implementation 
+=====================================
 
 Welcome to PyPy!
 
 
     http://pypy.org/
 
-We invite you to head over to our detailed getting-started document:
-
-    pypy/doc/getting-started.html or
-    pypy/doc/getting-started.txt
-    (local if you got a source tarball or svn checkout)
+The getting-started document will help guide you:
 
     http://codespeak.net/pypy/dist/pypy/doc/getting-started.html
 
-which gives you many good starting and entry points into playing with
-PyPy.  It will also point you to our documentation section which is
-generated from information in the pypy/doc directory.
-
-Enjoy and send us feedback!
+It will also point you to the rest of the documentation which is generated
+from files in the pypy/doc directory within the source repositories. Enjoy
+and send us feedback!
 
     the pypy-dev team <pypy-dev@codespeak.net>

File _pytest/__init__.py

View file
  • Ignore whitespace
 #
+__version__ = '2.0.3.dev3'

File _pytest/config.py

View file
  • Ignore whitespace
         self.hook = self.pluginmanager.hook
         self._inicache = {}
 
+    @classmethod
+    def fromdictargs(cls, option_dict, args):
+        """ constructor useable for subprocesses. """
+        config = cls()
+        config._preparse(args, addopts=False)
+        config.option.__dict__.update(option_dict)
+        for x in config.option.plugins:
+            config.pluginmanager.consider_pluginarg(x)
+        return config
+
     def _onimportconftest(self, conftestmodule):
         self.trace("loaded conftestmodule %r" %(conftestmodule,))
         self.pluginmanager.consider_conftest(conftestmodule)

File _pytest/core.py

View file
  • Ignore whitespace
     def consider_preparse(self, args):
         for opt1,opt2 in zip(args, args[1:]):
             if opt1 == "-p":
-                if opt2.startswith("no:"):
-                    name = opt2[3:]
-                    if self.getplugin(name) is not None:
-                        self.unregister(None, name=name)
-                    self._name2plugin[name] = -1
-                else:
-                    if self.getplugin(opt2) is None:
-                        self.import_plugin(opt2)
+                self.consider_pluginarg(opt2)
+
+    def consider_pluginarg(self, arg):
+        if arg.startswith("no:"):
+            name = arg[3:]
+            if self.getplugin(name) is not None:
+                self.unregister(None, name=name)
+            self._name2plugin[name] = -1
+        else:
+            if self.getplugin(arg) is None:
+                self.import_plugin(arg)
 
     def consider_conftest(self, conftestmodule):
         if self.register(conftestmodule, name=conftestmodule.__file__):

File _pytest/junitxml.py

View file
  • Ignore whitespace
                 '<skipped message="expected test failure">%s</skipped>',
                 report.keywords['xfail'])
         else:
-            self.appendlog("<skipped/>")
+            filename, lineno, skipreason = report.longrepr
+            if skipreason.startswith("Skipped: "):
+                skipreason = skipreason[9:]
+            self.appendlog('<skipped type="pytest.skip" '
+                           'message="%s">%s</skipped>',
+                skipreason, "%s:%s: %s" % report.longrepr,
+                )
         self._closetestcase()
         self.skipped += 1
 

File _pytest/python.py

View file
  • Ignore whitespace
     res = __multicall__.execute()
     if res is not None:
         return res
-    if collector._istestclasscandidate(name, obj):
+    if inspect.isclass(obj):
         #if hasattr(collector.obj, 'unittest'):
         #    return # we assume it's a mixin class for a TestCase derived one
-        Class = collector._getcustomclass("Class")
-        return Class(name, parent=collector)
+        if collector.classnamefilter(name):
+            if not hasinit(obj):
+                Class = collector._getcustomclass("Class")
+                return Class(name, parent=collector)
     elif collector.funcnamefilter(name) and hasattr(obj, '__call__'):
         if is_generator(obj):
             return Generator(name, parent=collector)
         return self.ihook.pytest_pycollect_makeitem(
             collector=self, name=name, obj=obj)
 
-    def _istestclasscandidate(self, name, obj):
-        if self.classnamefilter(name) and \
-           inspect.isclass(obj):
-            if hasinit(obj):
-                # XXX WARN
-                return False
-            return True
-
     def _genfunctions(self, name, funcobj):
         module = self.getparent(Module).obj
         clscol = self.getparent(Class)

File lib-python/conftest.py

View file
  • Ignore whitespace
         return status, stdout.read(mode='rU'), stderr.read(mode='rU')
 
     def getresult(self, regrtest): 
-        cmd = self.getinvocation(regrtest) 
-        exit_status, test_stdout, test_stderr = self.getstatusouterr(cmd) 
+        cmd = self.getinvocation(regrtest)
+        tempdir = py.test.ensuretemp(self.fspath.basename)
+        oldcwd = tempdir.chdir()
+        exit_status, test_stdout, test_stderr = self.getstatusouterr(cmd)
+        oldcwd.chdir()
         skipped = False
         timedout = test_stderr.rfind(26*"=" + "timedout" + 26*"=") != -1 
         if not timedout: 

File lib-python/modified-2.7.0/ctypes/test/test_callbacks.py

View file
  • Ignore whitespace
 import unittest
 from ctypes import *
 import _ctypes_test
-from ctypes.test import xfail
 
 class Callbacks(unittest.TestCase):
     functype = CFUNCTYPE
         prototype = self.functype.im_func(object)
         self.assertRaises(TypeError, prototype, lambda: None)
 
-    @xfail
     def test_issue_7959(self):
         proto = self.functype.im_func(None)
 

File lib-python/modified-2.7.0/ctypes/test/test_cast.py

View file
  • Ignore whitespace
 import unittest
 import sys
 
-from ctypes.test import xfail
-
 class Test(unittest.TestCase):
 
     def test_array2pointer(self):

File lib-python/modified-2.7.0/ctypes/test/test_init.py

View file
  • Ignore whitespace
 from ctypes import *
 import unittest
-from ctypes.test import xfail
 
 class X(Structure):
     _fields_ = [("a", c_int),
 
 
 class InitTest(unittest.TestCase):
-    @xfail
     def test_get(self):
         # make sure the only accessing a nested structure
         # doesn't call the structure's __new__ and __init__

File lib-python/modified-2.7.0/ctypes/test/test_internals.py

View file
  • Ignore whitespace
 import unittest
 from ctypes import *
 from sys import getrefcount as grc
-from ctypes.test import xfail
 
 # XXX This test must be reviewed for correctness!!!
 
         self.assertEqual(refcnt, grc(i))
         self.assertEqual(ci._objects, None)
 
-    @xfail
     def test_c_char_p(self):
         s = "Hello, World"
         refcnt = grc(s)
         cs = c_char_p(s)
         self.assertEqual(refcnt + 1, grc(s))
-        self.assertSame(cs._objects, s)
+        try:
+            # Moving gcs need to allocate a nonmoving buffer
+            cs._objects._obj
+        except AttributeError:
+            self.assertSame(cs._objects, s)
+        else:
+            self.assertSame(cs._objects._obj, s)
 
     def test_simple_struct(self):
         class X(Structure):

File lib-python/modified-2.7.0/ctypes/test/test_loading.py

View file
  • Ignore whitespace
 import sys, unittest
 import os
 from ctypes.util import find_library
-from ctypes.test import is_resource_enabled
+from ctypes.test import is_resource_enabled, xfail
 
 libc_name = None
 if os.name == "nt":
             self.assertRaises(AttributeError, dll.__getitem__, 1234)
 
     if os.name == "nt":
+        @xfail
         def test_1703286_A(self):
             from _ctypes import LoadLibrary, FreeLibrary
             # On winXP 64-bit, advapi32 loads at an address that does
             handle = LoadLibrary("advapi32")
             FreeLibrary(handle)
 
+        @xfail
         def test_1703286_B(self):
             # Since on winXP 64-bit advapi32 loads like described
             # above, the (arbitrarily selected) CloseEventLog function

File lib-python/modified-2.7.0/ctypes/test/test_macholib.py

View file
  • Ignore whitespace
                                  '/usr/lib/libSystem.B.dylib')
 
             result = find_lib('z')
-            self.assertTrue(result.startswith('/usr/lib/libz.1'))
             self.assertTrue(result.endswith('.dylib'))
 
             self.assertEqual(find_lib('IOKit'),

File lib-python/modified-2.7.0/ctypes/test/test_objects.py

View file
  • Ignore whitespace
 
 >>> array[4] = 'foo bar'
 >>> array._objects
-{'4': <CArgObject: 'foo bar'>}
+{'4': <CArgObject 'foo bar'>}
 >>> array[4]
 'foo bar'
 >>>
 
 >>> x.array[0] = 'spam spam spam'
 >>> x._objects
-{'0:2': <CArgObject: 'spam spam spam'>}
+{'0:2': <CArgObject 'spam spam spam'>}
 >>> x.array._b_base_._objects
-{'0:2': <CArgObject: 'spam spam spam'>}
+{'0:2': <CArgObject 'spam spam spam'>}
 >>>
 
 '''

File lib-python/modified-2.7.0/ctypes/test/test_parameters.py

View file
  • Ignore whitespace
 
         pa = c_wchar_p.from_param(c_wchar_p(u"123"))
         self.assertEqual(type(pa), c_wchar_p)
+    if sys.platform == "win32":
+        test_cw_strings = xfail(test_cw_strings)
 
     @xfail
     def test_int_pointers(self):

File lib-python/modified-2.7.0/ctypes/test/test_prototypes.py

View file
  • Ignore whitespace
 from ctypes import *
 import unittest
-from ctypes.test import xfail
 
 # IMPORTANT INFO:
 #
         func.restype = c_long
         func.argtypes = None
 
-    @xfail
     def test_paramflags(self):
         # function returns c_void_p result,
         # and has a required parameter named 'input'

File lib-python/modified-2.7.0/ctypes/test/test_refcounts.py

View file
  • Ignore whitespace
             return a * b * 2
         f = proto(func)
 
+        gc.collect()
         a = sys.getrefcount(ctypes.c_int)
         f(1, 2)
         self.assertEqual(sys.getrefcount(ctypes.c_int), a)

File lib-python/modified-2.7.0/distutils/command/build_ext.py

View file
  • Ignore whitespace
             # the 'libs' directory is for binary installs - we assume that
             # must be the *native* platform.  But we don't really support
             # cross-compiling via a binary install anyway, so we let it go.
-            self.library_dirs.append(os.path.join(sys.exec_prefix, 'libs'))
+            self.library_dirs.append(os.path.join(sys.exec_prefix, 'include'))
             if self.debug:
                 self.build_temp = os.path.join(self.build_temp, "Debug")
             else:
 
             # Append the source distribution include and library directories,
             # this allows distutils on windows to work in the source tree
-            self.include_dirs.append(os.path.join(sys.exec_prefix, 'PC'))
-            if MSVC_VERSION == 9:
+            if 0:
+                # pypy has no PC directory
+                self.include_dirs.append(os.path.join(sys.exec_prefix, 'PC'))
+            if 1:
+                # pypy has no PCBuild directory
+                pass
+            elif MSVC_VERSION == 9:
                 # Use the .lib files for the correct architecture
                 if self.plat_name == 'win32':
                     suffix = ''
         shared extension.  On most platforms, this is just 'ext.libraries';
         on Windows and OS/2, we add the Python library (eg. python20.dll).
         """
-        # The python library is always needed on Windows.  For MSVC, this
-        # is redundant, since the library is mentioned in a pragma in
-        # pyconfig.h that MSVC groks.  The other Windows compilers all seem
-        # to need it mentioned explicitly, though, so that's what we do.
-        # Append '_d' to the python import library on debug builds.
+        # The python library is always needed on Windows.
         if sys.platform == "win32":
-            from distutils.msvccompiler import MSVCCompiler
-            if not isinstance(self.compiler, MSVCCompiler):
-                template = "python%d%d"
-                if self.debug:
-                    template = template + '_d'
-                pythonlib = (template %
-                       (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
-                # don't extend ext.libraries, it may be shared with other
-                # extensions, it is a reference to the original list
-                return ext.libraries + [pythonlib]
-            else:
-                return ext.libraries
+            template = "python%d%d"
+            pythonlib = (template %
+                   (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
+            # don't extend ext.libraries, it may be shared with other
+            # extensions, it is a reference to the original list
+            return ext.libraries + [pythonlib]
         elif sys.platform == "os2emx":
             # EMX/GCC requires the python library explicitly, and I
             # believe VACPP does as well (though not confirmed) - AIM Apr01

File lib-python/modified-2.7.0/distutils/msvc9compiler.py

View file
  • Ignore whitespace
             temp_manifest = os.path.join(
                     build_temp,
                     os.path.basename(output_filename) + ".manifest")
+            ld_args.append('/MANIFEST')
             ld_args.append('/MANIFESTFILE:' + temp_manifest)
 
             if extra_preargs:

File lib-python/modified-2.7.0/sqlite3/test/regression.py

View file
  • Ignore whitespace
         """
         self.assertRaises(sqlite.Warning, self.con, 1)
 
+    def CheckUpdateDescriptionNone(self):
+        """
+        Call Cursor.update with an UPDATE query and check that it sets the
+        cursor's description to be None.
+        """
+        cur = self.con.cursor()
+        cur.execute("CREATE TABLE foo (id INTEGER)")
+        cur.execute("UPDATE foo SET id = 3 WHERE id = 1")
+        self.assertEqual(cur.description, None)
+
 def suite():
     regression_suite = unittest.makeSuite(RegressionTests, "Check")
     return unittest.TestSuite((regression_suite,))

File lib-python/modified-2.7.0/test/list_tests.py

View file
  • Ignore whitespace
         u += "eggs"
         self.assertEqual(u, self.type2test("spameggs"))
 
-        self.assertRaises(TypeError, u.__iadd__, None)
+        def f_iadd(u, x):
+            u += x
+            return u
+
+        self.assertRaises(TypeError, f_iadd, u, None)
 
     def test_imul(self):
         u = self.type2test([0, 1])

File lib-python/modified-2.7.0/test/test_ast.py

View file
  • Ignore whitespace
                 self._assertTrueorder(value, parent_pos)
 
     def test_AST_objects(self):
-        x = ast.AST()
-        try:
-            x.foobar = 21
-        except AttributeError, e:
-            self.assertEquals(e.args[0],
-                              "'_ast.AST' object has no attribute 'foobar'")
-        else:
-            self.assert_(False)
+        if test_support.check_impl_detail():
+            # PyPy also provides a __dict__ to the ast.AST base class.
 
-        try:
-            ast.AST(lineno=2)
-        except AttributeError, e:
-            self.assertEquals(e.args[0],
-                              "'_ast.AST' object has no attribute 'lineno'")
-        else:
-            self.assert_(False)
+            x = ast.AST()
+            try:
+                x.foobar = 21
+            except AttributeError, e:
+                self.assertEquals(e.args[0],
+                                  "'_ast.AST' object has no attribute 'foobar'")
+            else:
+                self.assert_(False)
+
+            try:
+                ast.AST(lineno=2)
+            except AttributeError, e:
+                self.assertEquals(e.args[0],
+                                  "'_ast.AST' object has no attribute 'lineno'")
+            else:
+                self.assert_(False)
+
         try:
             ast.AST(2)
         except TypeError, e:

File lib_pypy/_ctypes/__init__.py

View file
  • Ignore whitespace
 from _ctypes.primitive import _SimpleCData
 from _ctypes.pointer import _Pointer, _cast_addr
 from _ctypes.pointer import POINTER, pointer, _pointer_type_cache
-from _ctypes.function import CFuncPtr
+from _ctypes.function import CFuncPtr, call_function
 from _ctypes.dll import dlopen
 from _ctypes.structure import Structure
 from _ctypes.array import Array

File lib_pypy/_ctypes/function.py

View file
  • Ignore whitespace
-
-from _ctypes.basics import _CData, _CDataMeta, cdata_from_address
-from _ctypes.primitive import SimpleType
-from _ctypes.basics import ArgumentError, keepalive_key
-from _ctypes.builtin import set_errno, set_last_error
 import _rawffi
 import sys
 import traceback
 
+from _ctypes.basics import ArgumentError, keepalive_key
+from _ctypes.basics import _CData, _CDataMeta, cdata_from_address
+from _ctypes.builtin import set_errno, set_last_error
+from _ctypes.primitive import SimpleType
+
 # XXX this file needs huge refactoring I fear
 
 PARAMFLAG_FIN   = 0x1
 PARAMFLAG_FOUT  = 0x2
 PARAMFLAG_FLCID = 0x4
+PARAMFLAG_COMBINED = PARAMFLAG_FIN | PARAMFLAG_FOUT | PARAMFLAG_FLCID
+
+VALID_PARAMFLAGS = (
+    0,
+    PARAMFLAG_FIN,
+    PARAMFLAG_FIN | PARAMFLAG_FOUT,
+    PARAMFLAG_FIN | PARAMFLAG_FLCID
+    )
+
+WIN64 = sys.platform == 'win32' and sys.maxint == 2**63 - 1
+
 def get_com_error(errcode, riid, pIunk):
     "Win32 specific: build a COM Error exception"
     # XXX need C support code
     from _ctypes import COMError
     return COMError(errcode, None, None)
 
+def call_function(func, args):
+    "Only for debugging so far: So that we can call CFunction instances"
+    funcptr = CFuncPtr(func)
+    funcptr.restype = int
+    return funcptr(*args)
+
 class CFuncPtrType(_CDataMeta):
     # XXX write down here defaults and such things
 
 
     def _getargtypes(self):
         return self._argtypes_
+
     def _setargtypes(self, argtypes):
         self._ptr = None
         if argtypes is None:
-            self._argtypes_ = None
+            self._argtypes_ = ()
         else:
             for i, argtype in enumerate(argtypes):
                 if not hasattr(argtype, 'from_param'):
                         "item %d in _argtypes_ has no from_param method" % (
                             i + 1,))
             self._argtypes_ = argtypes
+
     argtypes = property(_getargtypes, _setargtypes)
 
+    def _getparamflags(self):
+        return self._paramflags
+
+    def _setparamflags(self, paramflags):
+        if paramflags is None or not self._argtypes_:
+            self._paramflags = None
+            return
+        if not isinstance(paramflags, tuple):
+            raise TypeError("paramflags must be a tuple or None")
+        if len(paramflags) != len(self._argtypes_):
+            raise ValueError("paramflags must have the same length as argtypes")
+        for idx, paramflag in enumerate(paramflags):
+            paramlen = len(paramflag)
+            name = default = None
+            if paramlen == 1:
+                flag = paramflag[0]
+            elif paramlen == 2:
+                flag, name = paramflag
+            elif paramlen == 3:
+                flag, name, default = paramflag
+            else:
+                raise TypeError(
+                    "paramflags must be a sequence of (int [,string [,value]]) "
+                    "tuples"
+                    )
+            if not isinstance(flag, int):
+                raise TypeError(
+                    "paramflags must be a sequence of (int [,string [,value]]) "
+                    "tuples"
+                    )
+            _flag = flag & PARAMFLAG_COMBINED
+            if _flag == PARAMFLAG_FOUT:
+                typ = self._argtypes_[idx]
+                if getattr(typ, '_ffiargshape', None) not in ('P', 'z', 'Z'):
+                    raise TypeError(
+                        "'out' parameter %d must be a pointer type, not %s"
+                        % (idx+1, type(typ).__name__)
+                        )
+            elif _flag not in VALID_PARAMFLAGS:
+                raise TypeError("paramflag value %d not supported" % flag)
+        self._paramflags = paramflags
+
+    paramflags = property(_getparamflags, _setparamflags)
+
     def _getrestype(self):
         return self._restype_
+
     def _setrestype(self, restype):
         self._ptr = None
         if restype is int:
             from ctypes import c_int
             restype = c_int
-        if not isinstance(restype, _CDataMeta) and not restype is None and \
-               not callable(restype):
-            raise TypeError("Expected ctypes type, got %s" % (restype,))
+        if not (isinstance(restype, _CDataMeta) or restype is None or
+                callable(restype)):
+            raise TypeError("restype must be a type, a callable, or None")
         self._restype_ = restype
+
     def _delrestype(self):
         self._ptr = None
         del self._restype_
+
     restype = property(_getrestype, _setrestype, _delrestype)
 
     def _geterrcheck(self):
         return getattr(self, '_errcheck_', None)
+
     def _seterrcheck(self, errcheck):
         if not callable(errcheck):
             raise TypeError("The errcheck attribute must be callable")
         self._errcheck_ = errcheck
+
     def _delerrcheck(self):
         try:
             del self._errcheck_
         except AttributeError:
             pass
+
     errcheck = property(_geterrcheck, _seterrcheck, _delerrcheck)
 
     def _ffishapes(self, args, restype):
+        if args is None:
+            args = []
         argtypes = [arg._ffiargshape for arg in args]
         if restype is not None:
             if not isinstance(restype, SimpleType):
             self._buffer = _rawffi.Array('P')(1)
             return
 
-        args = list(args)
-        argument = args.pop(0)
+        argsl = list(args)
+        argument = argsl.pop(0)
 
         # Direct construction from raw address
-        if isinstance(argument, (int, long)) and not args:
+        if isinstance(argument, (int, long)) and not argsl:
             ffiargs, ffires = self._ffishapes(self._argtypes_, self._restype_)
             self._ptr = _rawffi.FuncPtr(argument, ffiargs, ffires, self._flags_)
             self._buffer = self._ptr.byptr()
             return
 
-        # A callback into python
-        if callable(argument) and not args:
+        # A callback into Python
+        if callable(argument) and not argsl:
             self.callable = argument
             ffiargs, ffires = self._ffishapes(self._argtypes_, self._restype_)
             if self._restype_ is None:
         # Function exported from a shared library
         if isinstance(argument, tuple) and len(argument) == 2: