[pypy-commit] pypy py3.5: Forgot self at two function calls

2016-06-22 Thread raffael_t
Author: Raffael Tfirst 
Branch: py3.5
Changeset: r85341:87c42f87967a
Date: 2016-06-22 21:08 +0200
http://bitbucket.org/pypy/pypy/changeset/87c42f87967a/

Log:Forgot self at two function calls

diff --git a/pypy/interpreter/astcompiler/astbuilder.py 
b/pypy/interpreter/astcompiler/astbuilder.py
--- a/pypy/interpreter/astcompiler/astbuilder.py
+++ b/pypy/interpreter/astcompiler/astbuilder.py
@@ -1220,7 +1220,7 @@
 (n_maker_children > 1 and
  maker.get_child(1).type == tokens.COMMA)):
 # a set display
-return handle_setdisplay(maker)
+return self.handle_setdisplay(maker)
 elif n_maker_children > 1 and maker.get_child(1).type == 
syms.comp_for:
 # a set comprehension
 return self.handle_setcomp(maker)
@@ -1234,7 +1234,7 @@
 return self.handle_dictcomp(maker)
 else:
 # a dictionary display
-return handle_dictdisplay(maker)
+return self.handle_dictdisplay(maker)
 else:
 raise AssertionError("unknown atom")
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy PyTuple_Type-subclass: make sure itemsize is inherited

2016-06-22 Thread mattip
Author: Matti Picus 
Branch: PyTuple_Type-subclass
Changeset: r85340:18b7886e7acd
Date: 2016-06-22 23:21 +0300
http://bitbucket.org/pypy/pypy/changeset/18b7886e7acd/

Log:make sure itemsize is inherited

diff --git a/pypy/module/cpyext/test/foo.c b/pypy/module/cpyext/test/foo.c
--- a/pypy/module/cpyext/test/foo.c
+++ b/pypy/module/cpyext/test/foo.c
@@ -637,7 +637,8 @@
 static PyObject * is_TupleLike(PyObject *self, PyObject * t)
 {
 int tf = t->ob_type == 
-Py_DECREF(t);
+if (t->ob_type->tp_itemsize == 0)
+return PyInt_FromLong(-1);
 return PyInt_FromLong(tf);
 }
 
diff --git a/pypy/module/cpyext/test/test_tupleobject.py 
b/pypy/module/cpyext/test/test_tupleobject.py
--- a/pypy/module/cpyext/test/test_tupleobject.py
+++ b/pypy/module/cpyext/test/test_tupleobject.py
@@ -155,4 +155,4 @@
 def test_tuple_subclass(self):
 module = self.import_module(name='foo')
 a = module.TupleLike([1, 2, 3])
-assert module.is_TupleLike(a)
+assert module.is_TupleLike(a) == 1
diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py
--- a/pypy/module/cpyext/typeobject.py
+++ b/pypy/module/cpyext/typeobject.py
@@ -371,6 +371,8 @@
 # (minimally, if tp_basicsize is zero we copy it from the base)
 if not pto.c_tp_basicsize:
 pto.c_tp_basicsize = base_pto.c_tp_basicsize
+if pto.c_tp_itemsize < base_pto.c_tp_itemsize:
+pto.c_tp_itemsize = base_pto.c_tp_itemsize
 flags = rffi.cast(lltype.Signed, pto.c_tp_flags)
 base_object_pyo = make_ref(space, space.w_object)
 base_object_pto = rffi.cast(PyTypeObjectPtr, base_object_pyo)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy PyTuple_Type-subclass: change PyTupleObject.ob_item from PyObject** to PyObject*[], implies tp_itemsize != 0

2016-06-22 Thread mattip
Author: Matti Picus 
Branch: PyTuple_Type-subclass
Changeset: r85339:1f707f869b48
Date: 2016-06-22 22:43 +0300
http://bitbucket.org/pypy/pypy/changeset/1f707f869b48/

Log:change PyTupleObject.ob_item from PyObject** to PyObject*[], implies
tp_itemsize != 0

diff --git a/pypy/module/cpyext/include/tupleobject.h 
b/pypy/module/cpyext/include/tupleobject.h
--- a/pypy/module/cpyext/include/tupleobject.h
+++ b/pypy/module/cpyext/include/tupleobject.h
@@ -8,9 +8,12 @@
 #endif
 
 typedef struct {
-PyObject_HEAD
-Py_ssize_t ob_size;
-PyObject **ob_item;/* XXX optimize to ob_item[] */
+PyObject_VAR_HEAD
+PyObject *ob_item[1];
+/* ob_item contains space for 'ob_size' elements.
+ * Items must normally not be NULL, except during construction when
+ * the tuple is not yet visible outside the function that builds it.
+ */
 } PyTupleObject;
 
 /* defined in varargswrapper.c */
diff --git a/pypy/module/cpyext/test/test_tupleobject.py 
b/pypy/module/cpyext/test/test_tupleobject.py
--- a/pypy/module/cpyext/test/test_tupleobject.py
+++ b/pypy/module/cpyext/test/test_tupleobject.py
@@ -51,7 +51,7 @@
 api._PyTuple_Resize(ar, 10)
 assert api.PyTuple_Size(ar[0]) == 10
 for i in range(3, 10):
-rffi.cast(PyTupleObject, py_tuple).c_ob_item[i] = make_ref(
+rffi.cast(PyTupleObject, ar[0]).c_ob_item[i] = make_ref(
 space, space.wrap(42 + i))
 w_tuple = from_ref(space, ar[0])
 assert space.int_w(space.len(w_tuple)) == 10
diff --git a/pypy/module/cpyext/tupleobject.py 
b/pypy/module/cpyext/tupleobject.py
--- a/pypy/module/cpyext/tupleobject.py
+++ b/pypy/module/cpyext/tupleobject.py
@@ -2,10 +2,10 @@
 from rpython.rtyper.lltypesystem import rffi, lltype
 from rpython.rlib.debug import fatalerror_notb
 from pypy.module.cpyext.api import (cpython_api, Py_ssize_t, CANNOT_FAIL,
-build_type_checkers, PyObjectFields,
+build_type_checkers, PyVarObjectFields,
 cpython_struct, bootstrap_function)
 from pypy.module.cpyext.pyobject import (PyObject, PyObjectP, Py_DecRef,
-make_ref, from_ref, decref,
+make_ref, from_ref, decref, pyobj_has_w_obj,
 track_reference, make_typedescr, get_typedescr)
 from pypy.module.cpyext.pyerrors import PyErr_BadInternalCall
 from pypy.objspace.std.tupleobject import W_TupleObject
@@ -29,8 +29,8 @@
 PyTupleObjectStruct = lltype.ForwardReference()
 PyTupleObject = lltype.Ptr(PyTupleObjectStruct)
 ObjectItems = rffi.CArray(PyObject)
-PyTupleObjectFields = PyObjectFields + \
-(("ob_size", Py_ssize_t), ("ob_item", lltype.Ptr(ObjectItems)))
+PyTupleObjectFields = PyVarObjectFields + \
+(("ob_item", ObjectItems),)
 cpython_struct("PyTupleObject", PyTupleObjectFields, PyTupleObjectStruct)
 
 @bootstrap_function
@@ -56,14 +56,12 @@
 tuple_realize() is called.  Refcount of the result is 1.
 """
 typedescr = get_typedescr(space.w_tuple.layout.typedef)
-py_obj = typedescr.allocate(space, space.w_tuple)
+py_obj = typedescr.allocate(space, space.w_tuple, length)
 py_tup = rffi.cast(PyTupleObject, py_obj)
-
-py_tup.c_ob_item = lltype.malloc(ObjectItems, length,
- flavor='raw', zero=True,
- add_memory_pressure=True)
-py_tup.c_ob_size = length
-return py_tup
+p = py_tup.c_ob_item
+for i in range(py_tup.c_ob_size):
+p[i] = lltype.nullptr(PyObject.TO)
+return py_obj
 
 def tuple_attach(space, py_obj, w_obj):
 """
@@ -71,23 +69,22 @@
 buffer must not be modified.
 """
 items_w = space.fixedview(w_obj)
-l = len(items_w)
-p = lltype.malloc(ObjectItems, l, flavor='raw',
-  add_memory_pressure=True)
+py_tup = rffi.cast(PyTupleObject, py_obj)
+length = len(items_w)
+if py_tup.c_ob_size < length:
+raise oefmt(space.w_ValueError,
+"tuple_attach called on object with ob_size %d but trying to store 
%d",
+py_tup.c_ob_size, length) 
 i = 0
 try:
-while i < l:
-p[i] = make_ref(space, items_w[i])
+while i < length:
+py_tup.c_ob_item[i] = make_ref(space, items_w[i])
 i += 1
 except:
 while i > 0:
 i -= 1
-decref(space, p[i])
-lltype.free(p, flavor='raw')
+decref(space, py_tup.c_ob_item[i])
 raise
-py_tup = rffi.cast(PyTupleObject, py_obj)
-py_tup.c_ob_size = l
-py_tup.c_ob_item = p
 
 def tuple_realize(space, py_obj):
 """
@@ -101,7 +98,9 @@
 p = py_tup.c_ob_item
 items_w = [None] * l
 for i in range(l):
-w_item = from_ref(space, p[i])
+w_item = None
+if p[i]:
+w_item = from_ref(space, p[i])
 if w_item is None:
 fatalerror_notb(
 "Fatal 

[pypy-commit] pypy PyTuple_Type-subclass: test, fix for PyTuple_Type subclassing

2016-06-22 Thread mattip
Author: Matti Picus 
Branch: PyTuple_Type-subclass
Changeset: r85338:ddf360d978b7
Date: 2016-06-20 23:36 +0300
http://bitbucket.org/pypy/pypy/changeset/ddf360d978b7/

Log:test, fix for PyTuple_Type subclassing

diff --git a/pypy/module/cpyext/test/foo.c b/pypy/module/cpyext/test/foo.c
--- a/pypy/module/cpyext/test/foo.c
+++ b/pypy/module/cpyext/test/foo.c
@@ -620,17 +620,34 @@
 (destructor)custom_dealloc, /*tp_dealloc*/
 };
 
+static PyTypeObject TupleLike = {
+PyObject_HEAD_INIT(NULL)
+0,
+"foo.TupleLike", /*tp_name*/
+sizeof(PyObject),/*tp_size*/
+};
+
+
 static PyObject *size_of_instances(PyObject *self, PyObject *t)
 {
 return PyInt_FromLong(((PyTypeObject *)t)->tp_basicsize);
 }
 
+
+static PyObject * is_TupleLike(PyObject *self, PyObject * t)
+{
+int tf = t->ob_type == 
+Py_DECREF(t);
+return PyInt_FromLong(tf);
+}
+
 /* List of functions exported by this module */
 
 static PyMethodDef foo_functions[] = {
 {"new",(PyCFunction)foo_new, METH_NOARGS, NULL},
 {"newCustom",  (PyCFunction)newCustom, METH_NOARGS, NULL},
 {"size_of_instances", (PyCFunction)size_of_instances, METH_O, NULL},
+{"is_TupleLike", (PyCFunction)is_TupleLike, METH_O, NULL},
 {NULL,NULL}/* Sentinel */
 };
 
@@ -680,6 +697,10 @@
 if (PyType_Ready() < 0)
 return;
 
+TupleLike.tp_base = _Type;
+if (PyType_Ready() < 0)
+return;
+
 m = Py_InitModule("foo", foo_functions);
 if (m == NULL)
 return;
@@ -702,4 +723,6 @@
 return;
 if (PyDict_SetItemString(d, "Custom", (PyObject *) ) < 0)
 return;
+if (PyDict_SetItemString(d, "TupleLike", (PyObject *) ) < 0)
+return;
 }
