[pypy-svn] pypy commit 432ce85db2a3: hg merge default

Bitbucket commits-noreply at bitbucket.org
Thu Dec 16 00:09:54 CET 2010


# HG changeset patch -- Bitbucket.org
# Project pypy
# URL http://bitbucket.org/pypy/pypy/overview
# User Amaury Forgeot d'Arc <amauryfa at gmail.com>
# Date 1292454635 -3600
# Node ID 432ce85db2a310d342f4edc12284b762f4823fce
# Parent  9a60739ea7531597d69b1cfba6ff6e62a1e28301
# Parent  2088ce763fc22fbd4b5912e03bd5dc59e066b657
hg merge default

--- a/pypy/module/test_lib_pypy/conftest.py
+++ /dev/null
@@ -1,25 +0,0 @@
-import py
-import sys
-
-def pytest_collect_directory():
-    if '__pypy__' not in sys.builtin_module_names:
-        py.test.skip("these tests are meant to be run on top of pypy-c")
-
-def compile_so_file():
-    from pypy.translator.platform import platform
-    from pypy.translator.tool.cbuild import ExternalCompilationInfo
-    udir = py.test.ensuretemp('_ctypes_test')
-    cfile = py.path.local(__file__).dirpath().join("ctypes_tests", "_ctypes_test.c")
-
-    if sys.platform == 'win32':
-        libraries = ['oleaut32']
-    else:
-        libraries = []
-    eci = ExternalCompilationInfo(libraries=libraries)
-
-    return platform.compile([cfile], eci, str(udir.join('_ctypes_test')),
-                            standalone=False)
-
-def pytest_configure(config):
-    global sofile
-    sofile = compile_so_file()

