[pypy-svn] pypy fast-forward: hg merge default

amauryfa commits-noreply at bitbucket.org
Mon Jan 3 20:26:48 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: fast-forward
Changeset: r40353:0584b336bcd3
Date: 2011-01-03 20:25 +0100
http://bitbucket.org/pypy/pypy/changeset/0584b336bcd3/

Log:	hg merge default

diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -506,7 +506,7 @@
                                   " objects doesn't apply to '%s' object",
                                   self.name,
                                   self.w_cls.name,
-                                  space.type(w_obj).getname(space, '?'))
+                                  space.type(w_obj).getname(space))
     
     def descr_member_get(space, member, w_obj, w_w_cls=None):
         """member.__get__(obj[, type]) -> value
@@ -583,7 +583,7 @@
 def descr_get_dict(space, w_obj):
     w_dict = w_obj.getdict()
     if w_dict is None:
-        typename = space.type(w_obj).getname(space, '?')
+        typename = space.type(w_obj).getname(space)
         raise operationerrfmt(space.w_TypeError,
                               "descriptor '__dict__' doesn't apply to"
                               " '%s' objects", typename)

diff --git a/pypy/translator/goal/app_main.py b/pypy/translator/goal/app_main.py
--- a/pypy/translator/goal/app_main.py
+++ b/pypy/translator/goal/app_main.py
@@ -5,11 +5,11 @@
 options:
   -i             inspect interactively after running script
   -O             dummy optimization flag for compatibility with C Python
-  -c CMD         program passed in as CMD (terminates option list)
+  -c cmd         program passed in as CMD (terminates option list)
   -S             do not 'import site' on initialization
   -u             unbuffered binary stdout and stderr
   -h, --help     show this help message and exit
-  -m             library module to be run as a script (terminates option list)
+  -m mod         library module to be run as a script (terminates option list)
   -W arg         warning control (arg is action:message:category:module:lineno)
   -E             ignore environment variables (such as PYTHONPATH)
   --version      print the PyPy version
@@ -128,7 +128,8 @@
     raise SystemExit
 
 def print_help(*args):
-    print 'usage: %s [options]' % (sys.executable,)
+    print 'usage: %s [options] [-c cmd|-m mod|file.py|-] [arg...]' % (
+        sys.executable,)
     print __doc__.rstrip()
     if 'pypyjit' in sys.builtin_module_names:
         _print_jit_help()

diff --git a/pypy/objspace/std/ropeunicodeobject.py b/pypy/objspace/std/ropeunicodeobject.py
--- a/pypy/objspace/std/ropeunicodeobject.py
+++ b/pypy/objspace/std/ropeunicodeobject.py
@@ -30,7 +30,7 @@
         raise operationerrfmt(
             space.w_TypeError,
             "decoder did not return an unicode object (type '%s')",
-            space.type(w_retval).getname(space, '?'))
+            space.type(w_retval).getname(space))
     assert isinstance(w_retval, W_RopeUnicodeObject)
     return w_retval
 

diff --git a/pypy/rpython/memory/test/test_transformed_gc.py b/pypy/rpython/memory/test/test_transformed_gc.py
--- a/pypy/rpython/memory/test/test_transformed_gc.py
+++ b/pypy/rpython/memory/test/test_transformed_gc.py
@@ -1482,7 +1482,6 @@
                          'arena_size': 64*WORD,
                          'small_request_threshold': 5*WORD,
                          'large_object': 8*WORD,
-                         'large_object_gcptrs': 10*WORD,
                          'card_page_indices': 4,
                          'translated_to_c': False,
                          }

diff --git a/pypy/objspace/descroperation.py b/pypy/objspace/descroperation.py
--- a/pypy/objspace/descroperation.py
+++ b/pypy/objspace/descroperation.py
@@ -30,7 +30,7 @@
 
 def raiseattrerror(space, w_obj, name, w_descr=None):
     w_type = space.type(w_obj)
-    typename = w_type.getname(space, '?')
+    typename = w_type.getname(space)
     if w_descr is None:
         raise operationerrfmt(space.w_AttributeError,
                               "'%s' object has no attribute '%s'",
@@ -138,7 +138,7 @@
             return w_obj.call_args(args)
         w_descr = space.lookup(w_obj, '__call__')
         if w_descr is None:
-            typename = space.type(w_obj).getname(space, '?')
+            typename = space.type(w_obj).getname(space)
             raise operationerrfmt(space.w_TypeError,
                                   "'%s' object is not callable",
                                   typename)
@@ -155,7 +155,7 @@
     def set(space, w_descr, w_obj, w_val):
         w_set = space.lookup(w_descr, '__set__')
         if w_set is None:
-            typename = space.type(w_descr).getname(space, '?')
+            typename = space.type(w_descr).getname(space)
             raise operationerrfmt(space.w_TypeError,
                                   "'%s' object is not a descriptor with set",
                                   typename)
@@ -164,7 +164,7 @@
     def delete(space, w_descr, w_obj):
         w_delete = space.lookup(w_descr, '__delete__')
         if w_delete is None:
-            typename = space.type(w_descr).getname(space, '?')
+            typename = space.type(w_descr).getname(space)
             raise operationerrfmt(space.w_TypeError,
                                   "'%s' object is not a descriptor with delete",
                                   typename)
@@ -191,7 +191,7 @@
     def setattr(space, w_obj, w_name, w_val):
         w_descr = space.lookup(w_obj, '__setattr__')
         if w_descr is None:
-            typename = space.type(w_obj).getname(space, '?')
+            typename = space.type(w_obj).getname(space)
             raise operationerrfmt(space.w_AttributeError,
                                   "'%s' object is readonly",
                                   typename)
@@ -200,7 +200,7 @@
     def delattr(space, w_obj, w_name):
         w_descr = space.lookup(w_obj, '__delattr__')
         if w_descr is None:
-            typename = space.type(w_obj).getname(space, '?')
+            typename = space.type(w_obj).getname(space)
             raise operationerrfmt(space.w_AttributeError,
                                   "'%s' object does not support attribute removal",
                                   typename)
@@ -241,7 +241,7 @@
         if w_descr is None:
             w_descr = space.lookup(w_obj, '__getitem__')
             if w_descr is None:
-                typename = space.type(w_obj).getname(space, '?')
+                typename = space.type(w_obj).getname(space)
                 raise operationerrfmt(space.w_TypeError,
                                       "'%s' object is not iterable",
                                       typename)
@@ -256,7 +256,7 @@
     def next(space, w_obj):
         w_descr = space.lookup(w_obj, 'next')
         if w_descr is None:
-            typename = space.type(w_obj).getname(space, '?')
+            typename = space.type(w_obj).getname(space)
             raise operationerrfmt(space.w_TypeError,
                                   "'%s' object is not an iterator",
                                   typename)
@@ -265,7 +265,7 @@
     def getitem(space, w_obj, w_key):
         w_descr = space.lookup(w_obj, '__getitem__')
         if w_descr is None:
-            typename = space.type(w_obj).getname(space, '?')
+            typename = space.type(w_obj).getname(space)
             raise operationerrfmt(space.w_TypeError,
                                   "'%s' object is not subscriptable",
                                   typename)
@@ -274,7 +274,7 @@
     def setitem(space, w_obj, w_key, w_val):
         w_descr = space.lookup(w_obj, '__setitem__')
         if w_descr is None:
-            typename = space.type(w_obj).getname(space, '?')
+            typename = space.type(w_obj).getname(space)
             raise operationerrfmt(space.w_TypeError,
                               "'%s' object does not support item assignment",
                                   typename)
@@ -283,7 +283,7 @@
     def delitem(space, w_obj, w_key):
         w_descr = space.lookup(w_obj, '__delitem__')
         if w_descr is None:
-            typename = space.type(w_obj).getname(space, '?')
+            typename = space.type(w_obj).getname(space)
             raise operationerrfmt(space.w_TypeError,
                                 "'%s' object does not support item deletion",
                                   typename)
@@ -658,8 +658,8 @@
         w_res = _invoke_binop(space, w_right_impl, w_obj2, w_obj1)
         if w_res is not None:
             return w_res
-        typename1 = w_typ1.getname(space, '?')
-        typename2 = w_typ2.getname(space, '?')
+        typename1 = w_typ1.getname(space)
+        typename2 = w_typ2.getname(space)
         raise operationerrfmt(space.w_TypeError, errormsg,
                               typename1, typename2)
     
@@ -721,7 +721,7 @@
     def unaryop_impl(space, w_obj):
         w_impl = space.lookup(w_obj, specialname)
         if w_impl is None:
-            typename = space.type(w_obj).getname(space, '?')
+            typename = space.type(w_obj).getname(space)
             raise operationerrfmt(space.w_TypeError, errormsg, typename)
         return space.get_and_call_function(w_impl, w_obj)
     return func_with_new_name(unaryop_impl, 'unaryop_%s_impl'%specialname.strip('_'))
@@ -743,7 +743,7 @@
         def %(targetname)s(space, w_obj):
             w_impl = space.lookup(w_obj, %(specialname)r)
             if w_impl is None:
-                typename = space.type(w_obj).getname(space, '?')
+                typename = space.type(w_obj).getname(space)
                 raise operationerrfmt(space.w_TypeError,
                       "unsupported operand type for %(targetname)s(): '%%s'",
                                       typename)
@@ -751,7 +751,7 @@
 
             if %(checker)s: 
                 return w_result
-            typename = space.type(w_result).getname(space, '?')
+            typename = space.type(w_result).getname(space)
             msg = "%(specialname)s returned non-%(targetname)s (type '%%s')"
             raise operationerrfmt(space.w_TypeError, msg, typename)
         assert not hasattr(DescrOperation, %(targetname)r)
@@ -770,7 +770,7 @@
         def %(targetname)s(space, w_obj):
             w_impl = space.lookup(w_obj, %(specialname)r)
             if w_impl is None:
-                typename = space.type(w_obj).getname(space, '?')
+                typename = space.type(w_obj).getname(space)
                 raise operationerrfmt(space.w_TypeError,
                       "unsupported operand type for %(targetname)s(): '%%s'",
                                       typename)
@@ -783,7 +783,7 @@
             except OperationError, e:
                 if not e.match(space, space.w_TypeError):
                     raise
-                typename = space.type(w_result).getname(space, '?')
+                typename = space.type(w_result).getname(space)
                 msg = "%(specialname)s returned non-%(targetname)s (type '%%s')"
                 raise operationerrfmt(space.w_TypeError, msg, typename)
             else:

diff --git a/pypy/objspace/std/objecttype.py b/pypy/objspace/std/objecttype.py
--- a/pypy/objspace/std/objecttype.py
+++ b/pypy/objspace/std/objecttype.py
@@ -11,7 +11,7 @@
 def descr__repr__(space, w_obj):
     w = space.wrap
     w_type = space.type(w_obj)
-    classname = w_type.getname(space, '?')
+    classname = w_type.getname(space)
     w_module = w_type.lookup("__module__")
     if w_module is not None:
         try:
@@ -34,7 +34,7 @@
     if not isinstance(w_newcls, W_TypeObject):
         raise operationerrfmt(space.w_TypeError,
                               "__class__ must be set to new-style class, not '%s' object",
-                              space.type(w_newcls).getname(space, '?'))
+                              space.type(w_newcls).getname(space))
     if not w_newcls.is_heaptype():
         raise OperationError(space.w_TypeError,
                              space.wrap("__class__ assignment: only for heap types"))
@@ -46,7 +46,7 @@
     else:
         raise operationerrfmt(space.w_TypeError,
                               "__class__ assignment: '%s' object layout differs from '%s'",
-                              w_oldcls.getname(space, '?'), w_newcls.getname(space, '?'))
+                              w_oldcls.getname(space), w_newcls.getname(space))
 
 
 app = gateway.applevel("""