diff --git a/pypy/module/cpyext/test/test_tupleobject.py 
b/pypy/module/cpyext/test/test_tupleobject.py
--- a/pypy/module/cpyext/test/test_tupleobject.py
+++ b/pypy/module/cpyext/test/test_tupleobject.py
@@ -151,3 +151,8 @@
  """),
 ])
 module.run()
+
+def test_tuple_subclass(self):
+module = self.import_module(name='foo')
+a = module.TupleLike([1, 2, 3])
+assert module.is_TupleLike(a)
diff --git a/pypy/module/cpyext/tupleobject.py 
b/pypy/module/cpyext/tupleobject.py
--- a/pypy/module/cpyext/tupleobject.py
+++ b/pypy/module/cpyext/tupleobject.py
@@ -108,7 +108,9 @@
 "converting a PyTupleObject into a W_TupleObject, "
 "but found NULLs as items")
 items_w[i] = w_item
-w_obj = space.newtuple(items_w)
+w_type = from_ref(space, rffi.cast(PyObject, py_obj.c_ob_type))
+w_obj = space.allocate_instance(W_TupleObject, w_type)
+w_obj.__init__(items_w)
 track_reference(space, py_obj, w_obj)
 return w_obj
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: Fix comprehension unpack error

2016-06-22 Thread raffael_t
Author: Raffael Tfirst 
Branch: py3.5
Changeset: r85337:2060ceb7f13b
Date: 2016-06-22 21:01 +0200
http://bitbucket.org/pypy/pypy/changeset/2060ceb7f13b/

Log:Fix comprehension unpack error

diff --git a/pypy/interpreter/astcompiler/astbuilder.py 
b/pypy/interpreter/astcompiler/astbuilder.py
--- a/pypy/interpreter/astcompiler/astbuilder.py
+++ b/pypy/interpreter/astcompiler/astbuilder.py
@@ -1315,25 +1315,28 @@
 return comps
 
 def handle_genexp(self, genexp_node):
-elt = self.handle_expr(genexp_node.get_child(0))
-if elt.type == syms.star_expr:
-self.error("iterable unpacking cannot be used in comprehension", 
elt)
+ch = genexp_node.get_child(0)
+elt = self.handle_expr(ch)
+if isinstance(elt, ast.Starred):
+self.error("iterable unpacking cannot be used in comprehension", 
ch)
 comps = self.comprehension_helper(genexp_node.get_child(1))
 return ast.GeneratorExp(elt, comps, genexp_node.get_lineno(),
 genexp_node.get_column())
 
 def handle_listcomp(self, listcomp_node):
-elt = self.handle_expr(listcomp_node.get_child(0))
-if elt.type == syms.star_expr:
-self.error("iterable unpacking cannot be used in comprehension", 
elt)
+ch = listcomp_node.get_child(0)
+elt = self.handle_expr(ch)
+if isinstance(elt, ast.Starred):
+self.error("iterable unpacking cannot be used in comprehension", 
ch)
 comps = self.comprehension_helper(listcomp_node.get_child(1))
 return ast.ListComp(elt, comps, listcomp_node.get_lineno(),
 listcomp_node.get_column())
 
 def handle_setcomp(self, set_maker):
-elt = self.handle_expr(set_maker.get_child(0))
-if elt.type == syms.star_expr:
-self.error("iterable unpacking cannot be used in comprehension", 
elt)
+ch = set_maker.get_child(0)
+elt = self.handle_expr(ch)
+if isinstance(elt, ast.Starred):
+self.error("iterable unpacking cannot be used in comprehension", 
ch)
 comps = self.comprehension_helper(set_maker.get_child(1))
 return ast.SetComp(elt, comps, set_maker.get_lineno(),
set_maker.get_column())
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy reverse-debugger: updates

2016-06-22 Thread arigo
Author: Armin Rigo 
Branch: reverse-debugger
Changeset: r85336:1a7eac6b97b3
Date: 2016-06-22 18:32 +0200
http://bitbucket.org/pypy/pypy/changeset/1a7eac6b97b3/

Log:updates

diff --git a/rpython/rlib/revdb.py b/rpython/rlib/revdb.py
--- a/rpython/rlib/revdb.py
+++ b/rpython/rlib/revdb.py
@@ -116,11 +116,11 @@
 # 
 
 
-@specialize.arg(2)
-def _change_time(mode, time, callback):
-ll_callback = llhelper(_CALLBACK_NOARG_FNPTR, callback)
-llop.revdb_change_time(lltype.Void, mode, time, ll_callback)
-_CALLBACK_NOARG_FNPTR = lltype.Ptr(lltype.FuncType([], lltype.Void))
+## @specialize.arg(2)
+## def _change_time(mode, time, callback):
+## ll_callback = llhelper(_CALLBACK_NOARG_FNPTR, callback)
+## llop.revdb_change_time(lltype.Void, mode, time, ll_callback)
+## _CALLBACK_NOARG_FNPTR = lltype.Ptr(lltype.FuncType([], lltype.Void))
 _CALLBACK_GCREF_FNPTR = lltype.Ptr(lltype.FuncType([llmemory.GCREF],
lltype.Void))
 _CMDPTR = rffi.CStructPtr('rpy_revdb_command_s',
diff --git a/rpython/rtyper/lltypesystem/lloperation.py 
b/rpython/rtyper/lltypesystem/lloperation.py
--- a/rpython/rtyper/lltypesystem/lloperation.py
+++ b/rpython/rtyper/lltypesystem/lloperation.py
@@ -567,7 +567,6 @@
 
 'revdb_stop_point': LLOp(),
 'revdb_send_answer':LLOp(),
-'revdb_change_time':LLOp(),
 'revdb_breakpoint': LLOp(),
 'revdb_get_value':  LLOp(sideeffects=False),
 'revdb_get_unique_id':  LLOp(sideeffects=False),
diff --git a/rpython/translator/revdb/interact.py 
b/rpython/translator/revdb/interact.py
--- a/rpython/translator/revdb/interact.py
+++ b/rpython/translator/revdb/interact.py
@@ -31,6 +31,7 @@
 last_time = self.pgroup.get_current_time()
 if last_time != previous_time:
 print
+self.pgroup.update_watch_values()
 if self.print_extra_pending_info:
 print self.print_extra_pending_info
 self.print_extra_pending_info = None
@@ -117,16 +118,15 @@
 else:
 return '?point'
 
-def _bp_new(self, break_at, watchvalue=None):
+def _bp_new(self, break_at):
 b = self.pgroup.edit_breakpoints()
 new = 1
 while new in b.num2name:
 new += 1
 b.num2name[new] = break_at
-if watchvalue is not None:
-b.watchvalues[new] = watchvalue
+if break_at.startswith('W'):
+b.watchvalues[new] = ''
 print "%s %d added" % (self._bp_kind(break_at).capitalize(), new)
-return new
 
 def cmd_info_breakpoints(self):
 """List current breakpoints and watchpoints"""
@@ -288,5 +288,5 @@
 print text
 print 'Watchpoint not added'
 else:
-print 'Current value:', text
-self._bp_new('W' + argument, watchvalue=text)
+self._bp_new('W' + argument)
+self.pgroup.update_watch_values()
diff --git a/rpython/translator/revdb/process.py 
b/rpython/translator/revdb/process.py
--- a/rpython/translator/revdb/process.py
+++ b/rpython/translator/revdb/process.py
@@ -75,7 +75,7 @@
 return ''.join(pieces)
 
 def send(self, msg):
-print 'SENT:', self.pid, msg
+#print 'SENT:', self.pid, msg
 binary = struct.pack("iIqqq", msg.cmd, len(msg.extra),
  msg.arg1, msg.arg2, msg.arg3)
 self.control_socket.sendall(binary + msg.extra)
@@ -85,7 +85,7 @@
 cmd, size, arg1, arg2, arg3 = struct.unpack("iIqqq", binary)
 extra = self._recv_all(size)
 msg = Message(cmd, arg1, arg2, arg3, extra)
-print 'RECV:', self.pid, msg
+#print 'RECV:', self.pid, msg
 return msg
 
 def expect(self, cmd, arg1=0, arg2=0, arg3=0, extra=""):
@@ -133,7 +133,7 @@
 except socket.error:
 pass
 
-def forward(self, steps, breakpoint_mode, all_breakpoints):
+def forward(self, steps, breakpoint_mode):
 """Move this subprocess forward in time.
 Returns the Breakpoint or None.
 """
@@ -149,8 +149,6 @@
 break
 if bkpt is None:
 bkpt = Breakpoint(msg.arg1, msg.arg3)
-all_breakpoints.watchvalues = dict.fromkeys(
-all_breakpoints.watchvalues)# set all values to None
 assert msg.cmd == ANSWER_READY
 self.update_times(msg)
 return bkpt
@@ -175,7 +173,7 @@
 pgroup.all_printed_objects_lst.append(uid)
 sys.stdout.write('$%d = ' % nid)
 else:
-print >> sys.stderr, "unexpected message %d" % (msg.cmd,)
+print >> sys.stderr, "unexpected %r" % (msg,)
 
 
 class ReplayProcessGroup(object):
@@ -268,8 +266,7 @@
 break
 assert rel_next_clone >= 0
 if 

[pypy-commit] pypy reverse-debugger: watchpoints, in-progress

2016-06-22 Thread arigo
Author: Armin Rigo 
Branch: reverse-debugger
Changeset: r85335:fb7901990151
Date: 2016-06-22 17:30 +0200
http://bitbucket.org/pypy/pypy/changeset/fb7901990151/

Log:watchpoints, in-progress

diff --git a/rpython/rlib/revdb.py b/rpython/rlib/revdb.py
--- a/rpython/rlib/revdb.py
+++ b/rpython/rlib/revdb.py
@@ -16,12 +16,12 @@
 CMD_BREAKPOINTS = 4
 CMD_MOREINFO= 5
 CMD_ATTACHID= 6
-CMD_WATCH   = 7
-CMD_EXPECTED= 8
+CMD_CHECKWATCH  = 7
+CMD_WATCHVALUES = 8
 ANSWER_TEXT = 20
 ANSWER_MOREINFO = 21
 ANSWER_NEXTNID  = 22
-ANSWER_COMPILED = 23
+ANSWER_WATCH= 23
 
 
 def stop_point():
@@ -46,6 +46,9 @@
 def send_nextnid(unique_id):
 send_answer(ANSWER_NEXTNID, unique_id)
 
+def send_watch(text, ok_flag):
+send_answer(ANSWER_WATCH, ok_flag, extra=text)
+
 def current_time():
 """For RPython debug commands: returns the current time."""
 return llop.revdb_get_value(lltype.SignedLongLong, 'c')
@@ -103,6 +106,12 @@
 ll_callback = llhelper(_CALLBACK_GCREF_FNPTR, callback)
 llop.revdb_track_object(lltype.Void, unique_id, ll_callback)
 
+def save_state():
+return llop.revdb_save_state(lltype.Bool)
+
+def restore_state():
+llop.revdb_restore_state(lltype.Void)
+
 
 # 
 
@@ -157,7 +166,7 @@
 llannotation.lltype_to_annotation(llmemory.GCREF)]
 
 def arguments_WATCHING(self):
-return []
+raise Exception("XXX remove me")
 
 def specialize_call(self, hop):
 hop.exception_cannot_occur()
diff --git a/rpython/rtyper/lltypesystem/lloperation.py 
b/rpython/rtyper/lltypesystem/lloperation.py
--- a/rpython/rtyper/lltypesystem/lloperation.py
+++ b/rpython/rtyper/lltypesystem/lloperation.py
@@ -571,7 +571,8 @@
 'revdb_breakpoint': LLOp(),
 'revdb_get_value':  LLOp(sideeffects=False),
 'revdb_get_unique_id':  LLOp(sideeffects=False),
-## 'revdb_track_object':   LLOp(),
+'revdb_save_state': LLOp(),
+'revdb_restore_state':  LLOp(),
 }
 # * Run test_lloperation after changes. *
 
diff --git a/rpython/translator/revdb/gencsupp.py 
b/rpython/translator/revdb/gencsupp.py
--- a/rpython/translator/revdb/gencsupp.py
+++ b/rpython/translator/revdb/gencsupp.py
@@ -27,7 +27,6 @@
  lltype.Void))
 ALLOCFUNCPTR = lltype.Ptr(lltype.FuncType([rffi.LONGLONG, llmemory.GCREF],
   lltype.Void))
-WATCHFUNCPTR = lltype.Ptr(lltype.FuncType([], lltype.Signed))
 
 bk = db.translator.annotator.bookkeeper
 cmds = getattr(db.translator, 'revdb_commands', {})
@@ -37,8 +36,7 @@
 S = lltype.Struct('RPY_REVDB_COMMANDS',
   ('names', lltype.FixedSizeArray(rffi.INT, len(numcmds) + 1)),
   ('funcs', lltype.FixedSizeArray(FUNCPTR, len(numcmds))),
-  ('alloc', ALLOCFUNCPTR),
-  ('watch', WATCHFUNCPTR))
+  ('alloc', ALLOCFUNCPTR))
 s = lltype.malloc(S, flavor='raw', immortal=True, zero=True)
 
 i = 0
@@ -51,8 +49,6 @@
 i += 1
 elif name == "ALLOCATING":
 s.alloc = fnptr
-elif name == "WATCHING":
-s.watch = fnptr
 else:
 raise AssertionError("bad tag in register_debug_command(): %r"
  % (name,))
diff --git a/rpython/translator/revdb/interact.py 
b/rpython/translator/revdb/interact.py
--- a/rpython/translator/revdb/interact.py
+++ b/rpython/translator/revdb/interact.py
@@ -109,14 +109,34 @@
 lst = [str(n) for n in sorted(self.pgroup.paused)]
 print ', '.join(lst)
 
+def _bp_kind(self, name):
+if name[0] == 'B':
+return 'breakpoint'
+elif name[0] == 'W':
+return 'watchpoint'
+else:
+return '?point'
+
+def _bp_new(self, break_at, watchvalue=None):
+b = self.pgroup.edit_breakpoints()
+new = 1
+while new in b.num2name:
+new += 1
+b.num2name[new] = break_at
+if watchvalue is not None:
+b.watchvalues[new] = watchvalue
+print "%s %d added" % (self._bp_kind(break_at).capitalize(), new)
+return new
+
 def cmd_info_breakpoints(self):
-"""List current breakpoints"""
+"""List current breakpoints and watchpoints"""
 lst = self.pgroup.all_breakpoints.num2name.items()
 if lst:
 for num, name in sorted(lst):
-print '%8d: %s' % (num, name)
+print '\t%s %d: %s' % (self._bp_kind(name), num, name[1:])
 else:
 print 'no breakpoints.'
+cmd_info_watchpoints = cmd_info_breakpoints
 
 def move_forward(self, steps):
 self.remove_tainting()
@@ -137,7 +157,10 @@
 
 def hit_breakpoint(self, b, backward=False):
 if b.num != -1:
-self.print_extra_pending_info = 'Hit breakpoint %d' % (b.num,)

[pypy-commit] pypy py3.5: Fix keyword argument unpacking in handle_call

2016-06-22 Thread raffael_t
Author: Raffael Tfirst 
Branch: py3.5
Changeset: r85334:d3ccf823b126
Date: 2016-06-22 20:25 +0200
http://bitbucket.org/pypy/pypy/changeset/d3ccf823b126/

Log:Fix keyword argument unpacking in handle_call

diff --git a/pypy/interpreter/astcompiler/astbuilder.py 
b/pypy/interpreter/astcompiler/astbuilder.py
--- a/pypy/interpreter/astcompiler/astbuilder.py
+++ b/pypy/interpreter/astcompiler/astbuilder.py
@@ -1008,7 +1008,6 @@
 def handle_call(self, args_node, callable_expr):
 arg_count = 0 # position args + iterable args unpackings
 keyword_count = 0 # keyword args + keyword args unpackings
-doublestars_count = 0 # just keyword argument unpackings
 generator_count = 0 
 for i in range(args_node.num_children()):
 argument = args_node.get_child(i)
@@ -1032,6 +1031,7 @@
 args = []
 keywords = []
 used_keywords = {}
+doublestars_count = 0 # just keyword argument unpackings
 child_count = args_node.num_children()
 i = 0
 while i < child_count:
@@ -1062,8 +1062,9 @@
 expr_node.get_column()))
 elif expr_node.type == tokens.DOUBLESTAR:
 # a keyword argument unpacking
+i += 1
 expr = self.handle_expr(argument.get_child(1))
-args.append(ast.keyword(None, expr))
+keywords.append(ast.keyword(None, expr))
 doublestars_count += 1
 elif argument.get_child(1).type == syms.comp_for:
 # the lone generator expression
@@ -1223,7 +1224,7 @@
 elif n_maker_children > 1 and maker.get_child(1).type == 
syms.comp_for:
 # a set comprehension
 return self.handle_setcomp(maker)
-elif (n_maker_children > 3 - is_dict and
+elif (n_maker_children > (3-is_dict) and
   maker.get_child(3-is_dict).type == syms.comp_for):
 # a dictionary comprehension
 if is_dict:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: Handle setdisplay in ast

2016-06-22 Thread raffael_t
Author: Raffael Tfirst 
Branch: py3.5
Changeset: r85333:002348cdc66f
Date: 2016-06-22 19:22 +0200
http://bitbucket.org/pypy/pypy/changeset/002348cdc66f/

Log:Handle setdisplay in ast

diff --git a/pypy/interpreter/astcompiler/astbuilder.py 
b/pypy/interpreter/astcompiler/astbuilder.py
--- a/pypy/interpreter/astcompiler/astbuilder.py
+++ b/pypy/interpreter/astcompiler/astbuilder.py
@@ -1357,6 +1357,15 @@
 values.append(dictelement[2])
 i += 1
 return ast.Dict(keys, values, node.get_lineno(), node.get_column())
+
+def handle_setdisplay(self, node):
+elts = []
+i = 0
+while i < node.num_children():
+expr = self.handle_expr(node.get_child(i))
+elts.append(expr)
+i += 2
+return ast.Set(elts, node.get_lineno(), node.get_column())
 
 def handle_exprlist(self, exprlist, context):
 exprs = []
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: Handle dictdisplay in ast

2016-06-22 Thread raffael_t
Author: Raffael Tfirst 
Branch: py3.5
Changeset: r85332:708d898b26f4
Date: 2016-06-22 19:09 +0200
http://bitbucket.org/pypy/pypy/changeset/708d898b26f4/

Log:Handle dictdisplay in ast

diff --git a/pypy/interpreter/astcompiler/astbuilder.py 
b/pypy/interpreter/astcompiler/astbuilder.py
--- a/pypy/interpreter/astcompiler/astbuilder.py
+++ b/pypy/interpreter/astcompiler/astbuilder.py
@@ -1338,8 +1338,7 @@
set_maker.get_column())
 
 def handle_dictcomp(self, dict_maker):
-i = 0
-dictelement = self.handle_dictelement(dict_maker, i)
+dictelement = self.handle_dictelement(dict_maker, 0)
 i = dictelement[0]
 key = dictelement[1]
 value = dictelement[2]
@@ -1348,8 +1347,15 @@
 dict_maker.get_column())
 
 def handle_dictdisplay(self, node):
-size = (node.num_children()+1) / 3
-
+keys = []
+values = []
+i = 0
+while i < node.num_children():
+dictelement = self.handle_dictelement(node, i)
+i = dictelement[0]
+keys.append(dictelement[1])
+values.append(dictelement[2])
+i += 1
 return ast.Dict(keys, values, node.get_lineno(), node.get_column())
 
 def handle_exprlist(self, exprlist, context):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: Throw error if unpacking is used in comprehension

2016-06-22 Thread raffael_t
Author: Raffael Tfirst 
Branch: py3.5
Changeset: r85331:3c7f568374d8
Date: 2016-06-22 18:23 +0200
http://bitbucket.org/pypy/pypy/changeset/3c7f568374d8/

Log:Throw error if unpacking is used in comprehension

diff --git a/pypy/interpreter/astcompiler/astbuilder.py 
b/pypy/interpreter/astcompiler/astbuilder.py
--- a/pypy/interpreter/astcompiler/astbuilder.py
+++ b/pypy/interpreter/astcompiler/astbuilder.py
@@ -1315,18 +1315,24 @@
 
 def handle_genexp(self, genexp_node):
 elt = self.handle_expr(genexp_node.get_child(0))
+if elt.type == syms.star_expr:
+self.error("iterable unpacking cannot be used in comprehension", 
elt)
 comps = self.comprehension_helper(genexp_node.get_child(1))
 return ast.GeneratorExp(elt, comps, genexp_node.get_lineno(),
 genexp_node.get_column())
 
 def handle_listcomp(self, listcomp_node):
 elt = self.handle_expr(listcomp_node.get_child(0))
+if elt.type == syms.star_expr:
+self.error("iterable unpacking cannot be used in comprehension", 
elt)
 comps = self.comprehension_helper(listcomp_node.get_child(1))
 return ast.ListComp(elt, comps, listcomp_node.get_lineno(),
 listcomp_node.get_column())
 
 def handle_setcomp(self, set_maker):
 elt = self.handle_expr(set_maker.get_child(0))
+if elt.type == syms.star_expr:
+self.error("iterable unpacking cannot be used in comprehension", 
elt)
 comps = self.comprehension_helper(set_maker.get_child(1))
 return ast.SetComp(elt, comps, set_maker.get_lineno(),
set_maker.get_column())
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy ppc-vsx-support: (ppc) added hypothesis test for vec_float_abs

2016-06-22 Thread plan_rich
Author: Richard Plangger 
Branch: ppc-vsx-support
Changeset: r85330:7365988a68a4
Date: 2016-06-22 17:42 +0200
http://bitbucket.org/pypy/pypy/changeset/7365988a68a4/

Log:(ppc) added hypothesis test for vec_float_abs

diff --git a/rpython/jit/metainterp/test/test_vector.py 
b/rpython/jit/metainterp/test/test_vector.py
--- a/rpython/jit/metainterp/test/test_vector.py
+++ b/rpython/jit/metainterp/test/test_vector.py
@@ -84,6 +84,49 @@
   type_system=self.type_system,
   vec=vec, vec_all=vec_all)
 
+def _vector_float_unary(self, func, type, data):
+func = always_inline(func)
+
+size = rffi.sizeof(type)
+myjitdriver = JitDriver(greens = [], reds = 'auto', vectorize=True)
+def f(bytecount, va, vc):
+i = 0
+while i < bytecount:
+myjitdriver.jit_merge_point()
+a = raw_storage_getitem(type,va,i)
+c = func(a)
+raw_storage_setitem(vc, i, rffi.cast(type,c))
+i += size
+
+la = data.draw(st.lists(st.floats(), min_size=10, max_size=150))
+l = len(la)
+
+rawstorage = RawStorage()
+va = rawstorage.new(la, type)
+vc = rawstorage.new(None, type, size=l)
+self.meta_interp(f, [l*size, va, vc])
+
+for i in range(l):
+c = raw_storage_getitem(type,vc,i*size)
+r = func(la[i])
+assert isclose(r, c) or (math.isnan(r) and math.isnan(c)) or \
+   (math.isinf(r) and math.isinf(c) and \
+(r < 0.0 and c < 0.0) or \
+(r > 0.0 and c > 0.0))
+
+rawstorage.clear()
+
+def vec_int_unary(test_func, unary_func, type):
+return pytest.mark.parametrize('func,type', [
+(unary_func, type)
+])(given(data=st.data())(test_func))
+
+vec_float_unary = functools.partial(vec_int_unary, _vector_float_unary)
+
+test_vec_abs_float = \
+vec_float_unary(lambda v: abs(v), rffi.DOUBLE)
+
+
 @given(data=st.data())
 @pytest.mark.parametrize('func', [lambda a,b: a+b,
 lambda a,b: a*b, lambda a,b: a-b])
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy ppc-vsx-support: added test to check &, | and ^ vector operations, +impl. tests pass

2016-06-22 Thread plan_rich
Author: Richard Plangger 
Branch: ppc-vsx-support
Changeset: r85329:427a2b9a7a9b
Date: 2016-06-22 17:28 +0200
http://bitbucket.org/pypy/pypy/changeset/427a2b9a7a9b/

Log:added test to check &,| and ^ vector operations, +impl. tests pass

diff --git a/rpython/jit/backend/ppc/vector_ext.py 
b/rpython/jit/backend/ppc/vector_ext.py
--- a/rpython/jit/backend/ppc/vector_ext.py
+++ b/rpython/jit/backend/ppc/vector_ext.py
@@ -47,34 +47,6 @@
 elif itemsize == 8:
 self.mc.lxvd2x(resloc.value, indexloc.value, baseloc.value)
 
-def dispatch_vector_load(self, size, Vt, index, addr):
-self.mc.lvx(Vt, index, addr)
-return
-if size == 8:
-self.mc.lvx(Vt, index, addr)
-elif size == 4:
-self.mc.lvewx(Vt, index, addr)
-elif size == 2:
-self.mc.lvehx(Vt, index, addr)
-elif size == 1:
-self.mc.lvehx(Vt, index, addr)
-else:
-notimplemented("[ppc/assembler] dispatch vector load of size %d" % 
size)
-
-def dispatch_vector_store(self, size, Vt, index, addr):
-self.mc.stvx(Vt, index, addr)
-return
-if size == 8:
-self.mc.stvx(Vt, index, addr)
-elif size == 4:
-self.mc.stvewx(Vt, index, addr)
-elif size == 2:
-self.mc.stvehx(Vt, index, addr)
-elif size == 1:
-self.mc.stvehx(Vt, index, addr)
-else:
-notimplemented("[ppc/assembler] dispatch vector load of size %d" % 
size)
-
 def emit_vec_raw_load_i(self, op, arglocs, regalloc):
 resloc, baseloc, indexloc, size_loc, ofs, \
 Vhiloc, Vloloc, Vploc, tloc = arglocs
@@ -225,15 +197,15 @@
 pass # TODO
 
 def emit_vec_int_and(self, op, arglocs, regalloc):
-resloc, loc0, loc1 = arglocs
+resloc, loc0, loc1, sizeloc = arglocs
 self.mc.vand(resloc.value, loc0.value, loc1.value)
 
 def emit_vec_int_or(self, op, arglocs, regalloc):
-resloc, loc0, loc1 = arglocs
+resloc, loc0, loc1, sizeloc = arglocs
 self.mc.vor(resloc.value, loc0.value, loc1.value)
 
 def emit_vec_int_xor(self, op, arglocs, regalloc):
-resloc, loc0, loc1 = arglocs
+resloc, loc0, loc1, sizeloc = arglocs
 self.mc.veqv(resloc.value, loc0.value, loc1.value)
 
 def emit_vec_int_signext(self, op, arglocs, regalloc):
diff --git a/rpython/jit/metainterp/test/test_vector.py 
b/rpython/jit/metainterp/test/test_vector.py
--- a/rpython/jit/metainterp/test/test_vector.py
+++ b/rpython/jit/metainterp/test/test_vector.py
@@ -181,6 +181,27 @@
 test_vector_short_sub = \
 vec_int_arith(lambda a,b: r_int(a)-r_int(b), rffi.SHORT)
 
+test_vector_signed_and = \
+vec_int_arith(lambda a,b: intmask(a)(b), rffi.SIGNED)
+test_vector_int_and = \
+vec_int_arith(lambda a,b: intmask(a)(b), rffi.INT)
+test_vector_short_and = \
+vec_int_arith(lambda a,b: intmask(a)(b), rffi.SHORT)
+
+test_vector_or_signed = \
+vec_int_arith(lambda a,b: intmask(a)|intmask(b), rffi.SIGNED)
+test_vector_or_int = \
+vec_int_arith(lambda a,b: intmask(a)|intmask(b), rffi.INT)
+test_vector_or_short = \
+vec_int_arith(lambda a,b: intmask(a)|intmask(b), rffi.SHORT)
+
+test_vector_xor_signed = \
+vec_int_arith(lambda a,b: intmask(a)^intmask(b), rffi.SIGNED)
+test_vector_xor_int = \
+vec_int_arith(lambda a,b: intmask(a)^intmask(b), rffi.INT)
+test_vector_xor_short = \
+vec_int_arith(lambda a,b: intmask(a)^intmask(b), rffi.SHORT)
+
 @py.test.mark.parametrize('i',[1,2,3,8,17,128,130,131,142,143])
 def test_vectorize_array_get_set(self,i):
 myjitdriver = JitDriver(greens = [],
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy ppc-vsx-support: (ppc) added several new ppc op codes,

2016-06-22 Thread plan_rich
Author: Richard Plangger 
Branch: ppc-vsx-support
Changeset: r85328:7799b9b5dc53
Date: 2016-06-22 16:42 +0200
http://bitbucket.org/pypy/pypy/changeset/7799b9b5dc53/

Log:(ppc) added several new ppc op codes, fixed endian issues for vec
load/store (int only). added more tests for integer add

diff --git a/rpython/jit/backend/ppc/codebuilder.py 
b/rpython/jit/backend/ppc/codebuilder.py
--- a/rpython/jit/backend/ppc/codebuilder.py
+++ b/rpython/jit/backend/ppc/codebuilder.py
@@ -614,11 +614,18 @@
 # INTEGER
 # ---
 
-# load & store
+# load
 lvx = XV(31, XO1=103)
+lvewx = XV(31, XO1=71)
+lvehx = XV(31, XO1=39)
+lvebx = XV(31, XO1=7)
+# store
 stvx = XV(31, XO1=231)
+stvewx = XV(31, XO1=199)
+stvehx = XV(31, XO1=167)
+stvebx = XV(31, XO1=135)
 
-# arith & logic
+# arith
 vaddudm = VX(4, XO8=192)
 vadduwm = VX(4, XO8=128)
 vadduhm = VX(4, XO8=64)
@@ -629,6 +636,14 @@
 vsubuhm = VX(4, XO8=1088)
 vsububm = VX(4, XO8=1024)
 
+# logic
+vand = VX(4, XO8=1028)
+vor = VX(4, XO8=1156)
+veqv = VX(4, XO8=1668)
+
+# vector move register is alias to vector or
+vmr = vor
+
 
 
 # shift, perm and select
diff --git a/rpython/jit/backend/ppc/locations.py 
b/rpython/jit/backend/ppc/locations.py
--- a/rpython/jit/backend/ppc/locations.py
+++ b/rpython/jit/backend/ppc/locations.py
@@ -30,6 +30,9 @@
 def is_fp_reg(self):
 return False
 
+def is_vector_reg(self):
+return False
+
 def is_imm_float(self):
 return False
 
@@ -77,7 +80,7 @@
 
 class VectorRegisterLocation(AssemblerLocation):
 _immutable_ = True
-width = WORD
+width = WORD * 2
 type = VECTOR
 
 def __init__(self, value):
@@ -92,6 +95,9 @@
 def as_key(self):
 return self.value + 132
 
+def is_vector_reg(self):
+return True
+
 
 class ImmLocation(AssemblerLocation):
 _immutable_ = True
diff --git a/rpython/jit/backend/ppc/ppc_assembler.py 
b/rpython/jit/backend/ppc/ppc_assembler.py
--- a/rpython/jit/backend/ppc/ppc_assembler.py
+++ b/rpython/jit/backend/ppc/ppc_assembler.py
@@ -808,6 +808,8 @@
 #name = "Loop # %s: %s" % (looptoken.number, loopname)
 #self.cpu.profile_agent.native_code_written(name,
 #   rawstart, full_size)
+#print(hex(rawstart))
+#import pdb; pdb.set_trace()
 return AsmInfo(ops_offset, rawstart + looppos,
size_excluding_failure_stuff - looppos)
 
@@ -1044,6 +1046,10 @@
 self.mc.lfd(reg, r.SPP.value, offset)
 return
 assert 0, "not supported location"
+elif prev_loc.is_vector_reg():
+assert loc.is_vector_reg()
+self.mc.vmr(loc.value, prev_loc.value, prev_loc.value)
+return
 elif prev_loc.is_reg():
 reg = prev_loc.value
 # move to another register
diff --git a/rpython/jit/backend/ppc/vector_ext.py 
b/rpython/jit/backend/ppc/vector_ext.py
--- a/rpython/jit/backend/ppc/vector_ext.py
+++ b/rpython/jit/backend/ppc/vector_ext.py
@@ -11,6 +11,7 @@
 from rpython.rtyper.lltypesystem.lloperation import llop
 from rpython.rtyper.lltypesystem import lltype
 from rpython.jit.backend.ppc.locations import imm
+from rpython.jit.backend.ppc.arch import IS_BIG_ENDIAN
 
 def not_implemented(msg):
 msg = '[ppc/vector_ext] %s\n' % msg
@@ -46,6 +47,34 @@
 elif itemsize == 8:
 self.mc.lxvd2x(resloc.value, indexloc.value, baseloc.value)
 
+def dispatch_vector_load(self, size, Vt, index, addr):
+self.mc.lvx(Vt, index, addr)
+return
+if size == 8:
+self.mc.lvx(Vt, index, addr)
+elif size == 4:
+self.mc.lvewx(Vt, index, addr)
+elif size == 2:
+self.mc.lvehx(Vt, index, addr)
+elif size == 1:
+self.mc.lvehx(Vt, index, addr)
+else:
+notimplemented("[ppc/assembler] dispatch vector load of size %d" % 
size)
+
+def dispatch_vector_store(self, size, Vt, index, addr):
+self.mc.stvx(Vt, index, addr)
+return
+if size == 8:
+self.mc.stvx(Vt, index, addr)
+elif size == 4:
+self.mc.stvewx(Vt, index, addr)
+elif size == 2:
+self.mc.stvehx(Vt, index, addr)
+elif size == 1:
+self.mc.stvehx(Vt, index, addr)
+else:
+notimplemented("[ppc/assembler] dispatch vector load of size %d" % 
size)
+
 def emit_vec_raw_load_i(self, op, arglocs, regalloc):
 resloc, baseloc, indexloc, size_loc, ofs, \
 Vhiloc, Vloloc, Vploc, tloc = arglocs
@@ -56,10 +85,17 @@
 self.mc.lvx(Vhi, indexloc.value, baseloc.value)
 Vp = Vploc.value
 t = tloc.value
-self.mc.lvsl(Vp, indexloc.value, baseloc.value)
+if IS_BIG_ENDIAN:
+

[pypy-commit] pypy guard-compatible: merge default

2016-06-22 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: guard-compatible
Changeset: r85324:914cc74b5a8c
Date: 2016-06-20 15:49 +0200
http://bitbucket.org/pypy/pypy/changeset/914cc74b5a8c/

Log:merge default

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -26,3 +26,4 @@
 40497617ae91caa1a394d8be6f9cd2de31cb0628 release-pypy3.3-v5.2
 40497617ae91caa1a394d8be6f9cd2de31cb0628 release-pypy3.3-v5.2
 c09c19272c990a0611b17569a0085ad1ab00c8ff release-pypy2.7-v5.3
+7e8df3df96417c16c2d55b41352ec82c9c69c978 release-pypy2.7-v5.3.1
diff --git a/lib_pypy/greenlet.egg-info b/lib_pypy/greenlet.egg-info
--- a/lib_pypy/greenlet.egg-info
+++ b/lib_pypy/greenlet.egg-info
@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: greenlet
-Version: 0.4.9
+Version: 0.4.10
 Summary: Lightweight in-process concurrent programming
 Home-page: https://github.com/python-greenlet/greenlet
 Author: Ralf Schmitt (for CPython), PyPy team
diff --git a/lib_pypy/greenlet.py b/lib_pypy/greenlet.py
--- a/lib_pypy/greenlet.py
+++ b/lib_pypy/greenlet.py
@@ -1,7 +1,7 @@
 import sys
 import _continuation
 
-__version__ = "0.4.9"
+__version__ = "0.4.10"
 
 # 
 # Exceptions
diff --git a/pypy/doc/cpython_differences.rst b/pypy/doc/cpython_differences.rst
--- a/pypy/doc/cpython_differences.rst
+++ b/pypy/doc/cpython_differences.rst
@@ -315,13 +315,28 @@
 
  - ``complex``
 
+ - ``str`` (empty or single-character strings only)
+
+ - ``unicode`` (empty or single-character strings only)
+
+ - ``tuple`` (empty tuples only)
+
+ - ``frozenset`` (empty frozenset only)
+
 This change requires some changes to ``id`` as well. ``id`` fulfills the
 following condition: ``x is y <=> id(x) == id(y)``. Therefore ``id`` of the
 above types will return a value that is computed from the argument, and can
 thus be larger than ``sys.maxint`` (i.e. it can be an arbitrary long).
 
-Notably missing from the list above are ``str`` and ``unicode``.  If your
-code relies on comparing strings with ``is``, then it might break in PyPy.
+Note that strings of length 2 or greater can be equal without being
+identical.  Similarly, ``x is (2,)`` is not necessarily true even if
+``x`` contains a tuple and ``x == (2,)``.  The uniqueness rules apply
+only to the particular cases described above.  The ``str``, ``unicode``,
+``tuple`` and ``frozenset`` rules were added in PyPy 5.4; before that, a
+test like ``if x is "?"`` or ``if x is ()`` could fail even if ``x`` was
+equal to ``"?"`` or ``()``.  The new behavior added in PyPy 5.4 is
+closer to CPython's, which caches precisely the empty tuple/frozenset,
+and (generally but not always) the strings and unicodes of length <= 1.
 
 Note that for floats there "``is``" only one object per "bit pattern"
 of the float.  So ``float('nan') is float('nan')`` is true on PyPy,
diff --git a/pypy/doc/index-of-release-notes.rst 
b/pypy/doc/index-of-release-notes.rst
--- a/pypy/doc/index-of-release-notes.rst
+++ b/pypy/doc/index-of-release-notes.rst
@@ -6,6 +6,7 @@
 
 .. toctree::
 
+   release-pypy2.7-v5.3.1.rst
release-pypy2.7-v5.3.0.rst
release-5.1.1.rst
release-5.1.0.rst
diff --git a/pypy/doc/index-of-whatsnew.rst b/pypy/doc/index-of-whatsnew.rst
--- a/pypy/doc/index-of-whatsnew.rst
+++ b/pypy/doc/index-of-whatsnew.rst
@@ -7,6 +7,7 @@
 .. toctree::
 
whatsnew-head.rst
+   whatsnew-pypy2-5.3.1.rst
whatsnew-pypy2-5.3.0.rst
whatsnew-5.1.0.rst
whatsnew-5.0.0.rst
diff --git a/pypy/doc/release-pypy2.7-v5.3.1.rst 
b/pypy/doc/release-pypy2.7-v5.3.1.rst
new file mode 100644
--- /dev/null
+++ b/pypy/doc/release-pypy2.7-v5.3.1.rst
@@ -0,0 +1,41 @@
+==
+PyPy 5.3.1
+==
+
+We have released a bugfix for PyPy2.7-v5.3.0, released last week,
+due to issues_ reported by users.
+
+Thanks to those who reported the issues.
+
+.. _issues: http://doc.pypy.org/en/latest/whatsnew-pypy2-5.3.1.html
+
+What is PyPy?
+=
+
+PyPy is a very compliant Python interpreter, almost a drop-in replacement for
+CPython 2.7. It's fast (`PyPy and CPython 2.7.x`_ performance comparison)
+due to its integrated tracing JIT compiler.
+
+We also welcome developers of other
+`dynamic languages`_ to see what RPython can do for them.
+
+This release supports:
+
+  * **x86** machines on most common operating systems
+(Linux 32/64, Mac OS X 64, Windows 32, OpenBSD, FreeBSD),
+
+  * newer **ARM** hardware (ARMv6 or ARMv7, with VFPv3) running Linux,
+
+  * big- and little-endian variants of **PPC64** running Linux,
+
+  * **s390x** running Linux
+
+.. _`PyPy and CPython 2.7.x`: http://speed.pypy.org
+.. _`dynamic languages`: http://pypyjs.org
+
+Please update, and continue to help us make PyPy better.
+
+Cheers
+
+The PyPy Team
+
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -5,6 +5,10 @@
 .. this is a revision shortly after release-pypy2.7-v5.3
 .. startrev: 873218a739f1
 
+.. 418b05f95db5

[pypy-commit] pypy guard-compatible: an XXX

2016-06-22 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: guard-compatible
Changeset: r85326:3c8821d370d8
Date: 2016-06-22 12:16 +0200
http://bitbucket.org/pypy/pypy/changeset/3c8821d370d8/

Log:an XXX

diff --git a/rpython/jit/metainterp/optimizeopt/pure.py 
b/rpython/jit/metainterp/optimizeopt/pure.py
--- a/rpython/jit/metainterp/optimizeopt/pure.py
+++ b/rpython/jit/metainterp/optimizeopt/pure.py
@@ -230,6 +230,8 @@
 op)
 raise InvalidLoop('A GUARD_COMPATIBLE (%s) '
   'was proven to always fail' % r)
+# XXX check that the runtime constant matches the previous set of
+# conditions too
 return
 else:
 info._compatibility_conditions = CompatibilityCondition(
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy guard-compatible: pass the first unroll test (way too easy???)

2016-06-22 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: guard-compatible
Changeset: r85327:b5babc443dd9
Date: 2016-06-22 12:17 +0200
http://bitbucket.org/pypy/pypy/changeset/b5babc443dd9/

Log:pass the first unroll test (way too easy???)

diff --git a/rpython/jit/metainterp/optimizeopt/test/test_compatible.py 
b/rpython/jit/metainterp/optimizeopt/test/test_compatible.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_compatible.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_compatible.py
@@ -3,6 +3,8 @@
 LLtypeMixin)
 from rpython.jit.metainterp.optimizeopt.test.test_optimizebasic import (
 BaseTestBasic)
+from rpython.jit.metainterp.optimizeopt.test.test_optimizeopt import (
+BaseTestWithUnroll)
 from rpython.jit.metainterp.history import ConstInt, ConstPtr
 from rpython.jit.metainterp.optimize import InvalidLoop
 
@@ -278,3 +280,25 @@
 (ConstInt(123), ConstPtr(self.quasiptr), ConstInt(-4247)): 
ConstInt(5),
 }
 self.optimize_loop(ops, expected, call_pure_results)
+
+
+class TestCompatibleUnroll(BaseTestWithUnroll, LLtypeMixin):
+
+def test_remove_guard_compatible(self):
+ops = """
+[p0]
+guard_compatible(p0, ConstPtr(myptr)) []
+guard_compatible(p0, ConstPtr(myptr)) []
+jump(p0)
+"""
+preamble = """
+[p0]
+guard_compatible(p0, ConstPtr(myptr)) []
+jump(p0)
+"""
+expected = """
+[p0]
+jump(p0)
+"""
+self.optimize_loop(ops, expected, expected_preamble=preamble)
+
diff --git a/rpython/jit/metainterp/optimizeopt/unroll.py 
b/rpython/jit/metainterp/optimizeopt/unroll.py
--- a/rpython/jit/metainterp/optimizeopt/unroll.py
+++ b/rpython/jit/metainterp/optimizeopt/unroll.py
@@ -85,6 +85,10 @@
 op.set_forwarded(str_info)
 if preamble_info.is_nonnull():
 self.make_nonnull(op)
+if preamble_info._compatibility_conditions:
+info_in_loop = op.get_forwarded()
+if info_in_loop is not None:
+info_in_loop._compatibility_conditions = 
preamble_info._compatibility_conditions
 elif isinstance(preamble_info, intutils.IntBound):
 if preamble_info.lower > MININT/2 or preamble_info.upper < 
MAXINT/2:
 intbound = self.getintbound(op)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy guard-compatible: fix an error message

2016-06-22 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: guard-compatible
Changeset: r85325:1a4c8be91191
Date: 2016-06-20 15:54 +0200
http://bitbucket.org/pypy/pypy/changeset/1a4c8be91191/

Log:fix an error message

diff --git a/rpython/jit/metainterp/optimizeopt/pure.py 
b/rpython/jit/metainterp/optimizeopt/pure.py
--- a/rpython/jit/metainterp/optimizeopt/pure.py
+++ b/rpython/jit/metainterp/optimizeopt/pure.py
@@ -228,7 +228,7 @@
 if not ccond.known_valid.same_constant(op.getarg(1)):
 r = self.optimizer.metainterp_sd.logger_ops.repr_of_resop(
 op)
-raise InvalidLoop('A GUARD_VALUE (%s) '
+raise InvalidLoop('A GUARD_COMPATIBLE (%s) '
   'was proven to always fail' % r)
 return
 else:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy guard-compatible: a testing mixin for making we_are_jitted() return random results at runtime.

2016-06-22 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: guard-compatible
Changeset: r85323:1ac481910937
Date: 2016-06-20 11:45 +0200
http://bitbucket.org/pypy/pypy/changeset/1ac481910937/

Log:a testing mixin for making we_are_jitted() return random results at
runtime. this is useful to check whether the semantics in both paths
is really the same (which it has to be).

Apply this in some objspace tests.

diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py
--- a/pypy/objspace/std/bytesobject.py
+++ b/pypy/objspace/std/bytesobject.py
@@ -1,6 +1,5 @@
 """The builtin str implementation"""
 
-from rpython.rlib.jit import we_are_jitted
 from rpython.rlib.objectmodel import (
 compute_hash, compute_unique_id, import_from_mixin)
 from rpython.rlib.buffer import StringBuffer
diff --git a/pypy/objspace/std/test/test_callmethod.py 
b/pypy/objspace/std/test/test_callmethod.py
--- a/pypy/objspace/std/test/test_callmethod.py
+++ b/pypy/objspace/std/test/test_callmethod.py
@@ -1,4 +1,6 @@
-class AppTestCallMethod:
+from rpython.rlib import jit
+
+class AppTestCallMethod(jit.RandomWeAreJittedTestMixin):
 # The exec hacking is needed to have the code snippets compiled
 # by our own compiler, not CPython's
 
diff --git a/pypy/objspace/std/test/test_mapdict.py 
b/pypy/objspace/std/test/test_mapdict.py
--- a/pypy/objspace/std/test/test_mapdict.py
+++ b/pypy/objspace/std/test/test_mapdict.py
@@ -1,6 +1,9 @@
 import pytest
 from pypy.objspace.std.test.test_dictmultiobject import FakeSpace, W_DictObject
 from pypy.objspace.std.mapdict import *
+from rpython.rlib import jit
+import random
+
 
 class Config:
 class objspace:
@@ -662,7 +665,7 @@
 
 # XXX write more
 
-class AppTestWithMapDict(object):
+class AppTestWithMapDict(jit.RandomWeAreJittedTestMixin):
 
 def test_simple(self):
 class A(object):
diff --git a/pypy/objspace/std/test/test_typeobject.py 
b/pypy/objspace/std/test/test_typeobject.py
--- a/pypy/objspace/std/test/test_typeobject.py
+++ b/pypy/objspace/std/test/test_typeobject.py
@@ -2,6 +2,7 @@
 from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.gateway import interp2app
 from pypy.interpreter.typedef import TypeDef
+from rpython.rlib import jit
 
 
 class TestTypeObject:
@@ -59,7 +60,7 @@
 assert len(warnings) == 2
 
 
-class AppTestTypeObject:
+class AppTestTypeObject(jit.RandomWeAreJittedTestMixin):
 def test_abstract_methods(self):
 class X(object):
 pass
diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py
--- a/rpython/rlib/jit.py
+++ b/rpython/rlib/jit.py
@@ -378,17 +378,38 @@
 hop.exception_cannot_occur()
 return hop.genop('hint', [v, c_hint], resulttype=v.concretetype)
 
+def _we_are_jitted_interpreted():
+return False # for monkey-patching
 
 def we_are_jitted():
 """ Considered as true during tracing and blackholing,
 so its consquences are reflected into jitted code """
 # during testing we return something randomly, to emulate the real
 # behaviour where you can switch to tracing a arbitrary points.
-return False
+return _we_are_jitted_interpreted()
 
 _we_are_jitted = CDefinedIntSymbolic('0 /* we are not jitted here */',
  default=0)
 
+
+class RandomWeAreJittedTestMixin(object):
+def setup_method(self, meth):
+global _we_are_jitted_interpreted
+seed = random.random()
+print "seed", seed
+random.seed(seed)
+self.orig_we_are_jitted = _we_are_jitted_interpreted
+def _we_are_jitted_interpreted_random():
+result = random.random() > 0.5
+return result
+_we_are_jitted_interpreted = _we_are_jitted_interpreted_random
+
+def teardown_method(self, meth):
+global _we_are_jitted_interpreted
+_we_are_jitted_interpreted = self.orig_we_are_jitted
+
+
+
 def _get_virtualizable_token(frame):
 """ An obscure API to get vable token.
 Used by _vmprof