--- a/pypy/objspace/std/test/test_dictmultiobject.py
+++ b/pypy/objspace/std/test/test_dictmultiobject.py
@@ -505,6 +505,7 @@ class AppTest_DictMultiObject(AppTest_Di
 
     def test_emptydict_unhashable(self):
         raises(TypeError, "{}[['x']]")
+        raises(TypeError, "del {}[['x']]")
 
     def test_string_subclass_via_setattr(self):
         class A(object):

--- a/pypy/module/sys/__init__.py
+++ b/pypy/module/sys/__init__.py
@@ -62,7 +62,6 @@ class Module(MixedModule):
         'version_info'          : 'version.get_version_info(space)',
         'version'               : 'version.get_version(space)',
         'pypy_version_info'     : 'version.get_pypy_version_info(space)',
-        'pypy_svn_url'          : 'version.get_svn_url(space)',
         'subversion'            : 'version.get_subversion_info(space)',
         '_mercurial'            : 'version.wrap_mercurial_info(space)',
         'hexversion'            : 'version.get_hexversion(space)',

--- a/pypy/objspace/std/dictmultiobject.py
+++ b/pypy/objspace/std/dictmultiobject.py
@@ -56,8 +56,8 @@ class W_DictMultiObject(W_Object):
         else:
             if w_type is None:
                 w_type = space.w_dict
-            w_self = space.allocate_instance(EmptyDictImplementation, w_type)
-            EmptyDictImplementation.__init__(w_self, space)
+            w_self = space.allocate_instance(W_DictMultiObject, w_type)
+            W_DictMultiObject.__init__(w_self, space)
             return w_self
 
     def __init__(self, space):
@@ -98,29 +98,39 @@ class W_DictMultiObject(W_Object):
     # implementation methods
     def impl_getitem(self, w_key):
         #return w_value or None
-        raise NotImplementedError("abstract base class")
+        # in case the key is unhashable, try to hash it
+        self.space.hash(w_key)
+        # return None anyway
+        return None
 
     def impl_getitem_str(self, key):
         #return w_value or None
-        raise NotImplementedError("abstract base class")
+        return None
+
+    def impl_setitem(self, w_key, w_value):
+        self._as_rdict().impl_fallback_setitem(w_key, w_value)
 
     def impl_setitem_str(self, key, w_value):
-        raise NotImplementedError("abstract base class")
-
-    def impl_setitem(self, w_key, w_value):
-        raise NotImplementedError("abstract base class")
+        self._as_rdict().impl_fallback_setitem_str(key, w_value)
 
     def impl_delitem(self, w_key):
-        raise NotImplementedError("abstract base class")
+        # in case the key is unhashable, try to hash it
+        self.space.hash(w_key)
+        raise KeyError
 
     def impl_length(self):
-        raise NotImplementedError("abstract base class")
+        return 0
 
     def impl_iter(self):
-        raise NotImplementedError("abstract base class")
+        # XXX I guess it's not important to be fast in this case?
+        return self._as_rdict().impl_fallback_iter()
 
     def impl_clear(self):
-        raise NotImplementedError("abstract base class")
+        self.r_dict_content = None
+
+    def _as_rdict(self):
+        r_dict_content = self.initialize_as_rdict()
+        return self
 
     def impl_keys(self):
         iterator = self.impl_iter()
@@ -408,45 +418,6 @@ class WaryDictImplementation(StrDictImpl
         return self.shadowed[i]
 
 
-class EmptyDictImplementation(W_DictMultiObject):
-    def __init__(self, space):
-        self.space = space
-
-    def impl_setitem(self, w_key, w_value):
-        self._as_rdict().impl_fallback_setitem(w_key, w_value)
-
-    def impl_setitem_str(self, key, w_value):
-        self._as_rdict().impl_fallback_setitem_str(key, w_value)
-
-    def impl_delitem(self, w_key):
-        raise KeyError
-
-    def impl_length(self):
-        return 0
-
-    def impl_getitem_str(self, key):
-        return None
-
-    def impl_getitem(self, w_key):
-        # in case the key is unhashable, try to hash it
-        self.space.hash(w_key)
-        # return None anyway
-        return None
-
-    def impl_iter(self):
-        # XXX I guess it's not important to be fast in this case?
-        return self._as_rdict().impl_fallback_iter()
-
-    def impl_clear(self):
-        self.r_dict_content = None
-
-    def _as_rdict(self):
-        r_dict_content = self.initialize_as_rdict()
-        return self
-
-    def _clear_fields(self):
-        pass
-
 class RDictIteratorImplementation(IteratorImplementation):
     def __init__(self, space, dictimplementation):
         IteratorImplementation.__init__(self, space, dictimplementation)

--- a/pypy/rpython/memory/gc/env.py
+++ b/pypy/rpython/memory/gc/env.py
@@ -51,7 +51,7 @@ def read_float_from_env(varname):
 # ____________________________________________________________
 # Get the total amount of RAM installed in a system.
 # On 32-bit systems, it will try to return at most the addressable size.
-# Note that if unknown it will just return the addressable size, which
+# If unknown, it will just return the addressable size, which
 # will be huge on 64-bit systems.
 
 if sys.maxint == 2147483647:    # 32-bit

--- a/pypy/module/sys/version.py
+++ b/pypy/module/sys/version.py
@@ -9,13 +9,7 @@ from pypy.translator.platform import pla
 CPYTHON_VERSION            = (2, 7, 0, "final", 42)   #XXX # sync patchlevel.h
 CPYTHON_API_VERSION        = 1012   #XXX # sync with include/modsupport.h
 
-PYPY_VERSION               = (1, 4, 0, "beta", '?')  #XXX # sync patchlevel.h
-# the last item is replaced by the svn revision ^^^
-
-TRIM_URL_UP_TO = 'svn/pypy/'
-SVN_URL = """$HeadURL$"""[10:-28]
-
-REV = """$LastChangedRevision$"""[22:-2]
+PYPY_VERSION               = (1, 4, 0, "beta", 0)    #XXX # sync patchlevel.h
 
 if platform.name == 'msvc':
     COMPILER_INFO = 'MSC v.%d 32 bit' % (platform.version * 10 + 600)
@@ -29,18 +23,6 @@ elif platform.cc == 'gcc':
 else:
     COMPILER_INFO = ""
 
-def rev2int(rev):
-    try:
-        return int(rev)
-    except ValueError:
-        import py
-        from pypy.tool.ansi_print import ansi_log
-        log = py.log.Producer("version")
-        py.log.setconsumer("version", ansi_log)
-        log.ERROR("No subversion revision number available!")
-        log.ERROR("Hard-coding '0'")
-        return 0
-
 
 import pypy
 pypydir = os.path.dirname(os.path.abspath(pypy.__file__))
@@ -62,11 +44,11 @@ def get_version_info(space):
     return space.wrap(CPYTHON_VERSION)
 
 def get_version(space):
-    return space.wrap("%d.%d.%d (%d, %s, %s)\n[PyPy %d.%d.%d%s]" % (
+    return space.wrap("%d.%d.%d (%s, %s, %s)\n[PyPy %d.%d.%d%s]" % (
         CPYTHON_VERSION[0],
         CPYTHON_VERSION[1],
         CPYTHON_VERSION[2],
-        svn_revision(),
+        hg_universal_id(),
         date,
         time,
         PYPY_VERSION[0],
@@ -84,20 +66,11 @@ def get_hexversion(space):
 
 def get_pypy_version_info(space):
     ver = PYPY_VERSION
-    ver = ver[:-1] + (svn_revision(),)
+    #ver = ver[:-1] + (svn_revision(),)
     return space.wrap(ver)
 
-def get_svn_url(space):
-    return space.wrap((SVN_URL, svn_revision()))
-
 def get_subversion_info(space):
-    svnbranch = SVN_URL
-    if TRIM_URL_UP_TO in svnbranch:
-        svnbranch = svnbranch.split(TRIM_URL_UP_TO, 1)[1]
-    svnbranch = svnbranch.strip('/')
-    return space.newtuple([space.wrap('PyPy'),
-                           space.wrap(svnbranch),
-                           space.wrap(str(svn_revision()))])
+    return space.wrap(('PyPy', '', ''))
 
 
 def wrap_mercurial_info(space):
@@ -110,6 +83,13 @@ def wrap_mercurial_info(space):
     else:
         return space.w_None
 
+def hg_universal_id():
+    info = get_mercurial_info()
+    if info:
+        return info[2]
+    else:
+        return '?'
+
 
 def tuple2hex(ver):
     d = {'alpha':     0xA,
@@ -126,42 +106,6 @@ def tuple2hex(ver):
             d[ver[3]] << 4 |
             subver)
 
-def svn_revision():
-    "Return the last-changed svn revision number."
-    # NB. we hack the number directly out of the .svn directory to avoid
-    # to depend on an external 'svn' executable in the path.
-    rev = rev2int(REV)
-    try:
-        formatfile = os.path.join(pypydir, '.svn', 'format')
-        if os.path.exists(formatfile):
-            f = open(formatfile, 'r')
-            format = int(f.readline().strip())
-            f.close()
-            oldformat = (format <= 6) # Old XML-format
-        else:
-            oldformat = False
-        if oldformat:
-            f = open(os.path.join(pypydir, '.svn', 'entries'), 'r')
-            for line in f:
-                line = line.strip()
-                if line.startswith('committed-rev="') and line.endswith('"'):
-                    rev = int(line[15:-1])
-                    break
-            f.close()
-        else: # New format
-            f = open(os.path.join(pypydir, '.svn', 'entries'), 'r')
-            format = int(f.readline().strip())
-            for entry in f.read().split('\f'):
-                lines = entry.split('\n')
-                name, kind, revstr = lines[:3]
-                if name == '' and kind == 'dir': # The current directory
-                    rev = int(revstr)
-                    break
-            f.close()
-    except (IOError, OSError):
-        pass
-    return rev
-
 def compiler_version():
     if not COMPILER_INFO:
         return ""

--- a/pypy/module/sys/test/test_sysmodule.py
+++ b/pypy/module/sys/test/test_sysmodule.py
@@ -462,9 +462,6 @@ class AppTestSysModulePortedFromCPython:
 
     def test_pypy_attributes(self):
         assert isinstance(sys.pypy_objspaceclass, str)
-        assert isinstance(sys.pypy_svn_url, tuple)
-        url = sys.pypy_svn_url
-        assert isinstance(url[0], str)
         vi = sys.pypy_version_info
         assert isinstance(vi, tuple)
         assert len(vi) == 5
@@ -473,16 +470,12 @@ class AppTestSysModulePortedFromCPython:
         assert isinstance(vi[2], int)
         assert vi[3] in ("alpha", "beta", "candidate", "final")
         assert isinstance(vi[4], int)
-        assert url[1] == vi[4]
 
     def test_allattributes(self):
         sys.__dict__   # check that we don't crash initializing any attribute
 
     def test_subversion(self):
-        project, svnbranch, revision = sys.subversion
-        assert project == 'PyPy'
-        assert svnbranch == svnbranch.strip('/')
-        assert revision.isdigit()
+        assert sys.subversion == ('PyPy', '', '')
 
     def test__mercurial(self):
         import re
@@ -493,6 +486,9 @@ class AppTestSysModulePortedFromCPython:
         # the id is either nothing, or an id of 12 hash digits, with a possible
         # suffix of '+' if there are local modifications
         assert hgid == '' or re.match('[0-9a-f]{12}\+?', hgid)
+        # the id should also show up in sys.version
+        if hgid != '':
+            assert hgid in sys.version
 
     def test_trace_exec_execfile(self):
         found = []

--- a/pypy/module/sys/test/test_version.py
+++ b/pypy/module/sys/test/test_version.py
@@ -1,9 +1,3 @@
-from pypy.module.sys.version import rev2int
-
-def test_rev2int():
-    assert rev2int("71630") == 71630
-    assert rev2int("") == 0
-
 class AppTestVersion:
     def test_compiler(self):
         import sys

--- a/pypy/objspace/std/objspace.py
+++ b/pypy/objspace/std/objspace.py
@@ -322,6 +322,14 @@ class StdObjSpace(ObjSpace, DescrOperati
             w_subtype = w_type.check_user_subclass(w_subtype)
             if cls.typedef.applevel_subclasses_base is not None:
                 cls = cls.typedef.applevel_subclasses_base
+            #
+            if not we_are_translated():
+                if issubclass(cls, model.W_Object):
+                    # If cls is missing from model.typeorder, then you
+                    # need to add it there (including the inheritance
+                    # relationship, if any)
+                    assert cls in self.model.typeorder, repr(cls)
+            #
             if (self.config.objspace.std.withmapdict and cls is W_ObjectObject
                     and not w_subtype.needsdel):
                 from pypy.objspace.std.mapdict import get_subclass_of_correct_size

--- a/pypy/translator/goal/app_main.py
+++ b/pypy/translator/goal/app_main.py
@@ -585,6 +585,8 @@ def entry_point(executable, argv, nanos)
     except CommandLineError, e:
         print_error(str(e))
         return 2
+    except SystemExit, e:
+        return e.code or 0
     setup_initial_paths(**cmdline)
     return run_command_line(**cmdline)
 

--- a/pypy/module/cpyext/conftest.py
+++ b/pypy/module/cpyext/conftest.py
@@ -1,12 +1,12 @@
 import py
 from pypy.conftest import option, gettestobjspace
 
-def pytest_collect_directory(parent):
-    if parent.config.option.runappdirect:
-        py.test.skip("cannot be run by py.test -A")
-
+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', '_rawffi'])



More information about the Pypy-commit mailing list