diff --git a/pypy/objspace/std/unicodetype.py b/pypy/objspace/std/unicodetype.py
--- a/pypy/objspace/std/unicodetype.py
+++ b/pypy/objspace/std/unicodetype.py
@@ -241,7 +241,7 @@
     if not space.is_true(space.isinstance(w_retval, space.w_str)):
         raise operationerrfmt(space.w_TypeError,
             "encoder did not return an string object (type '%s')",
-            space.type(w_retval).getname(space, '?'))
+            space.type(w_retval).getname(space))
     return w_retval
 
 def decode_object(space, w_obj, encoding, errors):
@@ -274,7 +274,7 @@
     if not space.is_true(space.isinstance(w_retval, space.w_unicode)):
         raise operationerrfmt(space.w_TypeError,
             "decoder did not return an unicode object (type '%s')",
-            space.type(w_retval).getname(space, '?'))
+            space.type(w_retval).getname(space))
     return w_retval
 
 def unicode_from_object(space, w_obj):

diff --git a/pypy/rpython/memory/gc/minimark.py b/pypy/rpython/memory/gc/minimark.py
--- a/pypy/rpython/memory/gc/minimark.py
+++ b/pypy/rpython/memory/gc/minimark.py
@@ -177,14 +177,10 @@
         "card_page_indices": 128,
 
         # Objects whose total size is at least 'large_object' bytes are
-        # allocated out of the nursery immediately.  If the object
-        # has GC pointers in its varsized part, we use instead the
-        # higher limit 'large_object_gcptrs'.  The idea is that
-        # separately allocated objects are allocated immediately "old"
-        # and it's not good to have too many pointers from old to young
-        # objects.
-        "large_object": 1600*WORD,
-        "large_object_gcptrs": 8250*WORD,
+        # allocated out of the nursery immediately, as old objects.  The
+        # minimal allocated size of the nursery is 1.9x the following
+        # number (by default, at least 500KB on 32-bit and 1000KB on 64-bit).
+        "large_object": 65792*WORD,
         }
 
     def __init__(self, config,
@@ -197,7 +193,6 @@
                  growth_rate_max=2.5,   # for tests
                  card_page_indices=0,
                  large_object=8*WORD,
-                 large_object_gcptrs=10*WORD,
                  ArenaCollectionClass=None,
                  **kwds):
         MovingGCBase.__init__(self, config, **kwds)
@@ -219,12 +214,9 @@
             while (1 << self.card_page_shift) < self.card_page_indices:
                 self.card_page_shift += 1
         #
-        # 'large_object' and 'large_object_gcptrs' limit how big objects
-        # can be in the nursery, so they give a lower bound on the allowed
-        # size of the nursery.
+        # 'large_object' limit how big objects can be in the nursery, so
+        # it gives a lower bound on the allowed size of the nursery.
         self.nonlarge_max = large_object - 1
-        self.nonlarge_gcptrs_max = large_object_gcptrs - 1
-        assert self.nonlarge_max <= self.nonlarge_gcptrs_max
         #
         self.nursery      = NULL
         self.nursery_free = NULL
@@ -291,7 +283,9 @@
         else:
             #
             defaultsize = self.nursery_size
-            minsize = 2 * (self.nonlarge_gcptrs_max + 1)
+            minsize = int(1.9 * self.nonlarge_max)
+            if we_are_translated():
+                minsize = (minsize + 4095) & ~4095
             self.nursery_size = minsize
             self.allocate_nursery()
             #