diff --git a/rpython/rlib/test/test_jit.py b/rpython/rlib/test/test_jit.py
--- a/rpython/rlib/test/test_jit.py
+++ b/rpython/rlib/test/test_jit.py
@@ -5,7 +5,8 @@
 from rpython.rlib.jit import (hint, we_are_jitted, JitDriver, elidable_promote,
 JitHintError, oopspec, isconstant, conditional_call,
 elidable, unroll_safe, dont_look_inside,
-enter_portal_frame, leave_portal_frame, elidable_compatible)
+enter_portal_frame, leave_portal_frame, elidable_compatible,
+RandomWeAreJittedTestMixin)
 from rpython.rlib.rarithmetic import r_uint
 from rpython.rtyper.test.tool import BaseRtypingTest
 from rpython.rtyper.lltypesystem import lltype
@@ -335,3 +336,19 @@
 leave_portal_frame()
 t = Translation(g, [])
 t.compile_c() # does not crash
+
+class Test_we_are_jitted(RandomWeAreJittedTestMixin):
+def test_bad_we_are_jitted(self):
+def bad(x):
+if we_are_jitted():
+return x + 1

[pypy-commit] pypy reverse-debugger: in-progress

2016-06-22 Thread arigo
Author: Armin Rigo 
Branch: reverse-debugger
Changeset: r85322:1e5b6abe3bdb
Date: 2016-06-22 12:13 +0200
http://bitbucket.org/pypy/pypy/changeset/1e5b6abe3bdb/

Log:in-progress

diff --git a/rpython/rlib/revdb.py b/rpython/rlib/revdb.py
--- a/rpython/rlib/revdb.py
+++ b/rpython/rlib/revdb.py
@@ -16,9 +16,12 @@
 CMD_BREAKPOINTS = 4
 CMD_MOREINFO= 5
 CMD_ATTACHID= 6
+CMD_WATCH   = 7
+CMD_EXPECTED= 8
 ANSWER_TEXT = 20
 ANSWER_MOREINFO = 21
 ANSWER_NEXTNID  = 22
+ANSWER_COMPILED = 23
 
 
 def stop_point():
@@ -33,9 +36,6 @@
 def register_debug_command(command, lambda_func):
 """Register the extra RPython-implemented debug command."""
 
-def register_allocation_command(lambda_func):
-"""Register the extra RPython-implemented callback for allocation."""
-
 def send_answer(cmd, arg1=0, arg2=0, arg3=0, extra=""):
 """For RPython debug commands: writes an answer block to stdout"""
 llop.revdb_send_answer(lltype.Void, cmd, arg1, arg2, arg3, extra)
@@ -126,55 +126,38 @@
 _about_ = register_debug_command
 
 def compute_result_annotation(self, s_command_num, s_lambda_func):
-from rpython.annotator import model as annmodel
-from rpython.rtyper import llannotation
-
 command_num = s_command_num.const
 lambda_func = s_lambda_func.const
-assert isinstance(command_num, int)
+assert isinstance(command_num, (int, str))
 t = self.bookkeeper.annotator.translator
 if t.config.translation.reverse_debugger:
 func = lambda_func()
 try:
 cmds = t.revdb_commands
 except AttributeError:
-cmds = t.revdb_commands = []
-for old_num, old_func in cmds:
-if old_num == command_num:
-assert old_func is func
-break
-else:
-cmds.append((command_num, func))
+cmds = t.revdb_commands = {}
+old_func = cmds.setdefault(command_num, func)
+assert old_func is func
 s_func = self.bookkeeper.immutablevalue(func)
-s_ptr1 = llannotation.SomePtr(ll_ptrtype=_CMDPTR)
-s_str2 = annmodel.SomeString()
+arg_getter = getattr(self, 'arguments_' + str(command_num),
+ self.default_arguments)
 self.bookkeeper.emulate_pbc_call(self.bookkeeper.position_key,
- s_func, [s_ptr1, s_str2])
+ s_func, arg_getter())
+
+def default_arguments(self):
+from rpython.annotator import model as annmodel
+from rpython.rtyper import llannotation
+return [llannotation.SomePtr(ll_ptrtype=_CMDPTR),
+annmodel.SomeString()]
+
+def arguments_ALLOCATING(self):
+from rpython.annotator import model as annmodel
+from rpython.rtyper import llannotation
+return [annmodel.SomeInteger(knowntype=r_longlong),
+llannotation.lltype_to_annotation(llmemory.GCREF)]
+
+def arguments_WATCHING(self):
+return []
 
 def specialize_call(self, hop):
 hop.exception_cannot_occur()
-
-
-class RegisterAllocationCommand(ExtRegistryEntry):
-_about_ = register_allocation_command
-
-def compute_result_annotation(self, s_lambda_func):
-from rpython.annotator import model as annmodel
-from rpython.rtyper import llannotation
-
-lambda_func = s_lambda_func.const
-t = self.bookkeeper.annotator.translator
-if t.config.translation.reverse_debugger:
-func = lambda_func()
-try:
-assert t.revdb_allocation_cmd is func
-except AttributeError:
-t.revdb_allocation_cmd = func
-s_func = self.bookkeeper.immutablevalue(func)
-s_int1 = annmodel.SomeInteger(knowntype=r_longlong)
-s_ref2 = llannotation.lltype_to_annotation(llmemory.GCREF)
-self.bookkeeper.emulate_pbc_call(self.bookkeeper.position_key,
- s_func, [s_int1, s_ref2])
-
-def specialize_call(self, hop):
-hop.exception_cannot_occur()
diff --git a/rpython/translator/revdb/gencsupp.py 
b/rpython/translator/revdb/gencsupp.py
--- a/rpython/translator/revdb/gencsupp.py
+++ b/rpython/translator/revdb/gencsupp.py
@@ -27,27 +27,35 @@
  lltype.Void))
 ALLOCFUNCPTR = lltype.Ptr(lltype.FuncType([rffi.LONGLONG, llmemory.GCREF],
   lltype.Void))
+WATCHFUNCPTR = lltype.Ptr(lltype.FuncType([], lltype.Signed))
 
 bk = db.translator.annotator.bookkeeper
-cmds = getattr(db.translator, 'revdb_commands', [])
+cmds = getattr(db.translator, 'revdb_commands', {})
+numcmds = [(num, func) for (num, func) in cmds.items()
+   if isinstance(num, int)]
 

[pypy-commit] pypy reverse-debugger: tweaks

2016-06-22 Thread arigo
Author: Armin Rigo 
Branch: reverse-debugger
Changeset: r85321:76a8da332a75
Date: 2016-06-22 10:38 +0200
http://bitbucket.org/pypy/pypy/changeset/76a8da332a75/

Log:tweaks

diff --git a/rpython/translator/revdb/interact.py 
b/rpython/translator/revdb/interact.py
--- a/rpython/translator/revdb/interact.py
+++ b/rpython/translator/revdb/interact.py
@@ -22,6 +22,7 @@
 if executable is None:
 executable = fields[1]
 self.pgroup = ReplayProcessGroup(executable, revdb_log_filename)
+self.print_extra_pending_info = None
 
 def interact(self):
 last_command = 'help'
@@ -30,6 +31,10 @@
 last_time = self.pgroup.get_current_time()
 if last_time != previous_time:
 print
+if self.print_extra_pending_info:
+print self.print_extra_pending_info
+self.print_extra_pending_info = None
+if last_time != previous_time:
 self.pgroup.show_backtrace(complete=0)
 previous_time = last_time
 prompt = '(%d)$ ' % last_time
@@ -115,7 +120,7 @@
 
 def move_backward(self, steps):
 try:
-self.pgroup.go_backward(steps)
+self.pgroup.go_backward(steps, ignore_breakpoints=(steps==1))
 return True
 except Breakpoint as b:
 self.hit_breakpoint(b, backward=True)
@@ -123,7 +128,7 @@
 
 def hit_breakpoint(self, b, backward=False):
 if b.num != -1:
-print 'Hit breakpoint %d' % (b.num,)
+self.print_extra_pending_info = 'Hit breakpoint %d' % (b.num,)
 elif backward:
 b.time -= 1
 if self.pgroup.get_current_time() != b.time:
diff --git a/rpython/translator/revdb/process.py 
b/rpython/translator/revdb/process.py
--- a/rpython/translator/revdb/process.py
+++ b/rpython/translator/revdb/process.py
@@ -277,7 +277,7 @@
 if bkpt:
 raise bkpt
 
-def go_backward(self, steps):
+def go_backward(self, steps, ignore_breakpoints=False):
 """Go backward, for the given number of 'steps' of time.
 
 Closes the active process.  Implemented as jump_in_time()
@@ -285,7 +285,7 @@
 """
 assert steps >= 0
 initial_time = self.get_current_time()
-if self.all_breakpoints.is_empty():
+if self.all_breakpoints.is_empty() or ignore_breakpoints:
 self.jump_in_time(initial_time - steps)
 else:
 self._backward_search_forward(
@@ -300,7 +300,7 @@
 search_start_time = self.get_current_time()
 time_range_to_search = search_stop_time - search_start_time
 if time_range_to_search <= 0:
-print "[not found]"
+print "[search end]"
 return
 print "[searching %d..%d]" % (search_start_time,
   search_stop_time)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy.org extradoc: Add a link to Building from source

2016-06-22 Thread arigo
Author: Armin Rigo 
Branch: extradoc
Changeset: r761:0c226313307f
Date: 2016-06-22 10:25 +0200
http://bitbucket.org/pypy/pypy.org/changeset/0c226313307f/

Log:Add a link to Building from source

diff --git a/download.html b/download.html
--- a/download.html
+++ b/download.html
@@ -111,6 +111,7 @@
 version): http://packages.ubuntu.com/search?keywords=pypysearchon=names;>Ubuntu
 (https://launchpad.net/~pypy/+archive/ppa;>PPA), http://packages.debian.org/sid/pypy;>Debian, https://github.com/mxcl/homebrew/blob/master/Library/Formula/pypy.rb;>Homebrew,
 MacPorts,
 http://fedoraproject.org/wiki/Features/PyPyStack;>Fedora, http://packages.gentoo.org/package/dev-python/pypy;>Gentoo and https://wiki.archlinux.org/index.php/PyPy;>Arch are known to package 
PyPy, with various
 degrees of being up-to-date.
+or translate your own 
PyPy.
 
 
 
diff --git a/source/download.txt b/source/download.txt
--- a/source/download.txt
+++ b/source/download.txt
@@ -64,6 +64,8 @@
   `Fedora`_, `Gentoo`_ and `Arch`_ are known to package PyPy, with various
   degrees of being up-to-date.
 
+* or translate_ your own PyPy.
+
 .. _`Ubuntu`: http://packages.ubuntu.com/search?keywords=pypy=names
 .. _`PPA`: https://launchpad.net/~pypy/+archive/ppa
 .. _`Debian`: http://packages.debian.org/sid/pypy
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy reverse-debugger: Interface tweaks

2016-06-22 Thread arigo
Author: Armin Rigo 
Branch: reverse-debugger
Changeset: r85320:a80b43cb9d22
Date: 2016-06-22 10:05 +0200
http://bitbucket.org/pypy/pypy/changeset/a80b43cb9d22/

Log:Interface tweaks

diff --git a/rpython/translator/revdb/interact.py 
b/rpython/translator/revdb/interact.py
--- a/rpython/translator/revdb/interact.py
+++ b/rpython/translator/revdb/interact.py
@@ -25,8 +25,13 @@
 
 def interact(self):
 last_command = 'help'
+previous_time = None
 while True:
 last_time = self.pgroup.get_current_time()
+if last_time != previous_time:
+print
+self.pgroup.show_backtrace(complete=0)
+previous_time = last_time
 prompt = '(%d)$ ' % last_time
 sys.stdout.write(prompt)
 sys.stdout.flush()
@@ -55,11 +60,19 @@
 def command_help(self, argument):
 """Display commands summary"""
 print 'Available commands:'
-for name in dir(self):
-if name.startswith('command_'):
-command = name[len('command_'):]
-docstring = getattr(self, name).__doc__ or 'undocumented'
-print '\t%-12s %s' % (command, docstring)
+lst = dir(self)
+commands = [(name[len('command_'):], getattr(self, name))
+for name in lst
+if name.startswith('command_')]
+seen = {}
+for name, func in commands:
+seen.setdefault(func, []).append(name)
+for _, func in commands:
+if func in seen:
+names = seen.pop(func)
+names.sort(key=len, reverse=True)
+docstring = func.__doc__ or 'undocumented'
+print '\t%-16s %s' % (', '.join(names), docstring)
 
 def command_quit(self, argument):
 """Exit the debugger"""
@@ -92,6 +105,7 @@
 print ', '.join(lst)
 
 def move_forward(self, steps):
+self.remove_tainting()
 try:
 self.pgroup.go_forward(steps)
 return True
@@ -123,7 +137,6 @@
 def command_step(self, argument):
 """Run forward ARG steps (default 1)"""
 arg = int(argument or '1')
-self.remove_tainting()
 self.move_forward(arg)
 command_s = command_step
 
@@ -145,7 +158,6 @@
 
 def command_next(self, argument):
 """Run forward for one step, skipping calls"""
-self.remove_tainting()
 depth1 = self.pgroup.get_stack_depth()
 if self.move_forward(1):
 depth2 = self.pgroup.get_stack_depth()
@@ -173,11 +185,12 @@
 command_bn = command_bnext
 
 def command_finish(self, argument):
-self.remove_tainting()
+"""Run forward until the current function finishes"""
 with self._stack_depth_break(self.pgroup.get_stack_depth()):
 self.command_continue('')
 
 def command_bfinish(self, argument):
+"""Run backward until the current function is called"""
 with self._stack_depth_break(self.pgroup.get_stack_depth()):
 self.command_bcontinue('')
 
@@ -201,7 +214,7 @@
 
 def command_backtrace(self, argument):
 """Show the backtrace"""
-self.pgroup.show_backtrace()
+self.pgroup.show_backtrace(complete=1)
 command_bt = command_backtrace
 
 def command_locals(self, argument):
diff --git a/rpython/translator/revdb/process.py 
b/rpython/translator/revdb/process.py
--- a/rpython/translator/revdb/process.py
+++ b/rpython/translator/revdb/process.py
@@ -412,10 +412,10 @@
 self.active.send(Message(CMD_PRINT, extra=expression))
 self.active.print_text_answer(pgroup=self)
 
-def show_backtrace(self):
+def show_backtrace(self, complete=1):
 """Show the backtrace.
 """
-self.active.send(Message(CMD_BACKTRACE))
+self.active.send(Message(CMD_BACKTRACE, complete))
 self.active.print_text_answer()
 
 def show_locals(self):
diff --git a/rpython/translator/revdb/test/test_process.py 
b/rpython/translator/revdb/test/test_process.py
--- a/rpython/translator/revdb/test/test_process.py
+++ b/rpython/translator/revdb/test/test_process.py
@@ -28,7 +28,7 @@
 lambda_blip = lambda: blip
 
 def main(argv):
-revdb.register_debug_command(1, lambda_blip)
+revdb.register_debug_command(100, lambda_blip)
 for i, op in enumerate(argv[1:]):
 dbstate.stuff = Stuff()
 dbstate.stuff.x = i + 1000
@@ -63,8 +63,8 @@
 
 def test_breakpoint_b(self):
 group = ReplayProcessGroup(str(self.exename), self.rdbname)
-group.active.send(Message(1, 6, extra='set-breakpoint'))
-group.active.expect(42, 1, -43, -44, 'set-breakpoint')
+group.active.send(Message(100, 6, extra='set-breakpoint'))
+group.active.expect(42, 100, -43, -44, 'set-breakpoint')
 group.active.expect(ANSWER_READY, 1,