[pypy-commit] buildbot sort-nightly-directories: close about-to-be-merged branch

2013-03-21 Thread mattip
Author: Matti Picus matti.pi...@gmail.com
Branch: sort-nightly-directories
Changeset: r752:73a9e7779b04
Date: 2013-03-20 23:21 -0700
http://bitbucket.org/pypy/buildbot/changeset/73a9e7779b04/

Log:close about-to-be-merged branch

___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] buildbot default: merge sort-nightly-directories which sorts the nightly page by mtime of the subdirectories and puts trunk on top

2013-03-21 Thread mattip
Author: Matti Picus matti.pi...@gmail.com
Branch: 
Changeset: r753:c816177376d6
Date: 2013-03-20 23:22 -0700
http://bitbucket.org/pypy/buildbot/changeset/c816177376d6/

Log:merge sort-nightly-directories which sorts the nightly page by mtime
of the subdirectories and puts trunk on top

diff --git a/bot2/pypybuildbot/pypylist.py b/bot2/pypybuildbot/pypylist.py
--- a/bot2/pypybuildbot/pypylist.py
+++ b/bot2/pypybuildbot/pypylist.py
@@ -1,11 +1,10 @@
 import os.path
 import datetime
 import itertools
-import re
 import py
 import cgi
 import urllib
-from twisted.web import resource
+import sys
 from twisted.web.static import File, DirectoryLister
 
 class PyPyTarball(object):
@@ -103,25 +102,45 @@
 def display_in_italic(self):
 return self.vcs == 'latest'
 
+class PyPyDirectory(object):
+def __init__(self, filePath):
+self.filename = filePath.basename()
+self.filePath = filePath
+self.parse_filename()
+
+def parse_filename(self):
+if self.filename == 'trunk':
+self.last_mod_time = sys.maxsize
+return
+self.last_mod_time = self.filePath.getmtime()
+
+def key(self):
+return (self.last_mod_time)
 
 class PyPyList(File):
 
-def listNames(self):
-names = File.listNames(self)
+def sortBuildNames(self, names):
 items = map(PyPyTarball, names)
 items.sort(key=PyPyTarball.key, reverse=True)
 return [item.filename for item in items]
 
+def sortDirectoryNames(self, filePaths):
+items = map(PyPyDirectory, filePaths)
+items.sort(key=PyPyDirectory.key, reverse=True)
+return [item.filename for item in items]
+
 def directoryListing(self):
 def is_pypy_dir(names):
 for name in names:
 if name.startswith('pypy-c'):
 return True
 return False
-names = self.listNames()
+names = File.listNames(self)
 if is_pypy_dir(names):
+names = self.sortBuildNames(names)
 Listener = PyPyDirectoryLister
 else:
+names = self.sortDirectoryNames(File.listEntities(self))
 Listener = DirectoryLister
 return Listener(self.path,
 names,
diff --git a/bot2/pypybuildbot/test/test_pypylist.py 
b/bot2/pypybuildbot/test/test_pypylist.py
--- a/bot2/pypybuildbot/test/test_pypylist.py
+++ b/bot2/pypybuildbot/test/test_pypylist.py
@@ -1,5 +1,5 @@
 import py
-from pypybuildbot.pypylist import PyPyTarball
+from pypybuildbot.pypylist import PyPyTarball, PyPyList
 
 def test_pypytarball_svn():
 t = PyPyTarball('pypy-c-jit-75654-linux.tar.bz2')
@@ -12,6 +12,7 @@
 assert t.platform == 'linux'
 assert t.vcs == 'svn'
 
+
 def test_pypytarball_hg():
 t = PyPyTarball('pypy-c-jit-75654-foo-linux.tar.bz2')
 assert t.filename == 'pypy-c-jit-75654-foo-linux.tar.bz2'
@@ -23,6 +24,7 @@
 assert t.platform == 'linux'
 assert t.vcs == 'hg'
 
+
 def test_invalid_filename():
 t = PyPyTarball('foo')
 assert t.vcs == None
@@ -35,8 +37,8 @@
 t2 = PyPyTarball('pypy-c-jit-75654-linux.tar.bz2')
 assert t.key()  t2.key()
 
-def test_sort():
-files = map(PyPyTarball, [
+def test_sort(tmpdir):
+files = [
 'pypy-c-jit-1-linux.tar.bz2',
 'pypy-c-jit-2-linux.tar.bz2',
 'pypy-c-nojit-1-linux.tar.bz2',
@@ -45,11 +47,11 @@
 'pypy-c-stackless-1-linux.tar.bz2',
 'pypy-c-jit-1000-e5b73981fc8d-linux.tar.bz2', # this is mercurial 
based
 'pypy-c-jit-1-linux-armel.tar.bz2',
-])
-
-files.sort(key=PyPyTarball.key, reverse=True)
-files = [f.filename for f in files]
-assert files == [
+]
+[tmpdir.join(f).write(f) for f in files]
+pypylist = PyPyList(tmpdir.strpath)
+listener = pypylist.directoryListing()
+assert listener.dirs == [
 'pypy-c-jit-1000-e5b73981fc8d-linux.tar.bz2', # mercurial first
 'pypy-c-jit-2-linux.tar.bz2',
 'pypy-c-jit-1-linux.tar.bz2',
@@ -60,6 +62,26 @@
 'pypy-c-stackless-1-linux.tar.bz2',
 ]
 
+def test_pypy_list(tmpdir):
+import os
+pypylist = PyPyList(os.path.dirname(__file__))
+files = pypylist.listNames()
+assert os.path.basename(__file__) in files
+
+def test_dir_render(tmpdir):
+# Create a bunch of directories, including one named trunk,
+# Make sure the time order is reversed collation order
+trunk = tmpdir.mkdir('trunk')
+oldtime = trunk.mtime()
+for ascii in range(ord('a'), ord('m')):
+newdir = tmpdir.mkdir(chr(ascii) * 4)
+newdir.setmtime(oldtime + ascii * 10)
+pypylist = PyPyList(tmpdir.strpath)
+listener = pypylist.directoryListing()
+assert listener.dirs == ['trunk', '', '',
+'','','','','','','',
+'','','','']
+
 def load_BuildmasterConfig():

[pypy-commit] pypy default: move readline to RStringIO

2013-03-21 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: 
Changeset: r62606:535f3a9dd3b6
Date: 2013-03-21 03:27 -0400
http://bitbucket.org/pypy/pypy/changeset/535f3a9dd3b6/

Log:move readline to RStringIO

diff --git a/pypy/module/cStringIO/interp_stringio.py 
b/pypy/module/cStringIO/interp_stringio.py
--- a/pypy/module/cStringIO/interp_stringio.py
+++ b/pypy/module/cStringIO/interp_stringio.py
@@ -149,22 +149,6 @@
 RStringIO.__init__(self)
 self.space = space
 
-def readline(self, size=-1):
-p = self.tell()
-bigbuffer = self.copy_into_bigbuffer()
-end = len(bigbuffer)
-if size = 0 and size  end - p:
-end = p + size
-assert p = 0
-i = p
-while i  end:
-finished = bigbuffer[i] == '\n'
-i += 1
-if finished:
-break
-self.seek(i)
-return ''.join(bigbuffer[p:i])
-
 def descr_truncate(self, w_size=None):
 self.check_closed()
 space = self.space
diff --git a/rpython/rlib/rStringIO.py b/rpython/rlib/rStringIO.py
--- a/rpython/rlib/rStringIO.py
+++ b/rpython/rlib/rStringIO.py
@@ -126,6 +126,22 @@
 self.pos = p + count
 return ''.join(self.bigbuffer[p:p+count])
 
+def readline(self, size=-1):
+p = self.tell()
+self.copy_into_bigbuffer()
+end = len(self.bigbuffer)
+if size = 0 and size  end - p:
+end = p + size
+assert p = 0
+i = p
+while i  end:
+finished = self.bigbuffer[i] == '\n'
+i += 1
+if finished:
+break
+self.seek(i)
+return ''.join(self.bigbuffer[p:i])
+
 def truncate(self, size):
 # NB. 'size' is mandatory.  This has the same un-Posix-y semantics
 # than CPython: it never grows the buffer, and it sets the current
diff --git a/rpython/rlib/test/test_rStringIO.py 
b/rpython/rlib/test/test_rStringIO.py
--- a/rpython/rlib/test/test_rStringIO.py
+++ b/rpython/rlib/test/test_rStringIO.py
@@ -77,6 +77,16 @@
 assert f.read(2) == ''
 assert f.tell() == 15
 
+def test_readline():
+f = RStringIO()
+f.write('foo\nbar\nbaz')
+f.seek(0)
+assert f.readline() == 'foo\n'
+assert f.readline(2) == 'ba'
+assert f.readline() == 'r\n'
+assert f.readline() == 'baz'
+assert f.readline() == ''
+
 def test_truncate():
 f = RStringIO()
 f.truncate(20)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: update, finish and enable some calling convetion tests on arm

2013-03-21 Thread bivab
Author: David Schneider david.schnei...@picle.org
Branch: 
Changeset: r62609:7fe3b006e52e
Date: 2013-03-21 15:32 +0200
http://bitbucket.org/pypy/pypy/changeset/7fe3b006e52e/

Log:update, finish and enable some calling convetion tests on arm

diff --git a/rpython/jit/backend/arm/test/test_calling_convention.py 
b/rpython/jit/backend/arm/test/test_calling_convention.py
--- a/rpython/jit/backend/arm/test/test_calling_convention.py
+++ b/rpython/jit/backend/arm/test/test_calling_convention.py
@@ -4,12 +4,23 @@
 from rpython.rtyper.lltypesystem import lltype
 from rpython.jit.codewriter.effectinfo import EffectInfo
 
+from rpython.jit.backend.arm.codebuilder import ARMv7Builder
+from rpython.jit.backend.arm import registers as r
 from rpython.jit.backend.arm.test.support import skip_unless_run_slow_tests
 skip_unless_run_slow_tests()
 
 class TestARMCallingConvention(CallingConvTests):
 # ../../test/calling_convention_test.py
 
+def make_function_returning_stack_pointer(self):
+mc = ARMv7Builder()
+   mc.MOV_rr(r.r0.value, r.sp.value)
+   mc.MOV_rr(r.pc.value, r.lr.value)
+return mc.materialize(self.cpu.asmmemmgr, [])
+
+def get_alignment_requirements(self):
+return 8
+
 def test_call_argument_spilling(self):
 # bug when we have a value in r0, that is overwritten by an argument
 # and needed after the call, so that the register gets spilled after it
@@ -28,12 +39,24 @@
 ops = 
 [%s]
 i99 = call(ConstClass(func_ptr), 22, descr=calldescr)
-finish(%s, i99) % (args, args)
+force_spill(i0)
+force_spill(i1)
+force_spill(i2)
+force_spill(i3)
+force_spill(i4)
+force_spill(i5)
+force_spill(i6)
+force_spill(i7)
+force_spill(i8)
+force_spill(i9)
+force_spill(i10)
+guard_true(i0) [%s, i99]
+finish() % (args, args)
 loop = parse(ops, namespace=locals())
 looptoken = JitCellToken()
 self.cpu.compile_loop(loop.inputargs, loop.operations, looptoken)
 args = [x for x in range(11)]
-self.cpu.execute_token(looptoken, *args)
+deadframe = self.cpu.execute_token(looptoken, *args)
 for x in range(11):
-assert self.cpu.get_latest_value_int(x) == x
-assert self.cpu.get_latest_value_int(11) == 38
+assert self.cpu.get_int_value(deadframe, x) == x
+assert self.cpu.get_int_value(deadframe, 11) == 38
diff --git a/rpython/jit/backend/test/calling_convention_test.py 
b/rpython/jit/backend/test/calling_convention_test.py
--- a/rpython/jit/backend/test/calling_convention_test.py
+++ b/rpython/jit/backend/test/calling_convention_test.py
@@ -11,6 +11,7 @@
 from rpython.jit.backend.test.runner_test import Runner
 import py
 import sys
+import platform
 
 def boxfloat(x):
 return BoxFloat(longlong.getfloatstorage(x))
@@ -382,7 +383,8 @@
 raise NotImplementedError
 
 def test_call_aligned_explicit_check(self):
-if sys.maxint == 2 ** 31 - 1:
+if (not platform.machine().startswith('arm') and
+   sys.maxint == 2 ** 31 - 1): # XXX is still necessary on x86?
 py.test.skip(libffi on 32bit is broken)
 cpu = self.cpu
 if not cpu.supports_floats:
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] lang-smalltalk default: (tfel, lwassermann): minor fix to not send empty key-events when there were none

2013-03-21 Thread lwassermann
Author: Lars Wassermann lars.wasserm...@gmail.com
Branch: 
Changeset: r229:76bfdbc738e7
Date: 2013-03-21 16:08 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/76bfdbc738e7/

Log:(tfel, lwassermann): minor fix to not send empty key-events when
there were none

diff --git a/spyvm/primitives.py b/spyvm/primitives.py
--- a/spyvm/primitives.py
+++ b/spyvm/primitives.py
@@ -661,11 +661,19 @@
 
 @expose_primitive(KBD_NEXT, unwrap_spec=[object])
 def func(interp, s_frame, w_rcvr):
-return interp.space.wrap_int(interp.space.get_display().next_keycode())
+code = interp.space.get_display().next_keycode()
+if code == 0:
+return interp.space.w_nil
+else:
+return interp.space.wrap_int(code)
 
 @expose_primitive(KBD_PEEK, unwrap_spec=[object])
 def func(interp, s_frame, w_rcvr):
-return interp.space.wrap_int(interp.space.get_display().peek_keycode())
+code = interp.space.get_display().peek_keycode()
+if code == 0:
+return interp.space.w_nil
+else:
+return interp.space.wrap_int(code)
 
 
 # ___
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] lang-smalltalk default: method extraction refactoring for does not understand case in _sendSelector

2013-03-21 Thread lwassermann
Author: Lars Wassermann lars.wasserm...@gmail.com
Branch: 
Changeset: r228:7e8d4241566a
Date: 2013-03-21 16:07 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/7e8d4241566a/

Log:method extraction refactoring for does not understand case in
_sendSelector

diff --git a/spyvm/interpreter.py b/spyvm/interpreter.py
--- a/spyvm/interpreter.py
+++ b/spyvm/interpreter.py
@@ -33,7 +33,8 @@
 get_printable_location=get_printable_location
 )
 
-def __init__(self, space, image=None, image_name=, max_stack_depth=100):
+def __init__(self, space, image=None, image_name=,
+max_stack_depth=constants.MAX_LOOP_DEPTH):
 self.space = space
 self.image = image
 self.image_name = image_name
@@ -118,7 +119,8 @@
 if selector == asSymbol:
 w_selector = self.image.w_asSymbol
 else:
-w_selector = self.perform(self.space.wrap_string(selector), 
asSymbol)
+w_selector = self.perform(self.space.wrap_string(selector),
+asSymbol)
 else:
 w_selector = selector
 
@@ -281,22 +283,11 @@
 interp._last_indent, w_selector.as_string(), receiver,
 [self.peek(argcount-1-i) for i in range(argcount)])
 assert argcount = 0
+
 try:
 s_method = receiverclassshadow.lookup(w_selector)
 except MethodNotFound:
-arguments = self.pop_and_return_n(argcount)
-s_message_class = 
self.space.classtable[w_Message].as_class_get_shadow(self.space)
-w_message = s_message_class.new()
-w_message.store(self.space, 0, w_selector)
-w_message.store(self.space, 1, self.space.wrap_list(arguments))
-try:
-s_method = 
receiver.shadow_of_my_class(self.space).lookup(self.space.objtable[w_doesNotUnderstand])
-except MethodNotFound:
-print Missing doesDoesNotUnderstand in hierarchy of %s % 
receiverclassshadow.getname()
-raise
-s_frame = s_method.create_frame(self.space, receiver, [w_message], 
self)
-self.pop()
-return interp.stack_frame(s_frame)
+return self._doesNotUnderstand(w_selector, argcount, interp, 
receiver)
 
 code = s_method.primitive()
 if code:
@@ -316,6 +307,22 @@
 self.pop()
 return interp.stack_frame(s_frame)
 
+def _doesNotUnderstand(self, w_selector, argcount, interp, receiver):
+arguments = self.pop_and_return_n(argcount)
+s_message_class = 
self.space.classtable[w_Message].as_class_get_shadow(self.space)
+w_message = s_message_class.new()
+w_message.store(self.space, 0, w_selector)
+w_message.store(self.space, 1, self.space.wrap_list(arguments))
+s_class = receiver.shadow_of_my_class(self.space)
+try:
+s_method = 
s_class.lookup(self.space.objtable[w_doesNotUnderstand])
+except MethodNotFound:
+print Missing doesDoesNotUnderstand in hierarchy of %s % 
s_class.getname()
+raise
+s_frame = s_method.create_frame(self.space, receiver, [w_message], 
self)
+self.pop()
+return interp.stack_frame(s_frame)
+
 def _return(self, return_value, interp, s_return_to):
 # for tests, when returning from the top-level context
 if s_return_to is None:
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] lang-smalltalk default: added SIGNAL_AT_MILLISECONDS primitive and code which checks whether to signal

2013-03-21 Thread lwassermann
Author: Lars Wassermann lars.wasserm...@gmail.com
Branch: 
Changeset: r230:1330f5e597fe
Date: 2013-03-21 16:11 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/1330f5e597fe/

Log:added SIGNAL_AT_MILLISECONDS primitive and code which checks whether
to signal

diff --git a/spyvm/constants.py b/spyvm/constants.py
--- a/spyvm/constants.py
+++ b/spyvm/constants.py
@@ -90,7 +90,7 @@
 SO_BYTEARRAY_CLASS = 26
 SO_PROCESS_CLASS = 27
 SO_COMPACT_CLASSES_ARRAY = 28
-SO_DELAY_SEMAPHORE = 29
+SO_TIMER_SEMAPHORE = 29
 SO_USER_INTERRUPT_SEMAPHORE = 30
 SO_FLOAT_ZERO = 31
 SO_LARGEPOSITIVEINTEGER_ZERO = 32
@@ -139,6 +139,7 @@
 display : SO_DISPLAY_OBJECT,
 doesNotUnderstand : SO_DOES_NOT_UNDERSTAND,
 interrupt_semaphore : SO_USER_INTERRUPT_SEMAPHORE,
+timerSemaphore : SO_TIMER_SEMAPHORE,
 }
 
 LONG_BIT = 32
@@ -176,3 +177,10 @@
 primitive = primitive + (highbit  10) ##XXX todo, check this
 assert tempsize = numargs
 return primitive, literalsize, islarge, tempsize, numargs
+
+#___
+# Interpreter constants
+#
+
+MAX_LOOP_DEPTH = 100
+INTERRUPT_COUNTER_SIZE = 1000
\ No newline at end of file
diff --git a/spyvm/interpreter.py b/spyvm/interpreter.py
--- a/spyvm/interpreter.py
+++ b/spyvm/interpreter.py
@@ -41,6 +41,8 @@
 self.max_stack_depth = max_stack_depth
 self.remaining_stack_depth = max_stack_depth
 self._loop = False
+self.next_wakeup_tick = 0
+self.interrupt_check_counter = constants.INTERRUPT_COUNTER_SIZE
 
 def interpret_with_w_frame(self, w_frame):
 try:
@@ -80,10 +82,15 @@
 # padding = ' ' * (self.max_stack_depth - self.remaining_stack_depth)
 # print padding + s_context.short_str()
 old_pc = 0
+if not jit.we_are_jitted():
+self.quick_check_for_interrupt(s_context)
 while True:
 pc = s_context._pc
 method = s_context.s_method()
 if pc  old_pc:
+if jit.we_are_jitted():
+self.quick_check_for_interrupt(s_context,
+dec=self._get_adapted_tick_counter())
 self.jit_driver.can_enter_jit(
 pc=pc, self=self, method=method,
 s_context=s_context)
@@ -100,6 +107,14 @@
 else:
 s_context.push(nlr.value)
 
+def _get_adapted_tick_counter(self):
+# Normally, the tick counter is decremented by 1 for every message 
send.
+# Since we don't know how many messages are called during this trace, 
we
+# just decrement by 10th of the trace length (num of bytecodes).
+trace_length = jit.current_trace_length()
+decr_by = int(trace_length // 10)
+return max(decr_by, 1)
+
 def stack_frame(self, s_new_frame):
 if not self._loop:
 return s_new_frame # this test is done to not loop in test,
@@ -138,6 +153,36 @@
 except ReturnFromTopLevel, e:
 return e.object
 
+def quick_check_for_interrupt(self, s_frame, dec=1):
+self.interrupt_check_counter -= dec
+if self.interrupt_check_counter = 0:
+self.interrupt_check_counter = constants.INTERRUPT_COUNTER_SIZE
+self.check_for_interrupts(s_frame)
+
+def check_for_interrupts(self, s_frame):
+# parallel to Interpreter#checkForInterrupts
+import time, math
+
+# Profiling is skipped
+# We don't adjust the check counter size
+
+# use the same time value as the primitive MILLISECOND_CLOCK
+now = int(math.fmod(time.time()*1000, constants.TAGGED_MAXINT/2))
+
+# XXX the low space semaphore may be signaled here
+# Process inputs
+# Process User Interrupt?
+if not self.next_wakeup_tick == 0 and now = self.next_wakeup_tick:
+self.next_wakeup_tick = 0
+semaphore = self.space.objtable[w_timerSemaphore]
+if not semaphore.is_same_object(self.space.w_nil):
+wrapper.SemaphoreWrapper(self.space, 
semaphore).signal(s_frame.w_self())
+# We have no finalization process, so far.
+# We do not support external semaphores.
+# In cog, the method to add such a semaphore is only called in GC.
+
+
+
 class ReturnFromTopLevel(Exception):
 def __init__(self, object):
 self.object = object
diff --git a/spyvm/primitives.py b/spyvm/primitives.py
--- a/spyvm/primitives.py
+++ b/spyvm/primitives.py
@@ -823,14 +823,26 @@
 #
 # Time Primitives (135 - 137)
 MILLISECOND_CLOCK = 135
+SIGNAL_AT_MILLISECONDS = 136
 SECONDS_CLOCK = 137
 
 @expose_primitive(MILLISECOND_CLOCK, unwrap_spec=[object])
 def func(interp, s_frame, w_arg):
-import time
-import math
+import time, math
 return interp.space.wrap_int(int(math.fmod(time.time()*1000, 

[pypy-commit] lang-gameboy default: (jlincke, timfel) Add a test for blitting surface from pixelbuffer

2013-03-21 Thread timfel
Author: Tim Felgentreff timfelgentr...@gmail.com
Branch: 
Changeset: r6:c419533d2000
Date: 2013-03-15 17:57 +0100
http://bitbucket.org/pypy/lang-gameboy/changeset/c419533d2000/

Log:(jlincke, timfel) Add a test for blitting surface from pixelbuffer

diff --git a/rsdl/test/test_video.py b/rsdl/test/test_video.py
--- a/rsdl/test/test_video.py
+++ b/rsdl/test/test_video.py
@@ -236,6 +236,35 @@
 RSDL.FreeSurface(surface)
 self.check(Half Red/Orange rectangle(150px * 50px) at the top left, 
10 pixels from the border)
 
+
+def test_blit_pxrect(self):
+max  = 150 * 50
+surfacepx = lltype.malloc(rffi.VOIDP.TO, max * 4, flavor='raw')
+pos = 0
+for i in xrange(max):
+surfacepx[pos] = chr(int(float(i) / max * 255))
+surfacepx[pos + 1] = chr(int(float(i) / max * 255))
+surfacepx[pos + 2] = chr(int(float(i) / max * 255))
+surfacepx[pos + 3] = chr(255)
+pos += 4
+
+pitch = 4 * 150 # 4 byte per line * width
+surface = RSDL.CreateRGBSurfaceFrom(surfacepx, 150, 50, 32, pitch,
+r_uint(0x00FF),
+r_uint(0xFF00),
+r_uint(0x00FF),
+r_uint(0xFF00))
+
+dstrect = RSDL_helper.mallocrect(0, 0, 150, 50)
+try:
+RSDL.BlitSurface(surface, lltype.nullptr(RSDL.Rect), self.screen, 
dstrect)
+RSDL.Flip(self.screen)
+finally:
+lltype.free(dstrect, flavor='raw')
+RSDL.FreeSurface(surface)
+lltype.free(surfacepx, flavor='raw')
+self.check(Gradient from black to white rectangle(150px * 50px) at 
the top left)
+
 def teardown_method(self, meth):
 RSDL.Quit()
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] lang-js default: added annotation

2013-03-21 Thread stepahn
Author: Stephan step...@stzal.com
Branch: 
Changeset: r372:1d6b0ccb866f
Date: 2013-03-20 17:46 +0100
http://bitbucket.org/pypy/lang-js/changeset/1d6b0ccb866f/

Log:added annotation

diff --git a/js/jsobj.py b/js/jsobj.py
--- a/js/jsobj.py
+++ b/js/jsobj.py
@@ -956,6 +956,7 @@
 from js.object_space import object_space
 _map = object_space.new_obj()
 mapped_names = new_map()
+jit.promote(_len)
 indx = _len - 1
 while indx = 0:
 val = args[indx]
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] lang-js default: changed version string to include hg id and build time

2013-03-21 Thread stepahn
Author: Stephan step...@stzal.com
Branch: 
Changeset: r373:2d3ad1d9eda1
Date: 2013-03-21 16:33 +0100
http://bitbucket.org/pypy/lang-js/changeset/2d3ad1d9eda1/

Log:changed version string to include hg id and build time

diff --git a/js/builtins/js_global.py b/js/builtins/js_global.py
--- a/js/builtins/js_global.py
+++ b/js/builtins/js_global.py
@@ -329,9 +329,21 @@
 pass
 
 
+def _make_version_string():
+import subprocess
+import time
+
+repo_id = subprocess.check_output('hg id -i'.split()).strip()
+current_time = time.asctime(time.gmtime())
+
+return '1.0; Build: %s; %s' % (repo_id, current_time)
+
+_version_string = _make_version_string()
+
+
 @w_return
 def version(this, args):
-return '1.0'
+return _version_string
 
 
 # 15.1.2.1
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] lang-gameboy default: add external compilation info branch for windows

2013-03-21 Thread timfel
Author: Tim Felgentreff timfelgentr...@gmail.com
Branch: 
Changeset: r7:f85b5515ccef
Date: 2013-03-21 16:33 +0100
http://bitbucket.org/pypy/lang-gameboy/changeset/f85b5515ccef/

Log:add external compilation info branch for windows

diff --git a/rsdl/eci.py b/rsdl/eci.py
--- a/rsdl/eci.py
+++ b/rsdl/eci.py
@@ -2,6 +2,7 @@
 from rpython.translator.platform import CompilationError
 import py
 import sys
+import os
 
 def get_rsdl_compilation_info():
 if sys.platform == 'darwin':
@@ -13,6 +14,31 @@
 ],
 frameworks = ['SDL', 'Cocoa']
 )
+elif sys.platform == win32:
+try:
+sdl_prefix = os.path.abspath(os.environ[SDL_PREFIX])
+except KeyError:
+print You need to provide the path to SDL using the SDL_PREFIX 
environment variable
+exit(1)
+
+# XXX: SDL_main.h does a #define main SDL_main
+# This causes a linker error with the VS C compiler
+# The solution is to #undef main before we define our own
+this_dir = os.path.dirname(__file__)
+f = open(os.path.join(this_dir, RSDL_undef_main.h), w)
+print  f, #undef main
+f.close()
+
+eci = ExternalCompilationInfo(
+includes = ['SDL.h', 'RSDL_undef_main.h'],
+include_dirs = [os.path.join(sdl_prefix, include), this_dir],
+link_files = [
+os.path.join(sdl_prefix, lib, x86, SDLmain.lib),
+os.path.join(sdl_prefix, lib, x86, SDL.lib)
+],
+libraries = [SDL],
+library_dirs = [os.path.join(sdl_prefix, lib, x86)],
+)
 else:
 eci = ExternalCompilationInfo(
 includes=['SDL.h'],
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] lang-js default: backed out of 9e9af1fdf61d due to performance issues

2013-03-21 Thread stepahn
Author: Stephan step...@stzal.com
Branch: 
Changeset: r374:81e6e06fb4aa
Date: 2013-03-21 16:35 +0100
http://bitbucket.org/pypy/lang-js/changeset/81e6e06fb4aa/

Log:backed out of 9e9af1fdf61d due to performance issues

diff --git a/js/jsobj.py b/js/jsobj.py
--- a/js/jsobj.py
+++ b/js/jsobj.py
@@ -1187,6 +1187,7 @@
 
 
 @enforceargs(int)
+@jit.elidable
 def int32(n):
 if n  (1  (32 - 1)):
 res = n | ~MASK_32
@@ -1197,11 +1198,13 @@
 
 
 @enforceargs(int)
+@jit.elidable
 def uint32(n):
 return n  MASK_32
 
 
 @enforceargs(int)
+@jit.elidable
 def uint16(n):
 return n  MASK_16
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] lang-gameboy default: remove moved files

2013-03-21 Thread timfel
Author: Tim Felgentreff timfelgentr...@gmail.com
Branch: 
Changeset: r9:3dd131846afc
Date: 2013-03-21 16:53 +0100
http://bitbucket.org/pypy/lang-gameboy/changeset/3dd131846afc/

Log:remove moved files

diff --git a/rsdl/RIMG.py b/rsdl/RIMG.py
deleted file mode 100644
--- a/rsdl/RIMG.py
+++ /dev/null
@@ -1,25 +0,0 @@
-import sys
-from rpython.rtyper.lltypesystem import lltype, rffi
-from rpython.rtyper.tool import rffi_platform as platform
-from rpython.translator.tool.cbuild import ExternalCompilationInfo
-from rsdl import RSDL
-
-
-if sys.platform == 'darwin':
-eci = ExternalCompilationInfo(
-includes = ['SDL_image.h'],
-frameworks = ['SDL_image'],
-include_dirs = ['/Library/Frameworks/SDL_image.framework/Headers']
-)
-else:
-eci = ExternalCompilationInfo(
-includes=['SDL_image.h'],
-libraries=['SDL_image'],
-)
-
-eci = eci.merge(RSDL.eci)
-
-def external(name, args, result):
-return rffi.llexternal(name, args, result, compilation_info=eci)
-
-Load = external('IMG_Load', [rffi.CCHARP], RSDL.SurfacePtr)
diff --git a/rsdl/RMix.py b/rsdl/RMix.py
deleted file mode 100644
--- a/rsdl/RMix.py
+++ /dev/null
@@ -1,68 +0,0 @@
-import sys
-from rpython.rtyper.lltypesystem import lltype, rffi
-from rpython.rtyper.tool import rffi_platform as platform
-from rpython.translator.tool.cbuild import ExternalCompilationInfo
-from rsdl import RSDL
-
-
-if sys.platform == 'darwin':
-eci = ExternalCompilationInfo(
-includes = ['SDL_mixer.h'],
-frameworks = ['SDL_mixer'],
-include_dirs = ['/Library/Frameworks/SDL_Mixer.framework/Headers']
-)
-else:
-eci = ExternalCompilationInfo(
-includes=['SDL_mixer.h'],
-libraries=['SDL_mixer'],
-)
-
-eci = eci.merge(RSDL.eci)
-eci = eci.merge(eci)
-eci = eci.merge(eci)
-
-ChunkPtr = lltype.Ptr(lltype.ForwardReference())
-
-class CConfig:
-_compilation_info_ = eci
-
-Chunk  = platform.Struct('Mix_Chunk', [('allocated', rffi.INT),
-   ('abuf', RSDL.Uint8P),
-   ('alen', RSDL.Uint32),
-   ('volume', RSDL.Uint8)])
-
-globals().update(platform.configure(CConfig))
-
-ChunkPtr.TO.become(Chunk)
-
-
-Buffer = rffi.CArray(RSDL.Uint8)
-
-def external(name, args, result):
-return rffi.llexternal(name, args, result, compilation_info=eci)
-
-OpenAudio   = external('Mix_OpenAudio',
-   [rffi.INT, RSDL.Uint16, rffi.INT, rffi.INT],
-   rffi.INT)
-
-CloseAudio  = external('Mix_CloseAudio', [], lltype.Void)
-
-LoadWAV_RW  = external('Mix_LoadWAV_RW',
-   [RSDL.RWopsPtr, rffi.INT],
-   ChunkPtr)
-
-def LoadWAV(filename_ccharp):
-with rffi.scoped_str2charp('rb') as mode:
-return LoadWAV_RW(RSDL.RWFromFile(filename_ccharp, mode), 1)
-
-
-PlayChannelTimed= external('Mix_PlayChannelTimed',
-   [rffi.INT, ChunkPtr, rffi.INT, rffi.INT],
-   rffi.INT)
-
-def PlayChannel(channel,chunk,loops):
-return PlayChannelTimed(channel, chunk, loops, -1)
-
-Returns zero if the channel is not playing. 
-Otherwise if you passed in -1, the number of channels playing is returned
-ChannelPlaying  = external('Mix_Playing', [rffi.INT], rffi.INT)
diff --git a/rsdl/RMix_helper.py b/rsdl/RMix_helper.py
deleted file mode 100644
--- a/rsdl/RMix_helper.py
+++ /dev/null
@@ -1,24 +0,0 @@
-from pypy.rpython.lltypesystem import lltype, rffi
-from rsdl import RMix, RSDL
-from pypy.rpython.tool import rffi_platform as platform
-
-
-def malloc_buffer_chunk(has_own_allocated_buffer, length_bytes, volume):
-buffer_pointer = lltype.malloc(RMix.Buffer, length_bytes, flavor='raw')
-return malloc_chunk(has_own_allocated_buffer, length_bytes, volume)
-
-def malloc_chunk(has_own_allocated_buffer, buffer_pointer, length_bytes, 
volume):
-
-Creates a new Mix_Chunk.
-has_own_allocated_buffer:  if 1 struct has its own allocated buffer, 
-if 0 abuf should not be freed
-buffer_pointer: pointer to audio data
-length_bytes:   length of audio data in bytes
-volume: Per-sample volume, 0-128 (normally 
-MIX_MAX_VOLUME after loading)
-p = lltype.malloc(RMix.Chunk, flavor='raw')
-rffi.setintfield(p, 'c_allocated', has_own_allocated_buffer)
-rffi.setintfield(p, 'c_abuf', buffer_pointer)
-rffi.setintfield(p, 'c_alen', length_bytes)
-rffi.setintfield(p, 'c_volume', volume)
-return p
diff --git a/rsdl/RSDL.py b/rsdl/RSDL.py
deleted file mode 100644
--- a/rsdl/RSDL.py
+++ /dev/null
@@ -1,254 +0,0 @@
-from rpython.rtyper.lltypesystem import lltype, rffi
-from rpython.rtyper.tool import rffi_platform 

[pypy-commit] pypy default: also lazily construct bigbuffer object in RStringIO

2013-03-21 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: 
Changeset: r62611:2922803f28f3
Date: 2013-03-21 06:45 -0400
http://bitbucket.org/pypy/pypy/changeset/2922803f28f3/

Log:also lazily construct bigbuffer object in RStringIO

diff --git a/rpython/rlib/rStringIO.py b/rpython/rlib/rStringIO.py
--- a/rpython/rlib/rStringIO.py
+++ b/rpython/rlib/rStringIO.py
@@ -15,21 +15,23 @@
 #  * the list of characters self.bigbuffer;
 #  * each of the strings in self.strings.
 #
+self.closed = False
 self.strings = None
-self.bigbuffer = []
+self.bigbuffer = None
 self.pos = AT_END
 
 def close(self):
+self.closed = True
 self.strings = None
 self.bigbuffer = None
 
 def is_closed(self):
-return self.bigbuffer is None
+return self.closed
 
 def getvalue(self):
 If self.strings contains more than 1 string, join all the
 strings together.  Return the final single string.
-if len(self.bigbuffer):
+if self.bigbuffer is not None:
 self.copy_into_bigbuffer()
 return ''.join(self.bigbuffer)
 if self.strings is not None:
@@ -37,13 +39,17 @@
 return ''
 
 def getsize(self):
-result = len(self.bigbuffer)
+result = 0
+if self.bigbuffer is not None:
+result += len(self.bigbuffer)
 if self.strings is not None:
 result += self.strings.getlength()
 return result
 
 def copy_into_bigbuffer(self):
 Copy all the data into the list of characters self.bigbuffer.
+if self.bigbuffer is None:
+self.bigbuffer = []
 if self.strings is not None:
 self.bigbuffer += self.strings.build()
 self.strings = None
@@ -56,7 +62,7 @@
 if p != AT_END:# slow or semi-fast paths
 assert p = 0
 endp = p + len(buffer)
-if len(self.bigbuffer) = endp:
+if self.bigbuffer is not None and len(self.bigbuffer) = endp:
 # semi-fast path: the write is entirely inside self.bigbuffer
 for i in range(len(buffer)):
 self.bigbuffer[p + i] = buffer[i]
@@ -152,7 +158,7 @@
 # than CPython: it never grows the buffer, and it sets the current
 # position to the end.
 assert size = 0
-if size  len(self.bigbuffer):
+if self.bigbuffer is None or size  len(self.bigbuffer):
 self.copy_into_bigbuffer()
 else:
 # we can drop all extra strings
@@ -160,4 +166,6 @@
 self.strings = None
 if size  len(self.bigbuffer):
 del self.bigbuffer[size:]
+if len(self.bigbuffer) == 0:
+self.bigbuffer = None
 self.pos = AT_END
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: merge heads

2013-03-21 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: 
Changeset: r62613:b1a1549418d9
Date: 2013-03-21 15:05 -0400
http://bitbucket.org/pypy/pypy/changeset/b1a1549418d9/

Log:merge heads

diff --git a/rpython/jit/backend/arm/assembler.py 
b/rpython/jit/backend/arm/assembler.py
--- a/rpython/jit/backend/arm/assembler.py
+++ b/rpython/jit/backend/arm/assembler.py
@@ -242,7 +242,7 @@
 #
 mc = ARMv7Builder()
 # save argument registers and return address
-mc.PUSH([reg.value for reg in r.argument_regs] + [r.lr.value])
+mc.PUSH([reg.value for reg in r.argument_regs] + [r.ip.value, 
r.lr.value])
 # stack is aligned here
 # Pass current stack pointer as argument to the call
 mc.MOV_rr(r.r0.value, r.sp.value)
@@ -253,21 +253,13 @@
 mc.gen_load_int(r.r0.value, self.cpu.pos_exception())
 mc.LDR_ri(r.r0.value, r.r0.value)
 mc.TST_rr(r.r0.value, r.r0.value)
+#
 # restore registers and return
 # We check for c.EQ here, meaning all bits zero in this case
-mc.POP([reg.value for reg in r.argument_regs] + [r.pc.value], 
cond=c.EQ)
-#
-# Call the helper, which will return a dead frame object with
-# the correct exception set, or MemoryError by default
-addr = rffi.cast(lltype.Signed, self.cpu.get_propagate_exception())
-mc.BL(addr)
-#
-# footer -- note the ADD, which skips the return address of this
-# function, and will instead return to the caller's caller.  Note
-# also that we completely ignore the saved arguments, because we
-# are interrupting the function.
-mc.ADD_ri(r.sp.value, r.sp.value, (len(r.argument_regs) + 1) * WORD)
-mc.POP([r.pc.value])
+mc.POP([reg.value for reg in r.argument_regs] + [r.ip.value, 
r.pc.value], cond=c.EQ)
+# restore sp
+mc.ADD_ri(r.sp.value, r.sp.value, (len(r.argument_regs) + 2) * WORD)
+mc.B(self.propagate_exception_path)
 #
 rawstart = mc.materialize(self.cpu.asmmemmgr, [])
 self.stack_check_slowpath = rawstart
@@ -311,6 +303,8 @@
 else:
 self._restore_exception(mc, exc0, exc1)
 mc.VPOP([vfpr.value for vfpr in r.caller_vfp_resp])
+assert exc0 is not None
+   assert exc1 is not None
 mc.POP([gpr.value for gpr in r.caller_resp] +
 [exc0.value, exc1.value])
 #
@@ -505,7 +499,7 @@
 if self.cpu.supports_floats:
 mc.VPOP([reg.value for reg in r.callee_saved_vfp_registers],
 cond=cond)
-# push all callee saved registers and IP to keep the alignment
+# pop all callee saved registers and IP to keep the alignment
 mc.POP([reg.value for reg in r.callee_restored_registers] +
[r.ip.value], cond=cond)
 mc.BKPT()
@@ -564,11 +558,11 @@
 self.gen_func_prolog()
 
 def _call_header_with_stack_check(self):
+self._call_header()
 if self.stack_check_slowpath == 0:
 pass# no stack check (e.g. not translated)
 else:
 endaddr, lengthaddr, _ = self.cpu.insert_stack_check()
-self.mc.PUSH([r.lr.value])
 # load stack end
 self.mc.gen_load_int(r.ip.value, endaddr)  # load ip, [end]
 self.mc.LDR_ri(r.ip.value, r.ip.value) # LDR ip, ip
@@ -580,9 +574,6 @@
 # if ofs
 self.mc.CMP_rr(r.ip.value, r.lr.value) # CMP ip, lr
 self.mc.BL(self.stack_check_slowpath, c=c.HI)  # call if ip  
lr
-#
-self.mc.POP([r.lr.value])
-self._call_header()
 
 # cpu interface
 def assemble_loop(self, loopname, inputargs, operations, looptoken, log):
diff --git a/rpython/jit/backend/arm/test/test_calling_convention.py 
b/rpython/jit/backend/arm/test/test_calling_convention.py
--- a/rpython/jit/backend/arm/test/test_calling_convention.py
+++ b/rpython/jit/backend/arm/test/test_calling_convention.py
@@ -4,12 +4,23 @@
 from rpython.rtyper.lltypesystem import lltype
 from rpython.jit.codewriter.effectinfo import EffectInfo
 
+from rpython.jit.backend.arm.codebuilder import ARMv7Builder
+from rpython.jit.backend.arm import registers as r
 from rpython.jit.backend.arm.test.support import skip_unless_run_slow_tests
 skip_unless_run_slow_tests()
 
 class TestARMCallingConvention(CallingConvTests):
 # ../../test/calling_convention_test.py
 
+def make_function_returning_stack_pointer(self):
+mc = ARMv7Builder()
+   mc.MOV_rr(r.r0.value, r.sp.value)
+   mc.MOV_rr(r.pc.value, r.lr.value)
+return mc.materialize(self.cpu.asmmemmgr, [])
+
+def get_alignment_requirements(self):
+return 8
+
 def test_call_argument_spilling(self):
 # bug when 

[pypy-commit] lang-smalltalk default: fixed bitBlit primitive and test

2013-03-21 Thread lwassermann
Author: Lars Wassermann lars.wasserm...@gmail.com
Branch: 
Changeset: r231:4398592999e8
Date: 2013-03-21 18:01 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/4398592999e8/

Log:fixed bitBlit primitive and test fixed some problems with testing
sequence

diff --git a/spyvm/interpreter.py b/spyvm/interpreter.py
--- a/spyvm/interpreter.py
+++ b/spyvm/interpreter.py
@@ -62,20 +62,18 @@
 self._loop = True
 s_new_context = w_active_context.as_context_get_shadow(self.space)
 while True:
+assert self.remaining_stack_depth == self.max_stack_depth
 s_sender = s_new_context.s_sender()
 try:
 s_new_context = self.c_loop(s_new_context)
 except StackOverflow, e:
-self.remaining_stack_depth = self.max_stack_depth
 s_new_context = e.s_context
 except Return, nlr:
 while s_new_context is not nlr.s_target_context:
 s_new_context.mark_returned()
 s_new_context = s_sender
-self.remaining_stack_depth = self.max_stack_depth
 s_new_context.push(nlr.value)
 except ProcessSwitch, p:
-self.remaining_stack_depth = self.max_stack_depth
 s_new_context = p.s_new_context
 
 def c_loop(self, s_context):
@@ -119,7 +117,7 @@
 if not self._loop:
 return s_new_frame # this test is done to not loop in test,
# but rather step just once where wanted
-if self.remaining_stack_depth == 1:
+if self.remaining_stack_depth = 1:
 raise StackOverflow(s_new_frame)
 
 self.remaining_stack_depth -= 1
diff --git a/spyvm/primitives.py b/spyvm/primitives.py
--- a/spyvm/primitives.py
+++ b/spyvm/primitives.py
@@ -557,11 +557,13 @@
 if not isinstance(w_rcvr, model.W_PointersObject) or w_rcvr.size()  15:
 raise PrimitiveFailedError
 
-interp.perform(w_rcvr, simulateCopyBits)
+space = interp.space
+s_frame.push(w_rcvr)
+s_frame._sendSelfSelector(interp.image.w_simulateCopyBits, 0, interp)
 
-w_dest_form = w_rcvr.fetch(interp.space, 0)
-if w_dest_form.is_same_object(interp.space.objtable['w_display']):
-w_bitmap = w_dest_form.fetch(interp.space, 0)
+w_dest_form = w_rcvr.fetch(space, 0)
+if w_dest_form.is_same_object(space.objtable['w_display']):
+w_bitmap = w_dest_form.fetch(space, 0)
 assert isinstance(w_bitmap, model.W_DisplayBitmap)
 w_bitmap.flush_to_screen()
 
diff --git a/spyvm/squeakimage.py b/spyvm/squeakimage.py
--- a/spyvm/squeakimage.py
+++ b/spyvm/squeakimage.py
@@ -369,9 +369,10 @@
 for name, idx in constants.objects_in_special_object_table.items():
 space.objtable[w_ + name] = self.special_objects[idx]
 
-self.w_asSymbol = self.find_asSymbol(space, reader)
+self.w_asSymbol = self.find_symbol(space, reader, asSymbol)
+self.w_simulateCopyBits = self.find_symbol(space, reader, 
simulateCopyBits)
 
-def find_asSymbol(self, space, reader):
+def find_symbol(self, space, reader, symbol):
 w_dnu = self.special(constants.SO_DOES_NOT_UNDERSTAND)
 assert isinstance(w_dnu, model.W_BytesObject)
 assert w_dnu.as_string() == doesNotUnderstand:
@@ -384,7 +385,7 @@
 continue
 if not w_obj.getclass(space).is_same_object(w_Symbol):
 continue
-if w_obj.as_string() == asSymbol:
+if w_obj.as_string() == symbol:
 break
 assert w_obj is not None
 return w_obj
diff --git a/spyvm/test/test_miniimage.py b/spyvm/test/test_miniimage.py
--- a/spyvm/test/test_miniimage.py
+++ b/spyvm/test/test_miniimage.py
@@ -314,26 +314,6 @@
 size = prim(primitives.PERFORM_WITH_ARGS, [w_o, w_sel, []])
 assert size.value == 3
 
-def test_step_run_something():
-from spyvm.test import test_miniimage
-setup_module(test_miniimage, filename='running-something-mini.image')
-from spyvm import wrapper
-ap = wrapper.ProcessWrapper(space, 
wrapper.scheduler(space).active_process())
-w_ctx = ap.suspended_context()
-s_ctx = w_ctx.as_context_get_shadow(space)
-ap.store_suspended_context(space.w_nil)
-
-interp = interpreter.Interpreter(space)
-assert isinstance(s_ctx, shadow.MethodContextShadow)
-assert s_ctx.top().is_same_object(space.w_true)
-interp.step(s_ctx)
-interp.step(s_ctx)
-assert s_ctx.top().value == 1
-interp.step(s_ctx)
-assert s_ctx.top().value == 2
-interp.step(s_ctx)
-assert s_ctx.top().value == 3
-
 def test_create_new_symbol():
 w_result = perform(w(someString), asSymbol)
 assert w_result is not None
@@ -404,3 +384,23 @@
 assert s_message_cls.getname() == Message class
 w_message = s_message_cls.new()
 assert isinstance(w_message, model.W_PointersObject)
+
+def 

[pypy-commit] pypy default: Merged in chrish42/pypy (pull request #139)

2013-03-21 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: 
Changeset: r62615:93bc1578182f
Date: 2013-03-21 13:22 -0700
http://bitbucket.org/pypy/pypy/changeset/93bc1578182f/

Log:Merged in chrish42/pypy (pull request #139)

Fix gethostbyaddr() test on some versions of MacOSX.

diff --git a/pypy/module/_socket/test/test_sock_app.py 
b/pypy/module/_socket/test/test_sock_app.py
--- a/pypy/module/_socket/test/test_sock_app.py
+++ b/pypy/module/_socket/test/test_sock_app.py
@@ -35,13 +35,15 @@
 def test_gethostbyaddr():
 host = localhost
 expected = socket.gethostbyaddr(host)
-expecteds = (expected, expected[:2]+(['0.0.0.0'],))
+# On some versions of MacOSX, we get two '0.0.0.0' entries in the 
addresslist.
+expecteds = (expected, expected[:2] + (['0.0.0.0'], ), expected[:2] + 
(['0.0.0.0']*2, ))
 ip = space.appexec([w_socket, space.wrap(host)],
(_socket, host): return _socket.gethostbyaddr(host))
 assert space.unwrap(ip) in expecteds
 host = 127.0.0.1
 expected = socket.gethostbyaddr(host)
-expecteds = (expected, expected[:2]+(['0.0.0.0'],))
+# On some versions of MacOSX, we get two '0.0.0.0' entries in the 
addresslist.
+expecteds = (expected, expected[:2] + (['0.0.0.0'], ), expected[:2] + 
(['0.0.0.0']*2, ))
 ip = space.appexec([w_socket, space.wrap(host)],
(_socket, host): return _socket.gethostbyaddr(host))
 assert space.unwrap(ip) in expecteds
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix gethostbyaddr() test on some versions of MacOSX.

2013-03-21 Thread chrish42
Author: Christian Hudon chr...@pianocktail.org
Branch: 
Changeset: r62614:efd767a61b59
Date: 2013-03-19 14:11 -0700
http://bitbucket.org/pypy/pypy/changeset/efd767a61b59/

Log:Fix gethostbyaddr() test on some versions of MacOSX.

diff --git a/pypy/module/_socket/test/test_sock_app.py 
b/pypy/module/_socket/test/test_sock_app.py
--- a/pypy/module/_socket/test/test_sock_app.py
+++ b/pypy/module/_socket/test/test_sock_app.py
@@ -35,13 +35,15 @@
 def test_gethostbyaddr():
 host = localhost
 expected = socket.gethostbyaddr(host)
-expecteds = (expected, expected[:2]+(['0.0.0.0'],))
+# On some versions of MacOSX, we get two '0.0.0.0' entries in the 
addresslist.
+expecteds = (expected, expected[:2] + (['0.0.0.0'], ), expected[:2] + 
(['0.0.0.0']*2, ))
 ip = space.appexec([w_socket, space.wrap(host)],
(_socket, host): return _socket.gethostbyaddr(host))
 assert space.unwrap(ip) in expecteds
 host = 127.0.0.1
 expected = socket.gethostbyaddr(host)
-expecteds = (expected, expected[:2]+(['0.0.0.0'],))
+# On some versions of MacOSX, we get two '0.0.0.0' entries in the 
addresslist.
+expecteds = (expected, expected[:2] + (['0.0.0.0'], ), expected[:2] + 
(['0.0.0.0']*2, ))
 ip = space.appexec([w_socket, space.wrap(host)],
(_socket, host): return _socket.gethostbyaddr(host))
 assert space.unwrap(ip) in expecteds
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: remove this random/unexplained loosening of test, it represents bogus behavior

2013-03-21 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: 
Changeset: r62616:95f16920996f
Date: 2013-03-21 17:02 -0400
http://bitbucket.org/pypy/pypy/changeset/95f16920996f/

Log:remove this random/unexplained loosening of test, it represents
bogus behavior

diff --git a/pypy/module/_socket/test/test_sock_app.py 
b/pypy/module/_socket/test/test_sock_app.py
--- a/pypy/module/_socket/test/test_sock_app.py
+++ b/pypy/module/_socket/test/test_sock_app.py
@@ -35,18 +35,14 @@
 def test_gethostbyaddr():
 host = localhost
 expected = socket.gethostbyaddr(host)
-# On some versions of MacOSX, we get two '0.0.0.0' entries in the 
addresslist.
-expecteds = (expected, expected[:2] + (['0.0.0.0'], ), expected[:2] + 
(['0.0.0.0']*2, ))
 ip = space.appexec([w_socket, space.wrap(host)],
(_socket, host): return _socket.gethostbyaddr(host))
-assert space.unwrap(ip) in expecteds
+assert space.unwrap(ip) == socket.gethostbyaddr(host)
+
 host = 127.0.0.1
-expected = socket.gethostbyaddr(host)
-# On some versions of MacOSX, we get two '0.0.0.0' entries in the 
addresslist.
-expecteds = (expected, expected[:2] + (['0.0.0.0'], ), expected[:2] + 
(['0.0.0.0']*2, ))
 ip = space.appexec([w_socket, space.wrap(host)],
(_socket, host): return _socket.gethostbyaddr(host))
-assert space.unwrap(ip) in expecteds
+assert space.unwrap(ip) == socket.gethostbyaddr(host)
 
 def test_getservbyname():
 name = smtp
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fixes for RSocket IPV6 support

2013-03-21 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: 
Changeset: r62619:bd0e0b2b11bb
Date: 2013-03-21 19:28 -0400
http://bitbucket.org/pypy/pypy/changeset/bd0e0b2b11bb/

Log:fixes for RSocket IPV6 support

diff --git a/rpython/rlib/_rsocket_rffi.py b/rpython/rlib/_rsocket_rffi.py
--- a/rpython/rlib/_rsocket_rffi.py
+++ b/rpython/rlib/_rsocket_rffi.py
@@ -262,7 +262,7 @@
 CConfig.in_addr = platform.Struct('struct in_addr',
  [('s_addr', rffi.UINT)])
 CConfig.in6_addr = platform.Struct('struct in6_addr',
-  [])
+  [('s6_addr', 
rffi.CFixedArray(rffi.CHAR, 16))])
 CConfig.sockaddr_in = platform.Struct('struct sockaddr_in',
 [('sin_family', rffi.INT),
  ('sin_port',   rffi.USHORT),
diff --git a/rpython/rlib/rsocket.py b/rpython/rlib/rsocket.py
--- a/rpython/rlib/rsocket.py
+++ b/rpython/rlib/rsocket.py
@@ -339,7 +339,7 @@
 # to avoid leaks if an exception occurs inbetween
 sin = lltype.malloc(_c.sockaddr_in6, flavor='raw', zero=True)
 result.setdata(sin, sizeof(_c.sockaddr_in6))
-rffi.setintfield(sin, 'c_sin6_family', AF_INET)
+rffi.setintfield(sin, 'c_sin6_family', AF_INET6)
 rffi.structcopy(sin.c_sin6_addr, in6_addr)
 return result
 from_in6_addr = staticmethod(from_in6_addr)
diff --git a/rpython/rlib/test/test_rsocket.py 
b/rpython/rlib/test/test_rsocket.py
--- a/rpython/rlib/test/test_rsocket.py
+++ b/rpython/rlib/test/test_rsocket.py
@@ -68,17 +68,17 @@
  % (address_list,))
 
 def test_gethostbyaddr():
-for host in [localhost, 127.0.0.1]:
+for host in [localhost, 127.0.0.1, ::1]:
 name, aliases, address_list = gethostbyaddr(host)
 allnames = [name] + aliases
 for n in allnames:
 assert isinstance(n, str)
 if sys.platform != 'win32':
-assert 'localhost' in allnames
+assert 'localhost' in allnames or 'ip6-localhost' in allnames
 for a in address_list:
 if isinstance(a, INETAddress) and a.get_host() == 127.0.0.1:
 break  # ok
-if host == 'localhost':  # name lookup might return IPV6
+if host != '127.0.0.1':  # name lookup might return IPV6
 if isinstance(a, INET6Address) and a.get_host() == ::1:
 break  # ok
 else:
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: test ip6-loopback here too

2013-03-21 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: 
Changeset: r62620:ec25836976ee
Date: 2013-03-21 19:35 -0400
http://bitbucket.org/pypy/pypy/changeset/ec25836976ee/

Log:test ip6-loopback here too

diff --git a/pypy/module/_socket/test/test_sock_app.py 
b/pypy/module/_socket/test/test_sock_app.py
--- a/pypy/module/_socket/test/test_sock_app.py
+++ b/pypy/module/_socket/test/test_sock_app.py
@@ -32,7 +32,7 @@
 assert space.unwrap(ip) == socket.gethostbyname_ex(host)
 
 def test_gethostbyaddr():
-for host in [localhost, 127.0.0.1]:
+for host in [localhost, 127.0.0.1, ::1]:
 ip = space.appexec([w_socket, space.wrap(host)],
(_socket, host): return 
_socket.gethostbyaddr(host))
 assert space.unwrap(ip) == socket.gethostbyaddr(host)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy remove-string-smm: Remove undeed SMM definition.

2013-03-21 Thread hodgestar
Author: Simon Cross hodges...@gmail.com
Branch: remove-string-smm
Changeset: r62621:a05eeef6cfb0
Date: 2013-03-22 01:09 +0200
http://bitbucket.org/pypy/pypy/changeset/a05eeef6cfb0/

Log:Remove undeed SMM definition.

diff --git a/pypy/objspace/std/bytearraytype.py 
b/pypy/objspace/std/bytearraytype.py
--- a/pypy/objspace/std/bytearraytype.py
+++ b/pypy/objspace/std/bytearraytype.py
@@ -19,7 +19,6 @@
 from pypy.objspace.std.bytearrayinterface import bytearray_interface_methods
 
 
-str_ljust = SMM('ljust', 3, defaults=(' ',))
 str_join = SMM('join', 2, defaults=(None,-1))
 
 bytearray_insert  = SMM('insert', 3,
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy remove-string-smm: Re-implement bytearray.insert.

2013-03-21 Thread hodgestar
Author: Simon Cross hodges...@gmail.com
Branch: remove-string-smm
Changeset: r62622:c7554e6db542
Date: 2013-03-22 01:42 +0200
http://bitbucket.org/pypy/pypy/changeset/c7554e6db542/

Log:Re-implement bytearray.insert.

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1322,6 +1322,11 @@
 return None
 return self.str_w(w_obj)
 
+def str_or_int_w(self, w_obj):
+if self.is_true(self.isinstance(w_obj, self.w_str)):
+return self.str_w(w_obj)
+return self.int_w(w_obj)
+
 def str_w(self, w_obj):
 return w_obj.str_w(self)
 
diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py
--- a/pypy/interpreter/gateway.py
+++ b/pypy/interpreter/gateway.py
@@ -129,6 +129,9 @@
 def visit_str_or_None(self, el, app_sig):
 self.checked_space_method(el, app_sig)
 
+def visit_str_or_int(self, el, app_sig):
+self.checked_space_method(el, app_sig)
+
 def visit_str0(self, el, app_sig):
 self.checked_space_method(el, app_sig)
 
@@ -247,6 +250,9 @@
 def visit_str_or_None(self, typ):
 self.run_args.append(space.str_or_None_w(%s) % (self.scopenext(),))
 
+def visit_str_or_int(self, typ):
+self.run_args.append(space.str_or_int_w(%s) % (self.scopenext(),))
+
 def visit_str0(self, typ):
 self.run_args.append(space.str0_w(%s) % (self.scopenext(),))
 
diff --git a/pypy/objspace/std/bytearrayobject.py 
b/pypy/objspace/std/bytearrayobject.py
--- a/pypy/objspace/std/bytearrayobject.py
+++ b/pypy/objspace/std/bytearrayobject.py
@@ -397,14 +397,6 @@
 w_str = str__Bytearray(space, w_bytearray)
 return stringobject.str_isspace__String(space, w_str)
 
-def bytearray_insert__Bytearray_Int_ANY(space, w_bytearray, w_idx, w_other):
-where = space.int_w(w_idx)
-length = len(w_bytearray.data)
-index = get_positive_index(where, length)
-val = getbytevalue(space, w_other)
-w_bytearray.data.insert(index, val)
-return space.w_None
-
 def bytearray_pop__Bytearray_Int(space, w_bytearray, w_idx):
 index = space.int_w(w_idx)
 try:
diff --git a/pypy/objspace/std/bytearraytype.py 
b/pypy/objspace/std/bytearraytype.py
--- a/pypy/objspace/std/bytearraytype.py
+++ b/pypy/objspace/std/bytearraytype.py
@@ -1,8 +1,9 @@
 from pypy.interpreter.baseobjspace import ObjSpace, W_Root
 from pypy.interpreter.error import OperationError
-from pypy.interpreter.gateway import interp2app
+from pypy.interpreter.gateway import interp2app, unwrap_spec
 from pypy.objspace.std.register_all import register_all
 from pypy.objspace.std.stdtypedef import StdTypeDef, SMM
+from pypy.objspace.std.listobject import get_positive_index
 
 from pypy.objspace.std.stringtype import (
 str_decode,
@@ -21,10 +22,21 @@
 
 str_join = SMM('join', 2, defaults=(None,-1))
 
-bytearray_insert  = SMM('insert', 3,
-doc=B.insert(index, int) - None\n\n
-Insert a single item into the bytearray before 
-the given index.)
+
+@unwrap_spec(w_self=W_Root, index=int, val='str_or_int')
+def bytearray_insert(w_self, space, index, val):
+B.insert(index, int) - None
+
+Insert a single item into the bytearray before the given index.
+
+if isinstance(val, int):
+val = chr(val)
+elif len(val) != 1:
+raise OperationError(space.w_ValueError,
+ space.wrap(string must be of size 1))
+w_self.data.insert(index, val)
+return space.w_None
+
 
 bytearray_pop  = SMM('pop', 2, defaults=(-1,),
 doc=B.pop([index]) - int\n\nRemove and return a 
@@ -175,6 +187,7 @@
 __hash__ = None,
 __reduce__ = interp2app(descr_bytearray__reduce__),
 fromhex = interp2app(descr_fromhex, as_classmethod=True),
+insert = interp2app(bytearray_insert),
 **bytearray_interface_methods()
 )
 bytearray_typedef.registermethods(globals())
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy remove-string-smm: Re-implement bytearray.pop.

2013-03-21 Thread hodgestar
Author: Simon Cross hodges...@gmail.com
Branch: remove-string-smm
Changeset: r62623:47ef3c341a14
Date: 2013-03-22 01:53 +0200
http://bitbucket.org/pypy/pypy/changeset/47ef3c341a14/

Log:Re-implement bytearray.pop.

diff --git a/pypy/objspace/std/bytearrayobject.py 
b/pypy/objspace/std/bytearrayobject.py
--- a/pypy/objspace/std/bytearrayobject.py
+++ b/pypy/objspace/std/bytearrayobject.py
@@ -397,18 +397,6 @@
 w_str = str__Bytearray(space, w_bytearray)
 return stringobject.str_isspace__String(space, w_str)
 
-def bytearray_pop__Bytearray_Int(space, w_bytearray, w_idx):
-index = space.int_w(w_idx)
-try:
-result = w_bytearray.data.pop(index)
-except IndexError:
-if not w_bytearray.data:
-raise OperationError(space.w_IndexError, space.wrap(
-pop from empty bytearray))
-raise OperationError(space.w_IndexError, space.wrap(
-pop index out of range))
-return space.wrap(ord(result))
-
 def bytearray_remove__Bytearray_ANY(space, w_bytearray, w_char):
 char = space.int_w(space.index(w_char))
 try:
diff --git a/pypy/objspace/std/bytearraytype.py 
b/pypy/objspace/std/bytearraytype.py
--- a/pypy/objspace/std/bytearraytype.py
+++ b/pypy/objspace/std/bytearraytype.py
@@ -38,10 +38,23 @@
 return space.w_None
 
 
-bytearray_pop  = SMM('pop', 2, defaults=(-1,),
-doc=B.pop([index]) - int\n\nRemove and return a 
-single item from B. If no index\nargument is given, 
-will pop the last value.)
+@unwrap_spec(w_self=W_Root, index=int)
+def bytearray_pop(w_self, space, index=-1):
+B.pop([index]) - int
+
+Remove and return a single item from B. If no index
+argument is given, will pop the last value.
+
+try:
+result = w_self.data.pop(index)
+except IndexError:
+if not w_self.data:
+raise OperationError(space.w_IndexError, space.wrap(
+pop from empty bytearray))
+raise OperationError(space.w_IndexError, space.wrap(
+pop index out of range))
+return space.wrap(ord(result))
+
 
 bytearray_remove  = SMM('remove', 2,
 doc=B.remove(int) - None\n\n
@@ -188,6 +201,7 @@
 __reduce__ = interp2app(descr_bytearray__reduce__),
 fromhex = interp2app(descr_fromhex, as_classmethod=True),
 insert = interp2app(bytearray_insert),
+pop = interp2app(bytearray_pop),
 **bytearray_interface_methods()
 )
 bytearray_typedef.registermethods(globals())
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy remove-list-smm: (arigo, fijal) fix the descr test

2013-03-21 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: remove-list-smm
Changeset: r62624:b1beccb7c94f
Date: 2013-03-21 16:55 -0700
http://bitbucket.org/pypy/pypy/changeset/b1beccb7c94f/

Log:(arigo, fijal) fix the descr test

diff --git a/pypy/interpreter/function.py b/pypy/interpreter/function.py
--- a/pypy/interpreter/function.py
+++ b/pypy/interpreter/function.py
@@ -57,11 +57,15 @@
 
 def call_args(self, args):
 # delegate activation to code
-return self.getcode().funcrun(self, args)
+w_res = self.getcode().funcrun(self, args)
+assert isinstance(w_res, W_Root)
+return w_res
 
 def call_obj_args(self, w_obj, args):
 # delegate activation to code
-return self.getcode().funcrun_obj(self, w_obj, args)
+w_res = self.getcode().funcrun_obj(self, w_obj, args)
+assert isinstance(w_res, W_Root)
+return w_res
 
 def getcode(self):
 if jit.we_are_jitted():
diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py
--- a/pypy/interpreter/gateway.py
+++ b/pypy/interpreter/gateway.py
@@ -212,7 +212,11 @@
 self.run_args.append('space')
 
 def visit__W_Root(self, el):
-self.run_args.append(self.scopenext())
+if el is not W_Root:
+self.run_args.append(space.interp_w(%s, %s) % (self.use(el),
+ self.scopenext()))
+else:
+self.run_args.append(self.scopenext())
 
 def visit__Arguments(self, el):
 self.miniglobals['Arguments'] = Arguments
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
@@ -146,8 +146,6 @@
 # annotation (see pypy/annotation/builtin.py)
 if x is None:
 return self.w_None
-if isinstance(x, model.W_Object):
-raise TypeError, attempt to wrap already wrapped object: %s%(x,)
 if isinstance(x, OperationError):
 raise TypeError, (attempt to wrap already wrapped exception: %s%
   (x,))
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy remove-list-smm: (arigo, fijal) fix the descr test

2013-03-21 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: remove-list-smm
Changeset: r62625:b24c7cb07f42
Date: 2013-03-21 16:58 -0700
http://bitbucket.org/pypy/pypy/changeset/b24c7cb07f42/

Log:(arigo, fijal) fix the descr test

diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py
--- a/pypy/interpreter/gateway.py
+++ b/pypy/interpreter/gateway.py
@@ -153,11 +153,9 @@
 def visit__W_Root(self, el, app_sig):
 argname = self.orig_arg()
 if argname == 'self':
-# for W_ListObject and similar to be possible to have
-# unwrap_spec in methods
+assert el is not W_Root
 app_sig.append(argname)
 return
-assert el is W_Root, %s is not W_Root (forgotten to put .im_func in 
interp2app argument?) % (el,)
 assert argname.startswith('w_'), (
 argument %s of built-in function %r should 
 start with 'w_' % (argname, self.func))
@@ -351,7 +349,11 @@
 self.unwrap.append(space)
 
 def visit__W_Root(self, el):
-self.unwrap.append(self.nextarg())
+if el is not W_Root:
+self.unwrap.append(space.interp_w(%s, %s) % (self.use(el),
+   self.nextarg()))
+else:
+self.unwrap.append(self.nextarg())
 
 def visit__Arguments(self, el):
 raise FastFuncNotSupported
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy remove-list-smm: (arigo, fijal) fix naming

2013-03-21 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: remove-list-smm
Changeset: r62626:ad506216bd78
Date: 2013-03-21 17:00 -0700
http://bitbucket.org/pypy/pypy/changeset/ad506216bd78/

Log:(arigo, fijal) fix naming

diff --git a/pypy/module/_file/interp_file.py b/pypy/module/_file/interp_file.py
--- a/pypy/module/_file/interp_file.py
+++ b/pypy/module/_file/interp_file.py
@@ -591,7 +591,7 @@
 return False
 
 
-@unwrap_spec(file=W_File, encoding=str_or_None, errors=str_or_None)
-def set_file_encoding(space, file, encoding=None, errors=None):
-file.encoding = encoding
-file.errors = errors
+@unwrap_spec(w_file=W_File, encoding=str_or_None, errors=str_or_None)
+def set_file_encoding(space, w_file, encoding=None, errors=None):
+w_file.encoding = encoding
+w_file.errors = errors
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy remove-string-smm: Re-implement bytearray.remove.

2013-03-21 Thread hodgestar
Author: Simon Cross hodges...@gmail.com
Branch: remove-string-smm
Changeset: r62627:67ef049cda7e
Date: 2013-03-22 02:08 +0200
http://bitbucket.org/pypy/pypy/changeset/67ef049cda7e/

Log:Re-implement bytearray.remove.

diff --git a/pypy/objspace/std/bytearrayobject.py 
b/pypy/objspace/std/bytearrayobject.py
--- a/pypy/objspace/std/bytearrayobject.py
+++ b/pypy/objspace/std/bytearrayobject.py
@@ -397,14 +397,6 @@
 w_str = str__Bytearray(space, w_bytearray)
 return stringobject.str_isspace__String(space, w_str)
 
-def bytearray_remove__Bytearray_ANY(space, w_bytearray, w_char):
-char = space.int_w(space.index(w_char))
-try:
-result = w_bytearray.data.remove(chr(char))
-except ValueError:
-raise OperationError(space.w_ValueError, space.wrap(
-value not found in bytearray))
-
 def bytearray_reverse__Bytearray(space, w_bytearray):
 w_bytearray.data.reverse()
 return space.w_None
diff --git a/pypy/objspace/std/bytearraytype.py 
b/pypy/objspace/std/bytearraytype.py
--- a/pypy/objspace/std/bytearraytype.py
+++ b/pypy/objspace/std/bytearraytype.py
@@ -56,9 +56,19 @@
 return space.wrap(ord(result))
 
 
-bytearray_remove  = SMM('remove', 2,
-doc=B.remove(int) - None\n\n
-Remove the first occurance of a value in B.)
+@unwrap_spec(w_self=W_Root)
+def bytearray_remove(w_self, space, w_index):
+B.remove(int) - None
+
+Remove the first occurance of a value in B.
+
+val = space.int_w(space.index(w_index))
+try:
+w_self.data.remove(chr(val))
+except ValueError:
+raise OperationError(space.w_ValueError, space.wrap(
+value not found in bytearray))
+
 
 bytearray_reverse  = SMM('reverse', 1,
 doc=B.reverse() - None\n\n
@@ -200,8 +210,9 @@
 __hash__ = None,
 __reduce__ = interp2app(descr_bytearray__reduce__),
 fromhex = interp2app(descr_fromhex, as_classmethod=True),
-insert = interp2app(bytearray_insert),
-pop = interp2app(bytearray_pop),
+insert=interp2app(bytearray_insert),
+pop=interp2app(bytearray_pop),
+remove=interp2app(bytearray_remove),
 **bytearray_interface_methods()
 )
 bytearray_typedef.registermethods(globals())
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy remove-string-smm: Use index unwrap_spec type for index in bytearray.remove.

2013-03-21 Thread hodgestar
Author: Simon Cross hodges...@gmail.com
Branch: remove-string-smm
Changeset: r62628:e1b6bf1f9b9b
Date: 2013-03-22 02:17 +0200
http://bitbucket.org/pypy/pypy/changeset/e1b6bf1f9b9b/

Log:Use index unwrap_spec type for index in bytearray.remove.

diff --git a/pypy/objspace/std/bytearraytype.py 
b/pypy/objspace/std/bytearraytype.py
--- a/pypy/objspace/std/bytearraytype.py
+++ b/pypy/objspace/std/bytearraytype.py
@@ -56,15 +56,14 @@
 return space.wrap(ord(result))
 
 
-@unwrap_spec(w_self=W_Root)
-def bytearray_remove(w_self, space, w_index):
+@unwrap_spec(w_self=W_Root, value='index')
+def bytearray_remove(w_self, space, value):
 B.remove(int) - None
 
 Remove the first occurance of a value in B.
 
-val = space.int_w(space.index(w_index))
 try:
-w_self.data.remove(chr(val))
+w_self.data.remove(chr(value))
 except ValueError:
 raise OperationError(space.w_ValueError, space.wrap(
 value not found in bytearray))
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy remove-list-smm: fix fix fix

2013-03-21 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: remove-list-smm
Changeset: r62629:9aebaf686e8e
Date: 2013-03-21 17:18 -0700
http://bitbucket.org/pypy/pypy/changeset/9aebaf686e8e/

Log:fix fix fix

diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py
--- a/pypy/interpreter/gateway.py
+++ b/pypy/interpreter/gateway.py
@@ -116,8 +116,8 @@
 def checked_space_method(self, typname, app_sig):
 argname = self.orig_arg()
 assert not argname.startswith('w_'), (
-unwrapped %s argument %s of built-in function %r should 
-not start with 'w_' % (typname, argname, self.func))
+unwrapped %s argument %s of built-in function %r in %r should 
+not start with 'w_' % (typname, argname, self.func.func_name, 
self.func.func_globals['__name__']))
 app_sig.append(argname)
 
 def visit_index(self, index, app_sig):
@@ -157,8 +157,8 @@
 app_sig.append(argname)
 return
 assert argname.startswith('w_'), (
-argument %s of built-in function %r should 
-start with 'w_' % (argname, self.func))
+argument %s of built-in function %r in %r should 
+start with 'w_' % (argname, self.func.func_name, 
self.func.func_globals['__name__']))
 app_sig.append(argname[2:])
 
 def visit__Arguments(self, el, app_sig):
diff --git a/pypy/module/_cffi_backend/cbuffer.py 
b/pypy/module/_cffi_backend/cbuffer.py
--- a/pypy/module/_cffi_backend/cbuffer.py
+++ b/pypy/module/_cffi_backend/cbuffer.py
@@ -72,15 +72,15 @@
 MiniBuffer.typedef.acceptable_as_base_class = False
 
 
-@unwrap_spec(cdata=cdataobj.W_CData, size=int)
-def buffer(space, cdata, size=-1):
-ctype = cdata.ctype
+@unwrap_spec(w_cdata=cdataobj.W_CData, size=int)
+def buffer(space, w_cdata, size=-1):
+ctype = w_cdata.ctype
 if isinstance(ctype, ctypeptr.W_CTypePointer):
 if size  0:
 size = ctype.ctitem.size
 elif isinstance(ctype, ctypearray.W_CTypeArray):
 if size  0:
-size = cdata._sizeof()
+size = w_cdata._sizeof()
 else:
 raise operationerrfmt(space.w_TypeError,
   expected a pointer or array cdata, got '%s',
@@ -89,4 +89,4 @@
 raise operationerrfmt(space.w_TypeError,
   don't know the size pointed to by '%s',
   ctype.name)
-return space.wrap(MiniBuffer(LLBuffer(cdata._cdata, size), cdata))
+return space.wrap(MiniBuffer(LLBuffer(w_cdata._cdata, size), w_cdata))
diff --git a/pypy/module/_cffi_backend/func.py 
b/pypy/module/_cffi_backend/func.py
--- a/pypy/module/_cffi_backend/func.py
+++ b/pypy/module/_cffi_backend/func.py
@@ -5,28 +5,28 @@
 
 # 
 
-@unwrap_spec(ctype=ctypeobj.W_CType, w_init=WrappedDefault(None))
-def newp(space, ctype, w_init):
-return ctype.newp(w_init)
+@unwrap_spec(w_ctype=ctypeobj.W_CType, w_init=WrappedDefault(None))
+def newp(space, w_ctype, w_init):
+return w_ctype.newp(w_init)
 
 # 
 
-@unwrap_spec(ctype=ctypeobj.W_CType)
-def cast(space, ctype, w_ob):
-return ctype.cast(w_ob)
+@unwrap_spec(w_ctype=ctypeobj.W_CType)
+def cast(space, w_ctype, w_ob):
+return w_ctype.cast(w_ob)
 
 # 
 
-@unwrap_spec(ctype=ctypeobj.W_CType)
-def callback(space, ctype, w_callable, w_error=None):
+@unwrap_spec(w_ctype=ctypeobj.W_CType)
+def callback(space, w_ctype, w_callable, w_error=None):
 from pypy.module._cffi_backend.ccallback import W_CDataCallback
-return W_CDataCallback(space, ctype, w_callable, w_error)
+return W_CDataCallback(space, w_ctype, w_callable, w_error)
 
 # 
 
-@unwrap_spec(cdata=cdataobj.W_CData)
-def typeof(space, cdata):
-return cdata.ctype
+@unwrap_spec(w_cdata=cdataobj.W_CData)
+def typeof(space, w_cdata):
+return w_cdata.ctype
 
 # 
 
@@ -44,33 +44,33 @@
 space.wrap(expected a 'cdata' or 'ctype' object))
 return space.wrap(size)
 
-@unwrap_spec(ctype=ctypeobj.W_CType)
-def alignof(space, ctype):
-align = ctype.alignof()
+@unwrap_spec(w_ctype=ctypeobj.W_CType)
+def alignof(space, w_ctype):
+align = w_ctype.alignof()
 return space.wrap(align)
 
-@unwrap_spec(ctype=ctypeobj.W_CType, fieldname=str_or_None)
-def typeoffsetof(space, ctype, fieldname):
-ctype, offset = ctype.typeoffsetof(fieldname)
+@unwrap_spec(w_ctype=ctypeobj.W_CType, fieldname=str_or_None)
+def typeoffsetof(space, w_ctype, fieldname):
+ctype, offset = w_ctype.typeoffsetof(fieldname)
 return space.newtuple([space.wrap(ctype), space.wrap(offset)])
 
-@unwrap_spec(ctype=ctypeobj.W_CType, cdata=cdataobj.W_CData, offset=int)
-def rawaddressof(space, 

[pypy-commit] pypy remove-string-smm: Remove bogus w_self=W_Root in bytearraytype unwrap_specs.

2013-03-21 Thread hodgestar
Author: Simon Cross hodges...@gmail.com
Branch: remove-string-smm
Changeset: r62630:632f4fdd4857
Date: 2013-03-22 02:19 +0200
http://bitbucket.org/pypy/pypy/changeset/632f4fdd4857/

Log:Remove bogus w_self=W_Root in bytearraytype unwrap_specs.

diff --git a/pypy/objspace/std/bytearraytype.py 
b/pypy/objspace/std/bytearraytype.py
--- a/pypy/objspace/std/bytearraytype.py
+++ b/pypy/objspace/std/bytearraytype.py
@@ -23,7 +23,7 @@
 str_join = SMM('join', 2, defaults=(None,-1))
 
 
-@unwrap_spec(w_self=W_Root, index=int, val='str_or_int')
+@unwrap_spec(index=int, val='str_or_int')
 def bytearray_insert(w_self, space, index, val):
 B.insert(index, int) - None
 
@@ -38,7 +38,7 @@
 return space.w_None
 
 
-@unwrap_spec(w_self=W_Root, index=int)
+@unwrap_spec(index=int)
 def bytearray_pop(w_self, space, index=-1):
 B.pop([index]) - int
 
@@ -56,7 +56,7 @@
 return space.wrap(ord(result))
 
 
-@unwrap_spec(w_self=W_Root, value='index')
+@unwrap_spec(value='index')
 def bytearray_remove(w_self, space, value):
 B.remove(int) - None
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy remove-list-smm: (arigo, fijal) fix fix fix

2013-03-21 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: remove-list-smm
Changeset: r62631:a8616e7bc663
Date: 2013-03-21 17:53 -0700
http://bitbucket.org/pypy/pypy/changeset/a8616e7bc663/

Log:(arigo, fijal) fix fix fix

diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py
--- a/pypy/interpreter/gateway.py
+++ b/pypy/interpreter/gateway.py
@@ -466,6 +466,7 @@
 def __init__(self, default_value):
 self.default_value = default_value
 
+
 def build_unwrap_spec(func, argnames, self_type=None):
 build the list of parameter unwrap spec for the function.
 
diff --git a/pypy/module/parser/__init__.py b/pypy/module/parser/__init__.py
--- a/pypy/module/parser/__init__.py
+++ b/pypy/module/parser/__init__.py
@@ -17,12 +17,12 @@
  'expr' : 'pyparser.expr',
  'issuite'  : 'pyparser.issuite',
  'isexpr'   : 'pyparser.isexpr',
- 'STType'   : 'pyparser.STType',
+ 'STType'   : 'pyparser.W_STType',
  'ast2tuple': 'pyparser.st2tuple',
  'st2tuple' : 'pyparser.st2tuple',
  'ast2list' : 'pyparser.st2list',
  'ast2tuple': 'pyparser.st2tuple',
- 'ASTType'  : 'pyparser.STType',
+ 'ASTType'  : 'pyparser.W_STType',
  'compilest': 'pyparser.compilest',
  'compileast'   : 'pyparser.compilest',
  'ParserError'  : 'space.new_exception_class(parser.ParserError)',
diff --git a/pypy/module/parser/pyparser.py b/pypy/module/parser/pyparser.py
--- a/pypy/module/parser/pyparser.py
+++ b/pypy/module/parser/pyparser.py
@@ -8,7 +8,7 @@
 from rpython.rlib.objectmodel import specialize
 
 
-class STType(W_Root):
+class W_STType(W_Root):
 def __init__(self, tree, mode):
 self.tree = tree
 self.mode = mode
@@ -62,12 +62,12 @@
  e.wrap_info(space))
 return space.wrap(result)
 
-STType.typedef = TypeDef(parser.st,
-issuite=interp2app(STType.descr_issuite),
-isexpr=interp2app(STType.descr_isexpr),
-totuple=interp2app(STType.descr_totuple),
-tolist=interp2app(STType.descr_tolist),
-compile=interp2app(STType.descr_compile)
+W_STType.typedef = TypeDef(parser.st,
+issuite=interp2app(W_STType.descr_issuite),
+isexpr=interp2app(W_STType.descr_isexpr),
+totuple=interp2app(W_STType.descr_totuple),
+tolist=interp2app(W_STType.descr_tolist),
+compile=interp2app(W_STType.descr_compile)
 )
 
 
@@ -82,7 +82,7 @@
 except error.SyntaxError, e:
 raise OperationError(space.w_SyntaxError,
  e.wrap_info(space))
-return space.wrap(STType(tree, mode))
+return space.wrap(W_STType(tree, mode))
 
 
 @unwrap_spec(source=str)
@@ -95,22 +95,22 @@
 return parse_python(space, source, 'eval')
 
 
-@unwrap_spec(st=STType)
-def isexpr(space, st):
-return space.call_method(st, isexpr)
+@unwrap_spec(w_st=W_STType)
+def isexpr(space, w_st):
+return w_st.descr_isexpr(space)
 
-@unwrap_spec(st=STType)
-def issuite(space, st):
-return space.call_method(st, issuite)
+@unwrap_spec(w_st=W_STType)
+def issuite(space, w_st):
+return w_st.descr_issuite(space)
 
-@unwrap_spec(st=STType)
-def st2tuple(space, st, __args__):
-return space.call_args(space.getattr(st, space.wrap(totuple)), __args__)
+@unwrap_spec(w_st=W_STType)
+def st2tuple(space, w_st, __args__):
+return space.call_args(space.getattr(w_st, space.wrap(totuple)), 
__args__)
 
-@unwrap_spec(st=STType)
-def st2list(space, st, __args__):
-return space.call_args(space.getattr(st, space.wrap(tolist)), __args__)
+@unwrap_spec(w_st=W_STType)
+def st2list(space, w_st, __args__):
+return space.call_args(space.getattr(w_st, space.wrap(tolist)), __args__)
 
-@unwrap_spec(st=STType)
-def compilest(space, st, __args__):
-return space.call_args(space.getattr(st, space.wrap(compile)), __args__)
+@unwrap_spec(w_st=W_STType)
+def compilest(space, w_st, __args__):
+return space.call_args(space.getattr(w_st, space.wrap(compile)), 
__args__)
diff --git a/pypy/module/pypyjit/interp_resop.py 
b/pypy/module/pypyjit/interp_resop.py
--- a/pypy/module/pypyjit/interp_resop.py
+++ b/pypy/module/pypyjit/interp_resop.py
@@ -134,15 +134,18 @@
 getint = interp2app(WrappedBox.descr_getint),
 )
 
-@unwrap_spec(num=int, offset=int, repr=str, res=WrappedBox)
-def descr_new_resop(space, w_tp, num, w_args, res, offset=-1,
+@unwrap_spec(num=int, offset=int, repr=str, w_res=W_Root)
+def descr_new_resop(space, w_tp, num, w_args, w_res, offset=-1,
 repr=''):
 args = [space.interp_w(WrappedBox, w_arg).llbox for w_arg in
 space.listview(w_args)]
-if res is None:
+if space.is_none(w_res):
 llres = jit_hooks.emptyval()
 else:
-llres = res.llbox
+if not isinstance(w_res, WrappedBox):
+raise OperationError(space.w_TypeError, space.wrap(
+expected box type, got %s % space.type(w_res)))
+

[pypy-commit] pypy remove-list-smm: (arigo, fijal) Proxies seems to be broken, otherwise fix the rest of errors

2013-03-21 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: remove-list-smm
Changeset: r62632:b71c07d9680f
Date: 2013-03-21 18:13 -0700
http://bitbucket.org/pypy/pypy/changeset/b71c07d9680f/

Log:(arigo, fijal) Proxies seems to be broken, otherwise fix the rest of
errors

diff --git a/lib_pypy/tputil.py b/lib_pypy/tputil.py
--- a/lib_pypy/tputil.py
+++ b/lib_pypy/tputil.py
@@ -1,69 +1,69 @@
 
 
-application level support module for transparent proxies. 
+application level support module for transparent proxies.
 
 
-from __pypy__ import tproxy 
+from __pypy__ import tproxy
 from types import MethodType
 
 _dummy = object()
 origtype = type
 
-def make_proxy(controller, type=_dummy, obj=_dummy): 
- return a tranparent proxy controlled by the given 
-'controller' callable.  The proxy will appear 
-as a completely regular instance of the given 
-type but all operations on it are send to the 
-specified controller - which receives on 
-ProxyOperation instance on each such call.  
-A non-specified type will default to type(obj) 
-if obj is specified. 
+def make_proxy(controller, type=_dummy, obj=_dummy):
+ return a tranparent proxy controlled by the given
+'controller' callable.  The proxy will appear
+as a completely regular instance of the given
+type but all operations on it are send to the
+specified controller - which receives on
+ProxyOperation instance on each such call.
+A non-specified type will default to type(obj)
+if obj is specified.
 
-if type is _dummy: 
-if obj is _dummy: 
-raise TypeError(you must specify a type or an instance obj of 
it) 
-type = origtype(obj) 
+if type is _dummy:
+if obj is _dummy:
+raise TypeError(you must specify a type or an instance obj of it)
+type = origtype(obj)
 def perform(opname, *args, **kwargs):
 operation = ProxyOperation(tp, obj, opname, args, kwargs)
-return controller(operation) 
-tp = tproxy(type, perform) 
-return tp 
+return controller(operation)
+tp = tproxy(type, perform)
+return tp
 
 class ProxyOperation(object):
 def __init__(self, proxyobj, obj, opname, args, kwargs):
 self.proxyobj = proxyobj
-self.opname = opname 
+self.opname = opname
 self.args = args
 self.kwargs = kwargs
-if obj is not _dummy: 
-self.obj = obj 
+if obj is not _dummy:
+self.obj = obj
 
 def delegate(self):
- return result from delegating this operation to the 
-underyling self.obj - which must exist and is usually 
-provided through the initial make_proxy(..., obj=...) 
-creation. 
- 
+ return result from delegating this operation to the
+underyling self.obj - which must exist and is usually
+provided through the initial make_proxy(..., obj=...)
+creation.
+
 try:
 obj = getattr(self, 'obj')
-except AttributeError: 
+except AttributeError:
 raise TypeError(proxy does not have an underlying 'obj', 
 cannot delegate)
-objattr = getattr(obj, self.opname) 
-res = objattr(*self.args, **self.kwargs) 
-if self.opname == __getattribute__: 
+objattr = getattr(obj, self.opname)
+res = objattr(*self.args, **self.kwargs)
+if self.opname == __getattribute__:
 if (isinstance(res, MethodType) and
 res.im_self is self.instance):
 res = MethodType(res.im_func, self.proxyobj, res.im_class)
-if res is self.obj: 
+if res is self.obj:
 res = self.proxyobj
-return res 
+return res
 
 def __repr__(self):
 args = , .join([repr(x) for x in self.args])
-args = 0x%x,  % id(self.proxyobj) + args 
+args = 0x%x,  % id(self.proxyobj) + args
 if self.kwargs:
-args += , .join([%s=%r % item 
+args += , .join([%s=%r % item
   for item in self.kwargs.items()])
 return ProxyOperation %s.%s(%s) %(
 type(self.proxyobj).__name__, self.opname, args)
diff --git a/pypy/module/test_lib_pypy/test_tputil.py 
b/pypy/module/test_lib_pypy/test_tputil.py
--- a/pypy/module/test_lib_pypy/test_tputil.py
+++ b/pypy/module/test_lib_pypy/test_tputil.py
@@ -2,55 +2,85 @@
 spaceconfig = {objspace.std.withtproxy: True}
 
 def test_errors(self):
-from tputil import make_proxy 
+from tputil import make_proxy
 raises(TypeError, make_proxy(None))
 raises(TypeError, make_proxy(None, None))
-def f(): pass 
+def f(): pass
 raises(TypeError, make_proxy(f))
 raises(TypeError, make_proxy(f, None, None))
 
 def test_repr(self):

[pypy-commit] pypy remove-list-smm: fix translation

2013-03-21 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: remove-list-smm
Changeset: r62633:96b7c2746125
Date: 2013-03-21 18:28 -0700
http://bitbucket.org/pypy/pypy/changeset/96b7c2746125/

Log:fix translation

diff --git a/pypy/objspace/std/proxyobject.py b/pypy/objspace/std/proxyobject.py
--- a/pypy/objspace/std/proxyobject.py
+++ b/pypy/objspace/std/proxyobject.py
@@ -72,10 +72,10 @@
 return W_Transparent
 
 W_Transparent = transparent_class('W_Transparent', baseobjspace.W_Root)
-W_TransparentObject = transparent_class('W_TransparentObject', W_Object)
+#W_TransparentObject = transparent_class('W_TransparentObject', W_Object)
 
-from pypy.objspace.std.objecttype import object_typedef
-W_TransparentObject.typedef = object_typedef
+#from pypy.objspace.std.objecttype import object_typedef
+#W_TransparentObject.typedef = object_typedef
 
 from pypy.interpreter.typedef import Function, GeneratorIterator, PyTraceback, 
\
 PyFrame, PyCode
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: (alex, fijal): remove some random nonsense

2013-03-21 Thread alex_gaynor
Author: Alex Gaynor alex.gay...@gmail.com
Branch: 
Changeset: r62634:ecebd2bc6598
Date: 2013-03-21 21:34 -0700
http://bitbucket.org/pypy/pypy/changeset/ecebd2bc6598/

Log:(alex, fijal): remove some random nonsense

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1,27 +1,30 @@
 import sys
 
+from rpython.rlib.cache import Cache
+from rpython.tool.uid import HUGEVAL_BYTES
+from rpython.rlib import jit, types
+from rpython.rlib.debug import make_sure_not_resized
+from rpython.rlib.objectmodel import (we_are_translated, newlist_hint,
+ compute_unique_id)
+from rpython.rlib.signature import signature
+from rpython.rlib.rarithmetic import r_uint
+
 from pypy.interpreter.executioncontext import (ExecutionContext, ActionFlag,
 UserDelAction, FrameTraceAction)
 from pypy.interpreter.error import (OperationError, operationerrfmt,
 new_exception_class, typed_unwrap_error_msg)
 from pypy.interpreter.argument import Arguments
 from pypy.interpreter.miscutils import ThreadLocals
-from rpython.rlib.cache import Cache
-from rpython.tool.uid import HUGEVAL_BYTES
-from rpython.rlib import jit
-from rpython.rlib.debug import make_sure_not_resized
-from rpython.rlib.objectmodel import we_are_translated, newlist_hint,\
- compute_unique_id
-from rpython.rlib.rarithmetic import r_uint
 
 
 __all__ = ['ObjSpace', 'OperationError', 'Wrappable', 'W_Root']
 
 UINT_MAX_32_BITS = r_uint(4294967295)
 
-unpackiterable_driver = jit.JitDriver(name = 'unpackiterable',
-  greens = ['tp'],
-  reds = ['items', 'w_iterator'])
+unpackiterable_driver = jit.JitDriver(name='unpackiterable',
+  greens=['tp'],
+  reds=['items', 'w_iterator'])
+
 
 class W_Root(object):
 This is the abstract root class of all wrapped objects that live
@@ -698,6 +701,7 @@
 raise
 return None
 
+@signature(types.bool(), returns=types.instance(W_Root))
 def newbool(self, b):
 if b:
 return self.w_True
diff --git a/pypy/tool/ann_override.py b/pypy/tool/ann_override.py
--- a/pypy/tool/ann_override.py
+++ b/pypy/tool/ann_override.py
@@ -1,22 +1,17 @@
 # overrides for annotation specific to PyPy codebase
-from rpython.annotator.policy import AnnotatorPolicy, Sig
+from rpython.annotator.policy import AnnotatorPolicy
 # for some reason, model must be imported first,
 # or we create a cycle.
 from rpython.flowspace.model import Constant
-from rpython.annotator import model as annmodel
-from rpython.annotator.bookkeeper import getbookkeeper
 from rpython.annotator import specialize
-from pypy.interpreter import baseobjspace
+
 
 def isidentifier(s):
-if not s: return False
+if not s:
+return False
 s = s.replace('_', 'x')
 return s[0].isalpha() and s.isalnum()
 
-# patch - mostly for debugging, to enforce some signatures
-baseobjspace.ObjSpace.newbool.im_func._annenforceargs_ = Sig(lambda s1,s2: s1,
- bool)
-
 
 class PyPyAnnotatorPolicy(AnnotatorPolicy):
 def __init__(pol, single_space=None):
@@ -60,8 +55,8 @@
 # for jit benefit
 if cached not in t._immutable_fields_: # accessed this way just
# for convenience
-t._immutable_fields_.append(cached)
-
+t._immutable_fields_.append(cached)
+
 def attach_lookup(pol, t, attr):
 cached = cached_%s % attr
 if not t.is_heaptype() and not t.is_cpytype():
diff --git a/rpython/rlib/signature.py b/rpython/rlib/signature.py
--- a/rpython/rlib/signature.py
+++ b/rpython/rlib/signature.py
@@ -1,5 +1,6 @@
 from rpython.rlib import types
 
+
 def signature(*paramtypes, **kwargs):
 Decorate a function to specify its type signature.
 
@@ -12,7 +13,7 @@
 
 returntype = kwargs.pop('returns', None)
 if returntype is None:
-raise TypeError, signature: parameter 'returns' required
+raise TypeError(signature: parameter 'returns' required)
 
 def decorator(f):
 f._signature_ = (paramtypes, returntype)
diff --git a/rpython/rlib/types.py b/rpython/rlib/types.py
--- a/rpython/rlib/types.py
+++ b/rpython/rlib/types.py
@@ -10,9 +10,11 @@
 def float():
 return model.SomeFloat()
 
+
 def singlefloat():
 return model.SomeSingleFloat()
 
+
 def longfloat():
 return model.SomeLongFloat()
 
@@ -21,18 +23,26 @@
 return model.SomeInteger()
 
 
+def bool():
+return model.SomeBool()
+
+
 def unicode():
 return model.SomeUnicodeString()
 
+
 def unicode0():
 return model.SomeUnicodeString(no_nul=True)
 
+
 def str():
 return model.SomeString()
 
+
 def str0():
 return model.SomeString(no_nul=True)
 
+
 def char():
 return model.SomeChar()
 
@@ -46,21 

[pypy-commit] pypy default: Replace annenforce args with signature() in rsandbox

2013-03-21 Thread alex_gaynor
Author: Alex Gaynor alex.gay...@gmail.com
Branch: 
Changeset: r62635:0b27e32c2000
Date: 2013-03-21 21:40 -0700
http://bitbucket.org/pypy/pypy/changeset/0b27e32c2000/

Log:Replace annenforce args with signature() in rsandbox

diff --git a/rpython/translator/sandbox/rsandbox.py 
b/rpython/translator/sandbox/rsandbox.py
--- a/rpython/translator/sandbox/rsandbox.py
+++ b/rpython/translator/sandbox/rsandbox.py
@@ -3,7 +3,10 @@
 trampolines that marshal their input arguments, dump them to STDOUT,
 and wait for an answer on STDIN.  Enable with 'translate.py --sandbox'.
 
-from rpython.rlib import rmarshal
+import py
+
+from rpython.rlib import rmarshal, types
+from rpython.rlib.signature import signature
 
 # 
 #
@@ -12,12 +15,10 @@
 
 from rpython.rtyper.lltypesystem import lltype, rffi
 from rpython.annotator import model as annmodel
-from rpython.rlib.unroll import unrolling_iterable
-from rpython.rlib.objectmodel import CDefinedIntSymbolic
 from rpython.tool.sourcetools import func_with_new_name
 from rpython.rtyper.annlowlevel import MixLevelHelperAnnotator
 from rpython.tool.ansi_print import ansi_log
-import py
+
 log = py.log.Producer(sandbox)
 py.log.setconsumer(sandbox, ansi_log)
 
@@ -27,13 +28,15 @@
 ll_read_not_sandboxed = rffi.llexternal('read',
 [rffi.INT, rffi.CCHARP, rffi.SIZE_T],
 rffi.SIZE_T,
-sandboxsafe = True)
+sandboxsafe=True)
 
 ll_write_not_sandboxed = rffi.llexternal('write',
  [rffi.INT, rffi.CCHARP, rffi.SIZE_T],
  rffi.SIZE_T,
- sandboxsafe = True)
+ sandboxsafe=True)
 
+
+@signature(types.int(), types.ptr(rffi.CCHARP.TO), types.int(), 
returns=types.none())
 def writeall_not_sandboxed(fd, buf, length):
 while length  0:
 size = rffi.cast(rffi.SIZE_T, length)
@@ -43,22 +46,6 @@
 length -= count
 buf = lltype.direct_ptradd(lltype.direct_arrayitems(buf), count)
 buf = rffi.cast(rffi.CCHARP, buf)
-writeall_not_sandboxed._annenforceargs_ = [int, rffi.CCHARP, int]
-
-##def readall_not_sandboxed(fd, length):
-##buf = lltype.malloc(rffi.CCHARP.TO, length, flavor='raw')
-##p = buf
-##got = 0
-##while got  length:
-##size1 = rffi.cast(rffi.SIZE_T, length - got)
-##count = rffi.cast(lltype.Signed, ll_read_not_sandboxed(fd, p, size1))
-##if count = 0:
-##raise IOError
-##got += count
-##p = lltype.direct_ptradd(lltype.direct_arrayitems(p), count)
-##p = rffi.cast(rffi.CCHARP, p)
-##return buf
-##readall_not_sandboxed._annenforceargs_ = [int, int]
 
 
 class FdLoader(rmarshal.Loader):
@@ -112,13 +99,14 @@
 elif error == 8: raise IndexError
 else:raise RuntimeError
 
+
+@signature(types.str(), returns=types.none())
 def not_implemented_stub(msg):
 STDERR = 2
 buf = rffi.str2charp(msg + '\n')
 writeall_not_sandboxed(STDERR, buf, len(msg) + 1)
 rffi.free_charp(buf)
 raise RuntimeError(msg)  # XXX in RPython, the msg is ignored at the moment
-not_implemented_stub._annenforceargs_ = [str]
 
 dump_string = rmarshal.get_marshaller(str)
 load_int= rmarshal.get_loader(int)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy extregistry-refactor: close to be merged branch

2013-03-21 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: extregistry-refactor
Changeset: r62636:f208efb03da6
Date: 2013-03-21 21:49 -0700
http://bitbucket.org/pypy/pypy/changeset/f208efb03da6/

Log:close to be merged branch

___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: (ronan) remove happy nonsense that meaning was abandonded eons ago

2013-03-21 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: 
Changeset: r62637:92a9a93262ed
Date: 2013-03-21 21:49 -0700
http://bitbucket.org/pypy/pypy/changeset/92a9a93262ed/

Log:(ronan) remove happy nonsense that meaning was abandonded eons ago

diff --git a/rpython/annotator/binaryop.py b/rpython/annotator/binaryop.py
--- a/rpython/annotator/binaryop.py
+++ b/rpython/annotator/binaryop.py
@@ -11,14 +11,13 @@
 from rpython.annotator.model import SomeTuple, SomeImpossibleValue, 
s_ImpossibleValue
 from rpython.annotator.model import SomeInstance, SomeBuiltin, SomeIterator
 from rpython.annotator.model import SomePBC, SomeFloat, s_None, SomeByteArray
-from rpython.annotator.model import SomeExternalObject, SomeWeakRef
+from rpython.annotator.model import SomeWeakRef
 from rpython.annotator.model import SomeAddress, SomeTypedAddressAccess
 from rpython.annotator.model import SomeSingleFloat, SomeLongFloat, SomeType
 from rpython.annotator.model import unionof, UnionError, missing_operation
 from rpython.annotator.model import TLS
 from rpython.annotator.model import read_can_only_throw
 from rpython.annotator.model import add_knowntypedata, merge_knowntypedata
-from rpython.annotator.model import SomeGenericCallable
 from rpython.annotator.bookkeeper import getbookkeeper
 from rpython.flowspace.model import Variable, Constant
 from rpython.rlib import rarithmetic
@@ -131,7 +130,7 @@
 def is_((obj1, obj2)):
 r = SomeBool()
 if obj2.is_constant():
-if obj1.is_constant(): 
+if obj1.is_constant():
 r.const = obj1.const is obj2.const
 if obj2.const is None and not obj1.can_be_none():
 r.const = False
@@ -149,7 +148,7 @@
 
 def bind(src_obj, tgt_obj, tgt_arg):
 if hasattr(tgt_obj, 'is_type_of') and src_obj.is_constant():
-add_knowntypedata(knowntypedata, True, tgt_obj.is_type_of, 
+add_knowntypedata(knowntypedata, True, tgt_obj.is_type_of,
   bk.valueoftype(src_obj.const))
 
 assert annotator.binding(op.args[tgt_arg]) == tgt_obj
@@ -175,7 +174,7 @@
 getbookkeeper().count(coerce, obj1, obj2)
 return pair(obj1, obj2).union()   # reasonable enough
 
-# approximation of an annotation intersection, the result should be the 
annotation obj or 
+# approximation of an annotation intersection, the result should be the 
annotation obj or
 # the intersection of obj and improvement
 def improve((obj, improvement)):
 if not improvement.contains(obj) and obj.contains(improvement):
@@ -322,7 +321,7 @@
 return int0.knowntype
 if int1.nonneg and isinstance(op.args[1], Variable):
 case = opname in ('lt', 'le', 'eq')
-
+
 add_knowntypedata(knowntypedata, case, [op.args[1]],
   SomeInteger(nonneg=True, 
knowntype=tointtype(int2)))
 if int2.nonneg and isinstance(op.args[0], Variable):
@@ -333,7 +332,7 @@
 # a special case for 'x  0' or 'x = 0',
 # where 0 is a flow graph Constant
 # (in this case we are sure that it cannot become a r_uint later)
-if (isinstance(op.args[1], Constant) and 
+if (isinstance(op.args[1], Constant) and
 type(op.args[1].value) is int and# filter out Symbolics
 op.args[1].value == 0):
 if int1.nonneg:
@@ -354,14 +353,14 @@
 class __extend__(pairtype(SomeBool, SomeBool)):
 
 def union((boo1, boo2)):
-s = SomeBool() 
-if getattr(boo1, 'const', -1) == getattr(boo2, 'const', -2): 
-s.const = boo1.const 
+s = SomeBool()
+if getattr(boo1, 'const', -1) == getattr(boo2, 'const', -2):
+s.const = boo1.const
 if hasattr(boo1, 'knowntypedata') and \
hasattr(boo2, 'knowntypedata'):
 ktd = merge_knowntypedata(boo1.knowntypedata, boo2.knowntypedata)
 s.set_knowntypedata(ktd)
-return s 
+return s
 
 def and_((boo1, boo2)):
 s = SomeBool()
@@ -386,13 +385,13 @@
 if boo2.const:
 s.const = True
 return s
-
+
 def xor((boo1, boo2)):
 s = SomeBool()
 if boo1.is_constant() and boo2.is_constant():
 s.const = boo1.const ^ boo2.const
 return s
-
+
 class __extend__(pairtype(SomeString, SomeString)):
 
 def union((str1, str2)):
@@ -495,7 +494,7 @@
 return s_string.__class__()
 
 class __extend__(pairtype(SomeFloat, SomeFloat)):
-
+
 def union((flt1, flt2)):
 return SomeFloat()
 
@@ -512,13 +511,13 @@
 
 
 class __extend__(pairtype(SomeSingleFloat, SomeSingleFloat)):
-
+
 def union((flt1, flt2)):
 return SomeSingleFloat()
 
 
 class __extend__(pairtype(SomeLongFloat, SomeLongFloat)):
-
+
 def union((flt1, flt2)):
 return SomeLongFloat()
 
@@ 

[pypy-commit] pypy default: (alex, fijal) removed usage of annenforceargs from ootype.py

2013-03-21 Thread alex_gaynor
Author: Alex Gaynor alex.gay...@gmail.com
Branch: 
Changeset: r62640:f04b6c364ed0
Date: 2013-03-21 22:09 -0700
http://bitbucket.org/pypy/pypy/changeset/f04b6c364ed0/

Log:(alex, fijal) removed usage of annenforceargs from ootype.py

diff --git a/rpython/rtyper/ootypesystem/ootype.py 
b/rpython/rtyper/ootypesystem/ootype.py
--- a/rpython/rtyper/ootypesystem/ootype.py
+++ b/rpython/rtyper/ootypesystem/ootype.py
@@ -1,12 +1,12 @@
 import py
-from py.builtin import set
-from rpython.rtyper.lltypesystem.lltype import LowLevelType, Signed, Unsigned, 
Float, Char
-from rpython.rtyper.lltypesystem.lltype import Bool, Void, UniChar, typeOf, \
-Primitive, isCompatibleType, enforce, saferecursive, SignedLongLong, 
UnsignedLongLong
-from rpython.rtyper.lltypesystem.lltype import frozendict
-from rpython.rtyper.lltypesystem.lltype import identityhash
+
+from rpython.rlib import objectmodel, types
+from rpython.rlib.signature import signature
 from rpython.rlib.rarithmetic import intmask
-from rpython.rlib import objectmodel
+from rpython.rtyper.lltypesystem.lltype import (LowLevelType, Signed, Unsigned,
+Float, Char, Bool, Void, UniChar, typeOf, Primitive, isCompatibleType,
+enforce, saferecursive, SignedLongLong, UnsignedLongLong, frozendict,
+identityhash)
 from rpython.tool.uid import uid
 
 
@@ -75,7 +75,7 @@
 
 def _example(self):
 return _class(ROOT)
-
+
 Class = Class()
 
 class Instance(OOType):
@@ -111,7 +111,7 @@
 
 def __hash__(self):
 return object.__hash__(self)
-
+
 def _defl(self):
 return self._null
 
@@ -153,7 +153,7 @@
 _, meth = self._lookup(name)
 if meth is not None:
 raise TypeError(Cannot add field %r: method already exists % 
name)
-
+
 if self._superclass is not None:
 if self._superclass._has_field(name):
 raise TypeError(Field %r exists in superclass % name)
@@ -161,7 +161,7 @@
 if type(defn) is not tuple:
 if isinstance(defn, Meth):
 raise TypeError(Attempting to store method in field)
-
+
 fields[name] = (defn, defn._defl())
 else:
 ootype, default = defn
@@ -198,7 +198,7 @@
 def _init_instance(self, instance):
 if self._superclass is not None:
 self._superclass._init_instance(instance)
-
+
 for name, (ootype, default) in self._fields.iteritems():
 instance.__dict__[name] = enforce(ootype, default)
 
@@ -587,10 +587,10 @@
 
 # this is the equivalent of the lltypesystem ll_newlist that is
 # marked as typeMethod.
+@signature(types.any(), types.int(), returns=types.any())
 def ll_newlist(self, length):
 from rpython.rtyper.ootypesystem import rlist
 return rlist.ll_newlist(self, length)
-ll_newlist._annenforceargs_ = (None, int)
 
 # NB: We are expecting Lists of the same ITEMTYPE to compare/hash
 # equal. We don't redefine __eq__/__hash__ since the implementations
@@ -613,7 +613,7 @@
 def __hash__(self):
 if self.ITEM is None:
 raise TypeError(Can't hash uninitialized List type.)
-return BuiltinADTType.__hash__(self)
+return BuiltinADTType.__hash__(self)
 
 def __str__(self):
 return '%s(%s)' % (self.__class__.__name__,
@@ -625,7 +625,7 @@
 def _specialize(self, generic_types):
 ITEMTYPE = self._specialize_type(self.ITEM, generic_types)
 return self.__class__(ITEMTYPE)
-
+
 def _defl(self):
 return self._null
 
@@ -644,7 +644,7 @@
 # placeholders for types
 # make sure that each derived class has his own SELFTYPE_T
 # placeholder, because we want backends to distinguish that.
-
+
 SELFTYPE_T = object()
 ITEMTYPE_T = object()
 oopspec_name = 'list'
@@ -694,7 +694,7 @@
 def __hash__(self):
 if self.ITEM is None:
 raise TypeError(Can't hash uninitialized List type.)
-return BuiltinADTType.__hash__(self)
+return BuiltinADTType.__hash__(self)
 
 def __str__(self):
 return '%s(%s)' % (self.__class__.__name__,
@@ -717,14 +717,15 @@
 self.ITEM = ITEMTYPE
 self._init_methods()
 
+@signature(types.any(), types.int(), returns=types.any())
 def ll_newlist(self, length):
 from rpython.rtyper.ootypesystem import rlist
 return rlist.ll_newarray(self, length)
-ll_newlist._annenforceargs_ = (None, int)
 
 def ll_convert_from_array(self, array):
 return array
 
+
 class Dict(BuiltinADTType):
 # placeholders for types
 SELFTYPE_T = object()
@@ -790,7 +791,7 @@
 return False
 if not self._is_initialized() or not other._is_initialized():
 return False # behave like a ForwardReference, i.e. compare by 
identity
-return BuiltinADTType.__eq__(self, other) 
+return 

[pypy-commit] pypy default: (alex, fijal) fix importing and remove more annenforceargs

2013-03-21 Thread alex_gaynor
Author: Alex Gaynor alex.gay...@gmail.com
Branch: 
Changeset: r62641:af66d7a58e17
Date: 2013-03-21 22:15 -0700
http://bitbucket.org/pypy/pypy/changeset/af66d7a58e17/

Log:(alex, fijal) fix importing and remove more annenforceargs

diff --git a/rpython/annotator/model.py b/rpython/annotator/model.py
--- a/rpython/annotator/model.py
+++ b/rpython/annotator/model.py
@@ -530,7 +530,6 @@
 # annotation of low-level types
 
 from rpython.rtyper.lltypesystem import lltype
-from rpython.rtyper.ootypesystem import ootype
 
 class SomePtr(SomeObject):
 knowntype = lltype._ptr
@@ -556,27 +555,35 @@
 def can_be_none(self):
 return False
 
+
 class SomeOOObject(SomeObject):
 def __init__(self):
+from rpython.rtyper.ootypesystem import ootype
 self.ootype = ootype.Object
 
+
 class SomeOOClass(SomeObject):
 def __init__(self, ootype):
 self.ootype = ootype
 
+
 class SomeOOInstance(SomeObject):
 def __init__(self, ootype, can_be_None=False):
 self.ootype = ootype
 self.can_be_None = can_be_None
 
+
 class SomeOOBoundMeth(SomeObject):
 immutable = True
+
 def __init__(self, ootype, name):
 self.ootype = ootype
 self.name = name
 
+
 class SomeOOStaticMeth(SomeObject):
 immutable = True
+
 def __init__(self, method):
 self.method = method
 
@@ -592,6 +599,8 @@
 ]
 
 def annotation_to_lltype(s_val, info=None):
+from rpython.rtyper.ootypesystem import ootype
+
 if isinstance(s_val, SomeOOInstance):
 return s_val.ootype
 if isinstance(s_val, SomeOOStaticMeth):
@@ -625,6 +634,8 @@
 ll_to_annotation_map = dict([(ll, ann) for ann, ll in annotation_to_ll_map])
 
 def lltype_to_annotation(T):
+from rpython.rtyper.ootypesystem import ootype
+
 try:
 s = ll_to_annotation_map.get(T)
 except TypeError:
@@ -730,7 +741,7 @@
 flattened = args
 for arg in flattened:
 if arg.__class__ is SomeObject and arg.knowntype is not type:
-return  SomeObject()
+return SomeObject()
 bookkeeper = rpython.annotator.bookkeeper.getbookkeeper()
 bookkeeper.warning(no precise annotation supplied for %s%r % (name, 
args))
 return s_ImpossibleValue
diff --git a/rpython/rtyper/lltypesystem/rlist.py 
b/rpython/rtyper/lltypesystem/rlist.py
--- a/rpython/rtyper/lltypesystem/rlist.py
+++ b/rpython/rtyper/lltypesystem/rlist.py
@@ -1,6 +1,6 @@
-from rpython.rlib import rgc, jit
+from rpython.rlib import rgc, jit, types
 from rpython.rlib.debug import ll_assert
-from rpython.rlib.objectmodel import enforceargs
+from rpython.rlib.signature import signature
 from rpython.rtyper.lltypesystem import rstr
 from rpython.rtyper.lltypesystem.lltype import (GcForwardReference, Ptr, 
GcArray,
  GcStruct, Void, Signed, malloc, typeOf, nullptr, typeMethod)
@@ -171,7 +171,7 @@
 
 # adapted C code
 
-@enforceargs(None, int, None)
+@signature(types.any(), types.int(), types.bool(), returns=types.none())
 def _ll_list_resize_hint_really(l, newsize, overallocate):
 
 Ensure l.items has room for at least newsize elements.  Note that
@@ -227,7 +227,8 @@
 if allocated  newsize or newsize  (allocated  1) - 5:
 _ll_list_resize_hint_really(l, newsize, False)
 
-@enforceargs(None, int, None)
+
+@signature(types.any(), types.int(), types.bool(), returns=types.none())
 def _ll_list_resize_really(l, newsize, overallocate):
 
 Ensure l.items has room for at least newsize elements, and set
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: random whitespace/other cleanup

2013-03-21 Thread alex_gaynor
Author: Alex Gaynor alex.gay...@gmail.com
Branch: 
Changeset: r62642:d425c8bf2b7e
Date: 2013-03-21 22:19 -0700
http://bitbucket.org/pypy/pypy/changeset/d425c8bf2b7e/

Log:random whitespace/other cleanup

diff --git a/rpython/annotator/model.py b/rpython/annotator/model.py
--- a/rpython/annotator/model.py
+++ b/rpython/annotator/model.py
@@ -29,13 +29,15 @@
 
 from __future__ import absolute_import
 
-from types import BuiltinFunctionType, MethodType, FunctionType
+import inspect
+import weakref
+from types import BuiltinFunctionType, MethodType
+
 import rpython
 from rpython.tool import descriptor
 from rpython.tool.pairtype import pair, extendabletype
-from rpython.rlib.rarithmetic import r_uint, r_ulonglong, base_int
-from rpython.rlib.rarithmetic import r_singlefloat, r_longfloat
-import inspect, weakref
+from rpython.rlib.rarithmetic import r_uint, base_int, r_singlefloat, 
r_longfloat
+
 
 class State(object):
 # A global attribute :-(  Patch it with 'True' to enable checking of
@@ -56,8 +58,10 @@
 def __eq__(self, other):
 return (self.__class__ is other.__class__ and
 self.__dict__  == other.__dict__)
+
 def __ne__(self, other):
 return not (self == other)
+
 def __repr__(self):
 try:
 reprdict = TLS.reprdict
@@ -75,7 +79,7 @@
 m = getattr(self, 'fmt_' + k, repr)
 r = m(v)
 if r is not None:
-args.append('%s=%s'%(k, r))
+args.append('%s=%s' % (k, r))
 kwds = ', '.join(args)
 finally:
 del reprdict[self]
@@ -130,6 +134,7 @@
 def can_be_none(self):
 return False
 
+
 class SomeFloat(SomeObject):
 Stands for a float or an integer.
 knowntype = float   # if we don't know if it's a float or an int,
@@ -152,6 +157,7 @@
 def can_be_none(self):
 return False
 
+
 class SomeSingleFloat(SomeObject):
 Stands for an r_singlefloat.
 # No operation supported, not even union with a regular float
@@ -161,6 +167,7 @@
 def can_be_none(self):
 return False
 
+
 class SomeLongFloat(SomeObject):
 Stands for an r_longfloat.
 # No operation supported, not even union with a regular float
@@ -170,9 +177,11 @@
 def can_be_none(self):
 return False
 
+
 class SomeInteger(SomeFloat):
 Stands for an object which is known to be an integer.
 knowntype = int
+
 # size is in multiples of C's sizeof(long)!
 def __init__(self, nonneg=False, unsigned=None, knowntype=None):
 assert (knowntype is None or knowntype is int or
@@ -189,25 +198,29 @@
 self.nonneg = unsigned or nonneg
 self.unsigned = unsigned  # rpython.rlib.rarithmetic.r_uint
 
+
 class SomeBool(SomeInteger):
 Stands for true or false.
 knowntype = bool
 nonneg = True
 unsigned = False
+
 def __init__(self):
 pass
+
 def set_knowntypedata(self, knowntypedata):
 assert not hasattr(self, 'knowntypedata')
 if knowntypedata:
 self.knowntypedata = knowntypedata
 
+
 class SomeStringOrUnicode(SomeObject):
 Base class for shared implementation of SomeString and 
SomeUnicodeString.
 
 Cannot be an annotation.
 
 immutable = True
-can_be_None=False
+can_be_None = False
 no_nul = False  # No NUL character in the string.
 
 def __init__(self, can_be_None=False, no_nul=False):
@@ -226,8 +239,10 @@
 d1 = self.__dict__
 d2 = other.__dict__
 if not TLS.check_str_without_nul:
-d1 = d1.copy(); d1['no_nul'] = 0   # ignored
-d2 = d2.copy(); d2['no_nul'] = 0   # ignored
+d1 = d1.copy()
+d1['no_nul'] = 0
+d2 = d2.copy()
+d2['no_nul'] = 0
 return d1 == d2
 
 def nonnoneify(self):
@@ -236,27 +251,34 @@
 def nonnulify(self):
 return self.__class__(can_be_None=self.can_be_None, no_nul=True)
 
+
 class SomeString(SomeStringOrUnicode):
 Stands for an object which is known to be a string.
 knowntype = str
 
+
 class SomeUnicodeString(SomeStringOrUnicode):
 Stands for an object which is known to be an unicode string
 knowntype = unicode
 
+
 class SomeByteArray(SomeStringOrUnicode):
 knowntype = bytearray
 
+
 class SomeChar(SomeString):
 Stands for an object known to be a string of length 1.
 can_be_None = False
+
 def __init__(self, no_nul=False):# no 'can_be_None' argument here
 if no_nul:
 self.no_nul = True
 
+
 class SomeUnicodeCodePoint(SomeUnicodeString):
 Stands for an object known to be a unicode codepoint.
 can_be_None = False
+
 def __init__(self, no_nul=False):# no 'can_be_None' argument here
 if no_nul:
 self.no_nul = True
@@ -266,11 +288,14 @@
 SomeUnicodeString.basestringclass = SomeUnicodeString
 SomeUnicodeString.basecharclass = SomeUnicodeCodePoint
 
+
 

[pypy-commit] buildbot default: try on cpython just to see how it goes

2013-03-21 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: 
Changeset: r754:14454bbd4ec3
Date: 2013-03-21 22:34 -0700
http://bitbucket.org/pypy/buildbot/changeset/14454bbd4ec3/

Log:try on cpython just to see how it goes

diff --git a/bot2/pypybuildbot/master.py b/bot2/pypybuildbot/master.py
--- a/bot2/pypybuildbot/master.py
+++ b/bot2/pypybuildbot/master.py
@@ -102,6 +102,7 @@
 translationArgs=jit_translation_args,
 targetArgs=[],
 lib_python=True,
+interpreter='/usr/bin/python',
 pypyjit=True,
 app_tests=True,
 platform='linux64',
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] buildbot default: merge

2013-03-21 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: 
Changeset: r755:ccd87fb0895a
Date: 2013-03-21 22:35 -0700
http://bitbucket.org/pypy/buildbot/changeset/ccd87fb0895a/

Log:merge

diff --git a/bot2/pypybuildbot/pypylist.py b/bot2/pypybuildbot/pypylist.py
--- a/bot2/pypybuildbot/pypylist.py
+++ b/bot2/pypybuildbot/pypylist.py
@@ -1,11 +1,10 @@
 import os.path
 import datetime
 import itertools
-import re
 import py
 import cgi
 import urllib
-from twisted.web import resource
+import sys
 from twisted.web.static import File, DirectoryLister
 
 class PyPyTarball(object):
@@ -103,25 +102,45 @@
 def display_in_italic(self):
 return self.vcs == 'latest'
 
+class PyPyDirectory(object):
+def __init__(self, filePath):
+self.filename = filePath.basename()
+self.filePath = filePath
+self.parse_filename()
+
+def parse_filename(self):
+if self.filename == 'trunk':
+self.last_mod_time = sys.maxsize
+return
+self.last_mod_time = self.filePath.getmtime()
+
+def key(self):
+return (self.last_mod_time)
 
 class PyPyList(File):
 
-def listNames(self):
-names = File.listNames(self)
+def sortBuildNames(self, names):
 items = map(PyPyTarball, names)
 items.sort(key=PyPyTarball.key, reverse=True)
 return [item.filename for item in items]
 
+def sortDirectoryNames(self, filePaths):
+items = map(PyPyDirectory, filePaths)
+items.sort(key=PyPyDirectory.key, reverse=True)
+return [item.filename for item in items]
+
 def directoryListing(self):
 def is_pypy_dir(names):
 for name in names:
 if name.startswith('pypy-c'):
 return True
 return False
-names = self.listNames()
+names = File.listNames(self)
 if is_pypy_dir(names):
+names = self.sortBuildNames(names)
 Listener = PyPyDirectoryLister
 else:
+names = self.sortDirectoryNames(File.listEntities(self))
 Listener = DirectoryLister
 return Listener(self.path,
 names,
diff --git a/bot2/pypybuildbot/test/test_pypylist.py 
b/bot2/pypybuildbot/test/test_pypylist.py
--- a/bot2/pypybuildbot/test/test_pypylist.py
+++ b/bot2/pypybuildbot/test/test_pypylist.py
@@ -1,5 +1,5 @@
 import py
-from pypybuildbot.pypylist import PyPyTarball
+from pypybuildbot.pypylist import PyPyTarball, PyPyList
 
 def test_pypytarball_svn():
 t = PyPyTarball('pypy-c-jit-75654-linux.tar.bz2')
@@ -12,6 +12,7 @@
 assert t.platform == 'linux'
 assert t.vcs == 'svn'
 
+
 def test_pypytarball_hg():
 t = PyPyTarball('pypy-c-jit-75654-foo-linux.tar.bz2')
 assert t.filename == 'pypy-c-jit-75654-foo-linux.tar.bz2'
@@ -23,6 +24,7 @@
 assert t.platform == 'linux'
 assert t.vcs == 'hg'
 
+
 def test_invalid_filename():
 t = PyPyTarball('foo')
 assert t.vcs == None
@@ -35,8 +37,8 @@
 t2 = PyPyTarball('pypy-c-jit-75654-linux.tar.bz2')
 assert t.key()  t2.key()
 
-def test_sort():
-files = map(PyPyTarball, [
+def test_sort(tmpdir):
+files = [
 'pypy-c-jit-1-linux.tar.bz2',
 'pypy-c-jit-2-linux.tar.bz2',
 'pypy-c-nojit-1-linux.tar.bz2',
@@ -45,11 +47,11 @@
 'pypy-c-stackless-1-linux.tar.bz2',
 'pypy-c-jit-1000-e5b73981fc8d-linux.tar.bz2', # this is mercurial 
based
 'pypy-c-jit-1-linux-armel.tar.bz2',
-])
-
-files.sort(key=PyPyTarball.key, reverse=True)
-files = [f.filename for f in files]
-assert files == [
+]
+[tmpdir.join(f).write(f) for f in files]
+pypylist = PyPyList(tmpdir.strpath)
+listener = pypylist.directoryListing()
+assert listener.dirs == [
 'pypy-c-jit-1000-e5b73981fc8d-linux.tar.bz2', # mercurial first
 'pypy-c-jit-2-linux.tar.bz2',
 'pypy-c-jit-1-linux.tar.bz2',
@@ -60,6 +62,26 @@
 'pypy-c-stackless-1-linux.tar.bz2',
 ]
 
+def test_pypy_list(tmpdir):
+import os
+pypylist = PyPyList(os.path.dirname(__file__))
+files = pypylist.listNames()
+assert os.path.basename(__file__) in files
+
+def test_dir_render(tmpdir):
+# Create a bunch of directories, including one named trunk,
+# Make sure the time order is reversed collation order
+trunk = tmpdir.mkdir('trunk')
+oldtime = trunk.mtime()
+for ascii in range(ord('a'), ord('m')):
+newdir = tmpdir.mkdir(chr(ascii) * 4)
+newdir.setmtime(oldtime + ascii * 10)
+pypylist = PyPyList(tmpdir.strpath)
+listener = pypylist.directoryListing()
+assert listener.dirs == ['trunk', '', '',
+'','','','','','','',
+'','','','']
+
 def load_BuildmasterConfig():
 import os
 from pypybuildbot import summary, builds
@@ -70,7 +92,7 @@
 return builds