@@ -303,8 +297,8 @@
             # forces a minor collect for every malloc.  Useful to debug
             # external factors, like trackgcroot or the handling of the write
             # barrier.  Implemented by still using 'minsize' for the nursery
-            # size (needed to handle e.g. mallocs of 8249 words) but hacking
-            # at the current nursery position in collect_and_reserve().
+            # size (needed to handle mallocs just below 'large_objects') but
+            # hacking at the current nursery position in collect_and_reserve().
             if newsize <= 0:
                 newsize = env.estimate_best_nursery_size()
                 if newsize <= 0:
@@ -345,7 +339,7 @@
 
 
     def _nursery_memory_size(self):
-        extra = self.nonlarge_gcptrs_max + 1
+        extra = self.nonlarge_max + 1
         return self.nursery_size + extra
 
     def _alloc_nursery(self):
@@ -489,16 +483,11 @@
         # below 'nonlarge_max'.  All the following logic is usually
         # constant-folded because self.nonlarge_max, size and itemsize
         # are all constants (the arguments are constant due to
-        # inlining) and self.has_gcptr_in_varsize() is constant-folded.
-        if self.has_gcptr_in_varsize(typeid):
-            nonlarge_max = self.nonlarge_gcptrs_max
+        # inlining).
+        if not raw_malloc_usage(itemsize):
+            too_many_items = raw_malloc_usage(nonvarsize) > self.nonlarge_max
         else:
-            nonlarge_max = self.nonlarge_max
-
-        if not raw_malloc_usage(itemsize):
-            too_many_items = raw_malloc_usage(nonvarsize) > nonlarge_max
-        else:
-            maxlength = nonlarge_max - raw_malloc_usage(nonvarsize)
+            maxlength = self.nonlarge_max - raw_malloc_usage(nonvarsize)
             maxlength = maxlength // raw_malloc_usage(itemsize)
             too_many_items = length > maxlength
 
@@ -623,7 +612,7 @@
             # Check if we need to introduce the card marker bits area.
             if (self.card_page_indices <= 0  # <- this check is constant-folded
                 or not self.has_gcptr_in_varsize(typeid) or
-                raw_malloc_usage(totalsize) <= self.nonlarge_gcptrs_max):
+                raw_malloc_usage(totalsize) <= self.nonlarge_max):
                 #
                 # In these cases, we don't want a card marker bits area.
                 # This case also includes all fixed-size objects.

diff --git a/pypy/translator/goal/targetpypystandalone.py b/pypy/translator/goal/targetpypystandalone.py
--- a/pypy/translator/goal/targetpypystandalone.py
+++ b/pypy/translator/goal/targetpypystandalone.py
@@ -65,7 +65,7 @@
             ##    con.interact()
             except OperationError, e:
                 debug("OperationError:")
-                debug(" operror-type: " + e.w_type.getname(space, '?'))
+                debug(" operror-type: " + e.w_type.getname(space))
                 debug(" operror-value: " + space.str_w(space.str(e.get_w_value(space))))
                 return 1
         finally:
@@ -75,7 +75,7 @@
                 space.timer.stop("space.finish")
             except OperationError, e:
                 debug("OperationError:")
-                debug(" operror-type: " + e.w_type.getname(space, '?'))
+                debug(" operror-type: " + e.w_type.getname(space))
                 debug(" operror-value: " + space.str_w(space.str(e.get_w_value(space))))
                 return 1
         space.timer.stop("Entrypoint")

diff --git a/pypy/interpreter/test/test_interpreter.py b/pypy/interpreter/test/test_interpreter.py
--- a/pypy/interpreter/test/test_interpreter.py
+++ b/pypy/interpreter/test/test_interpreter.py
@@ -165,11 +165,14 @@
             assert not arg_w or not space.eq_w(arg_w[-1], space.wrap(-1))
             return real_call_function(w_obj, *arg_w)
         self.space.call_function = safe_call_function
-        code = '''
-            def f():
-                import sys
-            '''
-        self.codetest(code, 'f', [])
+        try:
+            code = '''
+                def f():
+                    import sys
+                '''
+            self.codetest(code, 'f', [])
+        finally:
+            del self.space.call_function
 
     def test_call_star_starstar(self):
         code = '''\

diff --git a/pypy/tool/release/package.py b/pypy/tool/release/package.py
--- a/pypy/tool/release/package.py
+++ b/pypy/tool/release/package.py
@@ -19,7 +19,7 @@
 
 if sys.version_info < (2,6): py.test.skip("requires 2.6 so far")
 
-USE_TARFILE_MODULE = sys.platform == 'win32'
+USE_ZIPFILE_MODULE = sys.platform == 'win32'
 
 def ignore_patterns(*patterns):
     """Function that can be used as copytree() ignore parameter.
@@ -40,14 +40,26 @@
             copy_to_dir = None, override_pypy_c = None):
     basedir = py.path.local(basedir)
     if sys.platform == 'win32':
-        basename = 'pypy-c.exe'
+        # Can't rename a DLL
+        if override_pypy_c is not None:
+            rename_pypy_c = py.path.local(override_pypy_c).purebasename
+            pypy_c_dir = py.path.local(override_pypy_c).dirname
+        else:
+            pypy_c_dir = basedir.join('pypy', 'translator', 'goal')
+        pypy_c = pypy_c_dir.join(rename_pypy_c + '.exe')
+        libpypy_c = pypy_c_dir.join('lib' + rename_pypy_c + '.dll')
+        binaries = [(pypy_c, pypy_c.basename),
+                    (libpypy_c, libpypy_c.basename),
+                    (pypy_c_dir.join('libexpat.dll'), 'libexpat.dll')]
     else:
         basename = 'pypy-c'
-    if override_pypy_c is None:
-        pypy_c = basedir.join('pypy', 'translator', 'goal', basename)
-    else:
-        pypy_c = py.path.local(override_pypy_c)
+        if override_pypy_c is None:
+            pypy_c = basedir.join('pypy', 'translator', 'goal', basename)
+        else:
+            pypy_c = py.path.local(override_pypy_c)
+        binaries = [(pypy_c, rename_pypy_c)]
     if not pypy_c.check():
+        print pypy_c
         raise PyPyCNotFound('Please compile pypy first, using translate.py')
     builddir = udir.ensure("build", dir=True)
     pypydir = builddir.ensure(name, dir=True)
@@ -72,34 +84,47 @@
     spdir = pypydir.ensure('site-packages', dir=True)
     shutil.copy(str(basedir.join('site-packages', 'README')), str(spdir))
     #
-    pypydir.ensure('bin', dir=True)
-    archive_pypy_c = pypydir.join('bin', rename_pypy_c)
-    shutil.copy(str(pypy_c), str(archive_pypy_c))
+    if sys.platform == 'win32':
+        bindir = pypydir
+    else:
+        bindir = pypydir.join('bin')
+        bindir.ensure(dir=True)
+    for source, target in binaries:
+        archive = bindir.join(target)
+        shutil.copy(str(source), str(archive))
     old_dir = os.getcwd()
     try:
         os.chdir(str(builddir))
         #
         # 'strip' fun: see https://codespeak.net/issue/pypy-dev/issue587
-        if sys.platform == 'darwin':
-            os.system("strip -x " + str(archive_pypy_c))    # ignore errors
+        for source, target in binaries:
+            if sys.platform == 'win32':
+                pass
+            elif sys.platform == 'darwin':
+                os.system("strip -x " + str(bindir.join(target)))    # ignore errors
+            else:
+                os.system("strip " + str(bindir.join(target)))    # ignore errors
+        #
+        if USE_ZIPFILE_MODULE:
+            import zipfile
+            archive = str(builddir.join(name + '.zip'))
+            zf = zipfile.ZipFile(archive, 'w',
+                                 compression=zipfile.ZIP_DEFLATED)
+            for (dirpath, dirnames, filenames) in os.walk(name):
+                for fnname in filenames:
+                    filename = os.path.join(dirpath, fnname)
+                    zf.write(filename)
+            zf.close()
         else:
-            os.system("strip " + str(archive_pypy_c))    # ignore errors
-        #
-        if USE_TARFILE_MODULE:
-            import tarfile
-            tf = tarfile.open(str(builddir.join(name + '.tar.bz2')), 'w:bz2')
-            tf.add(name)
-            tf.close()
-        else:
-            e = os.system('tar cvjf ' + str(builddir.join(name + '.tar.bz2')) +
-                          " " + name)
+            archive = str(builddir.join(name + '.tar.bz2'))
+            e = os.system('tar cvjf ' + archive + " " + name)
             if e:
                 raise OSError('"tar" returned exit status %r' % e)
     finally:
         os.chdir(old_dir)
     if copy_to_dir is not None:
-        print "Copying to %s" % copy_to_dir
-        shutil.copy(str(builddir.join(name + '.tar.bz2')), copy_to_dir)
+        print "Copying %s to %s" % (archive, copy_to_dir)
+        shutil.copy(archive, str(copy_to_dir))
     return builddir # for tests
 
 if __name__ == '__main__':

diff --git a/pypy/objspace/std/ropeobject.py b/pypy/objspace/std/ropeobject.py
--- a/pypy/objspace/std/ropeobject.py
+++ b/pypy/objspace/std/ropeobject.py
@@ -287,7 +287,7 @@
                 raise operationerrfmt(
                     space.w_TypeError,
                     "sequence item %d: expected string, %s "
-                    "found", i, space.type(w_s).getname(space, "?"))
+                    "found", i, space.type(w_s).getname(space))
             assert isinstance(w_s, W_RopeObject)
             node = w_s._node
             l.append(node)

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -55,7 +55,7 @@
         return False
 
     def setdict(self, space, w_dict):
-        typename = space.type(self).getname(space, '?')
+        typename = space.type(self).getname(space)
         raise operationerrfmt(space.w_TypeError,
                               "attribute '__dict__' of %s objects "
                               "is not writable", typename)
@@ -72,7 +72,7 @@
         raise NotImplementedError("only for interp-level user subclasses "
                                   "from typedef.py")
 
-    def getname(self, space, default):
+    def getname(self, space, default='?'):
         try:
             return space.str_w(space.getattr(self, space.wrap('__name__')))
         except OperationError, e:
@@ -117,7 +117,7 @@
             classname = wrappable_class_name(RequiredClass)
         msg = "'%s' object expected, got '%s' instead"
         raise operationerrfmt(space.w_TypeError, msg,
-            classname, self.getclass(space).getname(space, '?'))
+            classname, self.getclass(space).getname(space))
 
     # used by _weakref implemenation
 
@@ -125,7 +125,7 @@
         return None
 
     def setweakref(self, space, weakreflifeline):
-        typename = space.type(self).getname(space, '?')
+        typename = space.type(self).getname(space)
         raise operationerrfmt(space.w_TypeError,
             "cannot create weak reference to '%s' object", typename)
 
@@ -733,7 +733,7 @@
             msg = "'%s' object expected, got '%s' instead"
             raise operationerrfmt(self.w_TypeError, msg,
                 wrappable_class_name(RequiredClass),
-                w_obj.getclass(self).getname(self, '?'))
+                w_obj.getclass(self).getname(self))
         return obj
     interp_w._annspecialcase_ = 'specialize:arg(1)'
 
@@ -1050,7 +1050,7 @@
                 raise
             msg = "%s must be an integer, not %s"
             raise operationerrfmt(self.w_TypeError, msg,
-                objdescr, self.type(w_obj).getname(self, '?'))
+                objdescr, self.type(w_obj).getname(self))
         try:
             index = self.int_w(w_index)
         except OperationError, err:
@@ -1066,7 +1066,7 @@
                 raise operationerrfmt(
                     w_exception,
                     "cannot fit '%s' into an index-sized "
-                    "integer", self.type(w_obj).getname(self, '?'))
+                    "integer", self.type(w_obj).getname(self))
         else:
             return index
 

diff --git a/pypy/objspace/std/typetype.py b/pypy/objspace/std/typetype.py
--- a/pypy/objspace/std/typetype.py
+++ b/pypy/objspace/std/typetype.py
@@ -54,7 +54,7 @@
     if not isinstance(w_type, W_TypeObject):
         raise operationerrfmt(space.w_TypeError,
                               "X is not a type object (%s)",
-                              space.type(w_type).getname(space, '?'))
+                              space.type(w_type).getname(space))
     return w_type
 
 # ____________________________________________________________
@@ -114,7 +114,7 @@
         raise operationerrfmt(space.w_TypeError,
                               "can only assign tuple to %s.__bases__, not %s",
                               w_type.name,
-                              space.type(w_value).getname(space, '?'))
+                              space.type(w_value).getname(space))
     newbases_w = space.fixedview(w_value)
     if len(newbases_w) == 0:
         raise operationerrfmt(space.w_TypeError,
@@ -137,8 +137,8 @@
         raise operationerrfmt(space.w_TypeError,
                            "__bases__ assignment: '%s' object layout"
                            " differs from '%s'",
-                           w_newbestbase.getname(space, '?'),
-                           w_oldbestbase.getname(space, '?'))
+                           w_newbestbase.getname(space),
+                           w_oldbestbase.getname(space))
 
     # invalidate the version_tag of all the current subclasses
     w_type.mutated()

diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py
--- a/pypy/objspace/std/objspace.py
+++ b/pypy/objspace/std/objspace.py
@@ -344,7 +344,7 @@
         else:
             raise operationerrfmt(self.w_TypeError,
                 "%s.__new__(%s): only for the type %s",
-                w_type.name, w_subtype.getname(self, '?'), w_type.name)
+                w_type.name, w_subtype.getname(self), w_type.name)
         return instance
     allocate_instance._annspecialcase_ = "specialize:arg(1)"
 

diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py
--- a/pypy/interpreter/error.py
+++ b/pypy/interpreter/error.py
@@ -207,7 +207,7 @@
             w_inst = w_type
             w_instclass = space.exception_getclass(w_inst)
             if not space.exception_is_valid_class_w(w_instclass):
-                instclassname = w_instclass.getname(space, '?')
+                instclassname = w_instclass.getname(space)
                 msg = ("exceptions must be old-style classes or derived "
                        "from BaseException, not %s")
                 raise operationerrfmt(space.w_TypeError, msg, instclassname)

diff --git a/pypy/objspace/std/unicodeobject.py b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -49,7 +49,7 @@
     if not isinstance(w_unistr, W_UnicodeObject):
         raise operationerrfmt(space.w_TypeError,
                               "expected unicode, got '%s'",
-                              space.type(w_unistr).getname(space, '?'))
+                              space.type(w_unistr).getname(space))
     unistr = w_unistr._value
     result = ['\0'] * len(unistr)
     digits = [ '0', '1', '2', '3', '4',

diff --git a/pypy/interpreter/function.py b/pypy/interpreter/function.py
--- a/pypy/interpreter/function.py
+++ b/pypy/interpreter/function.py
@@ -444,7 +444,7 @@
             pre = "bound"
         else:
             pre = "unbound"
-        return "%s method %s" % (pre, self.w_function.getname(self.space, '?'))
+        return "%s method %s" % (pre, self.w_function.getname(self.space))
 
     def call_args(self, args):
         space = self.space
@@ -493,13 +493,13 @@
 
     def descr_method_repr(self):
         space = self.space
-        name = self.w_function.getname(self.space, '?')
+        name = self.w_function.getname(self.space)
         # XXX do we handle all cases sanely here?
         if space.is_w(self.w_class, space.w_None):
             w_class = space.type(self.w_instance)
         else:
             w_class = self.w_class
-        typename = w_class.getname(self.space, '?')
+        typename = w_class.getname(self.space)
         if self.w_instance is None:
             s = "<unbound method %s.%s>" % (typename, name)
             return space.wrap(s)

diff --git a/pypy/objspace/std/stringobject.py b/pypy/objspace/std/stringobject.py
--- a/pypy/objspace/std/stringobject.py
+++ b/pypy/objspace/std/stringobject.py
@@ -341,7 +341,7 @@
                 raise operationerrfmt(
                     space.w_TypeError,
                     "sequence item %d: expected string, %s "
-                    "found", i, space.type(w_s).getname(space, '?'))
+                    "found", i, space.type(w_s).getname(space))
             reslen += len(space.str_w(w_s))
         reslen += len(self) * (len(list_w) - 1)
         sb = StringBuilder(reslen)

diff --git a/pypy/tool/release/test/test_package.py b/pypy/tool/release/test/test_package.py
--- a/pypy/tool/release/test/test_package.py
+++ b/pypy/tool/release/test/test_package.py
@@ -1,38 +1,56 @@
 
 import py
 from pypy.tool.autopath import pypydir
-from pypy.tool.release.package import package
+from pypy.tool.release import package
 from pypy.module.sys.version import  CPYTHON_VERSION
-import tarfile, os
+import tarfile, zipfile, os, sys
 
 def test_dir_structure(test='test'):
     # make sure we have sort of pypy-c
-    pypy_c = py.path.local(pypydir).join('translator', 'goal', 'pypy-c')
+    if sys.platform == 'win32':
+        basename = 'pypy-c.exe'
+        rename_pypy_c = 'pypy-c'
+    else:
+        basename = 'pypy-c'
+        rename_pypy_c = 'pypy'
+    pypy_c = py.path.local(pypydir).join('translator', 'goal', basename)
     if not pypy_c.check():
         os.system("echo faked_pypy_c> %s" % (pypy_c,))
         fake_pypy_c = True
     else:
         fake_pypy_c = False
     try:
-        builddir = package(py.path.local(pypydir).dirpath(), test)
+        builddir = package.package(py.path.local(pypydir).dirpath(), test,
+                                   rename_pypy_c)
         prefix = builddir.join(test)
         cpyver = '%d.%d.%d' % CPYTHON_VERSION[:3]
         assert prefix.join('lib-python', cpyver, 'test').check()
-        assert prefix.join('bin', 'pypy').check()
+        if sys.platform == 'win32':
+            assert prefix.join('pypy-c.exe').check()
+        else:
+            assert prefix.join('bin', 'pypy').check()
         assert prefix.join('lib_pypy', 'syslog.py').check()
         assert not prefix.join('lib_pypy', 'py').check()
         assert not prefix.join('lib_pypy', 'ctypes_configure').check()
         assert prefix.join('LICENSE').check()
         assert prefix.join('README').check()
-        th = tarfile.open(str(builddir.join('%s.tar.bz2' % test)))
-        assert th.getmember('%s/lib_pypy/syslog.py' % test)
+        if package.USE_ZIPFILE_MODULE:
+            zh = zipfile.ZipFile(str(builddir.join('%s.zip' % test)))
+            assert zh.open('%s/lib_pypy/syslog.py' % test)
+        else:
+            th = tarfile.open(str(builddir.join('%s.tar.bz2' % test)))
+            assert th.getmember('%s/lib_pypy/syslog.py' % test)
 
         # the headers file could be not there, because they are copied into
         # trunk/include only during translation
         includedir = py.path.local(pypydir).dirpath().join('include')
         def check_include(name):
             if includedir.join(name).check(file=True):
-                assert th.getmember('%s/include/%s' % (test, name))
+                member = '%s/include/%s' % (test, name)
+                if package.USE_ZIPFILE_MODULE:
+                    assert zh.open(member)
+                else:
+                    assert th.getmember(member)
         check_include('Python.h')
         check_include('modsupport.inl')
         check_include('pypy_decl.h')
@@ -40,11 +58,11 @@
         if fake_pypy_c:
             pypy_c.remove()
 
-def test_with_tarfile_module():
+def test_with_zipfile_module():
     from pypy.tool.release import package
-    prev = package.USE_TARFILE_MODULE
+    prev = package.USE_ZIPFILE_MODULE
     try:
-        package.USE_TARFILE_MODULE = True
-        test_dir_structure(test='testtarfile')
+        package.USE_ZIPFILE_MODULE = True
+        test_dir_structure(test='testzipfile')
     finally:
-        package.USE_TARFILE_MODULE = prev
+        package.USE_ZIPFILE_MODULE = prev

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
@@ -336,7 +336,7 @@
         if not isinstance(w_subtype, W_TypeObject):
             raise operationerrfmt(space.w_TypeError,
                 "X is not a type object ('%s')",
-                space.type(w_subtype).getname(space, '?'))
+                space.type(w_subtype).getname(space))
         if not w_subtype.issubtype(w_self):
             raise operationerrfmt(space.w_TypeError,
                 "%s.__new__(%s): %s is not a subtype of %s",
@@ -892,7 +892,7 @@
         # explicit error message for this specific case
         raise operationerrfmt(space.w_TypeError,
                               "duplicate base class '%s'",
-                              candidate.getname(space,"?"))
+                              candidate.getname(space))
     while candidate not in cycle:
         cycle.append(candidate)
         nextblockinglist = mro_blockinglist(candidate, orderlists)
@@ -900,7 +900,7 @@
     del cycle[:cycle.index(candidate)]
     cycle.append(candidate)
     cycle.reverse()
-    names = [cls.getname(space, "?") for cls in cycle]
+    names = [cls.getname(space) for cls in cycle]
     raise OperationError(space.w_TypeError,
         space.wrap("cycle among base classes: " + ' < '.join(names)))
 

diff --git a/pypy/objspace/std/stdtypedef.py b/pypy/objspace/std/stdtypedef.py
--- a/pypy/objspace/std/stdtypedef.py
+++ b/pypy/objspace/std/stdtypedef.py
@@ -146,7 +146,7 @@
 
 def _gettypenames(space, *args_w):
     if args_w:
-        typename = space.type(args_w[-1]).getname(space, '?')
+        typename = space.type(args_w[-1]).getname(space)
         return _gettypenames(space, *args_w[:-1]) + (typename,)
     return ()
 _gettypenames._always_inline_ = True

diff --git a/pypy/tool/win32-build.bat b/pypy/tool/win32-build.bat
deleted file mode 100644
--- a/pypy/tool/win32-build.bat
+++ /dev/null
@@ -1,38 +0,0 @@
-setlocal
-
-set ROOTDIR=%~dp0..\..
-cd %ROOTDIR%
-
-set ZIPEXE=zip
-set PYTHON=c:\python26\python.exe
-set TRANSLATE=pypy/translator/goal/translate.py
-set TRANSLATEOPTS=--batch
-set TARGET=pypy/translator/goal/targetpypystandalone
-set TARGETOPTS=
-
-copy /y ..\expat-2.0.1\win32\bin\release\libexpat.dll .
-
-call :make_pypy pypy-1.2-win32.zip           pypy.exe           -Ojit
-call :make_pypy pypy-1.2-win32-nojit.zip     pypy-nojit.exe
-call :make_pypy pypy-1.2-win32-stackless.zip pypy-stackless.exe --stackless
-REM call :make_pypy pypy-1.2-win32-sandbox.zip   pypy-sandbox.exe   --sandbox
-
-goto :EOF
-
-REM =========================================
-:make_pypy
-REM make_pypy subroutine
-REM %1 is the zip filename
-REM %2 is pypy.exe filename
-REM %3 and others are the translation options
-
-set ZIPFILE=%1
-set PYPYEXE=%2
-set EXTRAOPTS=%3 %4 %5 %6 %7 %8 %9
-
-%PYTHON% %TRANSLATE% --output=%PYPYEXE% %TRANSLATEOPTS% %EXTRAOPTS% %TARGET% %TARGETOPTS%
-del %ZIPFILE%
-del /s pypy\lib\*.pyc lib-python\*.pyc
-%ZIPEXE%    %ZIPFILE% %PYPYEXE% *.dll
-%ZIPEXE% -r %ZIPFILE% pypy\lib lib-python
-%ZIPEXE% -d %ZIPFILE% lib-python\2.5.2\plat-*

diff --git a/pypy/objspace/std/default.py b/pypy/objspace/std/default.py
--- a/pypy/objspace/std/default.py
+++ b/pypy/objspace/std/default.py
@@ -18,7 +18,7 @@
     pass
 
 def typed_unwrap_error_msg(space, expected, w_obj):
-    type_name = space.type(w_obj).getname(space, '?')
+    type_name = space.type(w_obj).getname(space)
     return space.wrap("expected %s, got %s object" % (expected, type_name))
 
 def int_w__ANY(space,w_obj):

diff --git a/pypy/module/_weakref/interp__weakref.py b/pypy/module/_weakref/interp__weakref.py
--- a/pypy/module/_weakref/interp__weakref.py
+++ b/pypy/module/_weakref/interp__weakref.py
@@ -189,9 +189,8 @@
 reprdescr = interp2app(descr__repr__, unwrap_spec=[ObjSpace, W_WeakrefBase])
 
 W_Weakref.typedef = TypeDef("weakref",
-    __doc__ = """A weak reference to an object 'obj'.  A 'callback' can given,
-which is called with the weak reference as an argument when 'obj'
-is about to be finalized.""",
+    __doc__ = """A weak reference to an object 'obj'.  A 'callback' can be given,
+which is called with 'obj' as an argument when it is about to be finalized.""",
     __new__ = interp2app(descr__new__weakref,
                          unwrap_spec=[ObjSpace, W_Root, W_Root, W_Root,
                                       Arguments]),


More information about the Pypy-commit mailing list