[pypy-commit] pypy set-strategies: merge

2012-01-12 Thread l . diekmann
Author: Lukas Diekmann lukas.diekm...@uni-duesseldorf.de
Branch: set-strategies
Changeset: r51291:a4bba3dd3493
Date: 2012-01-12 18:29 +0100
http://bitbucket.org/pypy/pypy/changeset/a4bba3dd3493/

Log:merge

diff --git a/pypy/objspace/std/setobject.py b/pypy/objspace/std/setobject.py
--- a/pypy/objspace/std/setobject.py
+++ b/pypy/objspace/std/setobject.py
@@ -943,8 +943,9 @@
 w_set.sstorage = strategy.get_empty_storage()
 return
 
-#XXX check ints and strings at once
+_pick_correct_strategy(space, w_set, iterable_w)
 
+def _pick_correct_strategy(space, w_set, iterable_w):
 # check for integers
 for w_item in iterable_w:
 if type(w_item) is not W_IntObject:
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
@@ -61,7 +61,12 @@
 return plain_str2unicode(space, w_self._value)
 
 def listview_str(w_self):
-return [s for s in w_self._value]
+return _create_list_from_string(w_self._value)
+
+def _create_list_from_string(value):
+# need this helper function to allow the jit to look inside and inline
+# listview_str
+return [s for s in value]
 
 registerimplementation(W_StringObject)
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy set-strategies: merge

2011-11-14 Thread cfbolz
Author: Carl Friedrich Bolz cfb...@gmx.de
Branch: set-strategies
Changeset: r49402:c3ed604fcfb5
Date: 2011-11-14 15:15 +0100
http://bitbucket.org/pypy/pypy/changeset/c3ed604fcfb5/

Log:merge

diff --git a/lib-python/modified-2.7/test/test_import.py 
b/lib-python/modified-2.7/test/test_import.py
--- a/lib-python/modified-2.7/test/test_import.py
+++ b/lib-python/modified-2.7/test/test_import.py
@@ -64,6 +64,7 @@
 except ImportError, err:
 self.fail(import from %s failed: %s % (ext, err))
 else:
+# XXX importing .pyw is missing on Windows
 self.assertEqual(mod.a, a,
 module loaded (%s) but contents invalid % mod)
 self.assertEqual(mod.b, b,
diff --git a/lib-python/modified-2.7/test/test_repr.py 
b/lib-python/modified-2.7/test/test_repr.py
--- a/lib-python/modified-2.7/test/test_repr.py
+++ b/lib-python/modified-2.7/test/test_repr.py
@@ -254,8 +254,14 @@
 eq = self.assertEqual
 touch(os.path.join(self.subpkgname, self.pkgname + os.extsep + 'py'))
 from 
areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation
 import areallylongpackageandmodulenametotestreprtruncation
-eq(repr(areallylongpackageandmodulenametotestreprtruncation),
-   module '%s' from '%s' % 
(areallylongpackageandmodulenametotestreprtruncation.__name__, 
areallylongpackageandmodulenametotestreprtruncation.__file__))
+# On PyPy, we use %r to format the file name; on CPython it is done
+# with '%s'.  It seems to me that %r is safer arigo.
+if '__pypy__' in sys.builtin_module_names:
+eq(repr(areallylongpackageandmodulenametotestreprtruncation),
+   module %r from %r % 
(areallylongpackageandmodulenametotestreprtruncation.__name__, 
areallylongpackageandmodulenametotestreprtruncation.__file__))
+else:
+eq(repr(areallylongpackageandmodulenametotestreprtruncation),
+   module '%s' from '%s' % 
(areallylongpackageandmodulenametotestreprtruncation.__name__, 
areallylongpackageandmodulenametotestreprtruncation.__file__))
 eq(repr(sys), module 'sys' (built-in))
 
 def test_type(self):
diff --git a/lib-python/2.7/test/test_subprocess.py 
b/lib-python/modified-2.7/test/test_subprocess.py
copy from lib-python/2.7/test/test_subprocess.py
copy to lib-python/modified-2.7/test/test_subprocess.py
--- a/lib-python/2.7/test/test_subprocess.py
+++ b/lib-python/modified-2.7/test/test_subprocess.py
@@ -16,11 +16,11 @@
 # Depends on the following external programs: Python
 #
 
-if mswindows:
-SETBINARY = ('import msvcrt; msvcrt.setmode(sys.stdout.fileno(), '
-'os.O_BINARY);')
-else:
-SETBINARY = ''
+#if mswindows:
+#SETBINARY = ('import msvcrt; msvcrt.setmode(sys.stdout.fileno(), '
+#'os.O_BINARY);')
+#else:
+#SETBINARY = ''
 
 
 try:
@@ -420,8 +420,9 @@
 self.assertStderrEqual(stderr, )
 
 def test_universal_newlines(self):
-p = subprocess.Popen([sys.executable, -c,
-  'import sys,os;' + SETBINARY +
+# NB. replaced SETBINARY with the -u flag
+p = subprocess.Popen([sys.executable, -u, -c,
+  'import sys,os;' + #SETBINARY +
   'sys.stdout.write(line1\\n);'
   'sys.stdout.flush();'
   'sys.stdout.write(line2\\r);'
@@ -448,8 +449,9 @@
 
 def test_universal_newlines_communicate(self):
 # universal newlines through communicate()
-p = subprocess.Popen([sys.executable, -c,
-  'import sys,os;' + SETBINARY +
+# NB. replaced SETBINARY with the -u flag
+p = subprocess.Popen([sys.executable, -u, -c,
+  'import sys,os;' + #SETBINARY +
   'sys.stdout.write(line1\\n);'
   'sys.stdout.flush();'
   'sys.stdout.write(line2\\r);'
diff --git a/pypy/interpreter/test/test_executioncontext.py 
b/pypy/interpreter/test/test_executioncontext.py
--- a/pypy/interpreter/test/test_executioncontext.py
+++ b/pypy/interpreter/test/test_executioncontext.py
@@ -292,7 +292,7 @@
 import os, sys
 print sys.executable, self.tmpfile
 if sys.platform == win32:
-cmdformat = '%s %s'# excellent! tons of !
+cmdformat = '%s %s'
 else:
 cmdformat = '%s' '%s'
 g = os.popen(cmdformat % (sys.executable, self.tmpfile), 'r')
diff --git a/pypy/jit/codewriter/call.py b/pypy/jit/codewriter/call.py
--- a/pypy/jit/codewriter/call.py
+++ b/pypy/jit/codewriter/call.py
@@ -212,7 +212,10 @@
 elidable = False
 loopinvariant = False
 if op.opname == direct_call:
-func = getattr(get_funcobj(op.args[0].value), 

[pypy-commit] pypy set-strategies: merge with default

2011-11-10 Thread l . diekmann
Author: Lukas Diekmann lukas.diekm...@uni-duesseldorf.de
Branch: set-strategies
Changeset: r49245:a07d1bf6b358
Date: 2011-10-14 15:34 +0200
http://bitbucket.org/pypy/pypy/changeset/a07d1bf6b358/

Log:merge with default

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
@@ -756,7 +756,8 @@
 input = w_self._value
 width = space.int_w(w_width)
 
-if len(input) = width:
+num_zeros = width - len(input)
+if num_zeros = 0:
 # cannot return w_self, in case it is a subclass of str
 return space.wrap(input)
 
@@ -764,13 +765,11 @@
 if len(input)  0 and (input[0] == '+' or input[0] == '-'):
 builder.append(input[0])
 start = 1
-middle = width - len(input) + 1
 else:
 start = 0
-middle = width - len(input)
 
-builder.append_multiple_char('0', middle - start)
-builder.append(input[start:start + (width - middle)])
+builder.append_multiple_char('0', num_zeros)
+builder.append_slice(input, start, len(input))
 return space.wrap(builder.build())
 
 
diff --git a/pypy/tool/logparser.py b/pypy/tool/logparser.py
--- a/pypy/tool/logparser.py
+++ b/pypy/tool/logparser.py
@@ -298,6 +298,8 @@
 image.paste(textpercent, (t1x, 5), textpercent)
 image.paste(textlabel,   (t2x, 5), textlabel)
 images.append(image)
+if not images:
+return None
 return combine(images, spacing=0, border=1, horizontal=False)
 
 def get_timesummary_single_image(totaltimes, totaltime0, componentdict,
@@ -333,6 +335,8 @@
 del totaltimes[None]
 img2 = render_histogram(totaltimes, totaltime0, {},
 width, summarybarheight)
+if img2 is None:
+return img1
 return combine([img1, img2], spacing=spacing, horizontal=True)
 
 # --
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit