cvsuser     04/07/21 21:31:16

  Modified:    classes  coroutine.pmc
               include/parrot exceptions.h interpreter.h
               languages/python/t/pie b2.t
               src      inter_run.c trace.c
  Log:
  Pie-thon 86 - fix a dumb exception bug
  * nested exceptions were failing, when the runloop was reentered
    more then 2 times
  * put in a runloop_level variable to aid debugging
  * it may be needed to unwind the handlers, dunno yet
  * mayjor code from b2.py is running now
  
  Revision  Changes    Path
  1.39      +4 -3      parrot/classes/coroutine.pmc
  
  Index: coroutine.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/classes/coroutine.pmc,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -w -r1.38 -r1.39
  --- coroutine.pmc     21 Jul 2004 11:42:32 -0000      1.38
  +++ coroutine.pmc     22 Jul 2004 04:31:06 -0000      1.39
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: coroutine.pmc,v 1.38 2004/07/21 11:42:32 leo Exp $
  +$Id: coroutine.pmc,v 1.39 2004/07/22 04:31:06 leo Exp $
   
   =head1 NAME
   
  @@ -137,7 +137,7 @@
   is actually done via the C<call_hook> below, a piece of code at the
   end of a coroutine:
   
  -  set P0, P5    # get the reall coroutine
  +  set P0, P5    # get the real coroutine
     invokecc      # run that code
     end           # terminate the runloop
   
  @@ -166,7 +166,8 @@
           /*
            * the generator returned None, when it's finished
            */
  -        if (res == Parrot_base_vtables[enum_class_None]->data) {
  +        if (REG_INT(3) == 1 &&
  +                res == Parrot_base_vtables[enum_class_None]->data) {
               Parrot_restore_register_frames(interpreter, regs);
               real_exception(interpreter, NULL, E_StopIteration, "StopIteration");
           }
  
  
  
  1.50      +2 -1      parrot/include/parrot/exceptions.h
  
  Index: exceptions.h
  ===================================================================
  RCS file: /cvs/public/parrot/include/parrot/exceptions.h,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -w -r1.49 -r1.50
  --- exceptions.h      5 Jul 2004 12:14:26 -0000       1.49
  +++ exceptions.h      22 Jul 2004 04:31:09 -0000      1.50
  @@ -1,7 +1,7 @@
   /* exceptions.h
    *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: exceptions.h,v 1.49 2004/07/05 12:14:26 leo Exp $
  + *     $Id: exceptions.h,v 1.50 2004/07/22 04:31:09 leo Exp $
    *  Overview:
    *     define the internal interpreter exceptions
    *  Data Structure and Algorithms:
  @@ -145,6 +145,7 @@
       long error;                         /* exception_type_enum */
       STRING *msg;                        /* may be NULL */
       void *resume;                       /* opcode_t* for resume or NULL */
  +    int runloop_level;                  /* for reentering run loop */
       struct parrot_exception_t *prev;    /* interpreters handler stack */
       long language;                      /* what is this? */
       long system;                        /* what is this? */
  
  
  
  1.147     +2 -2      parrot/include/parrot/interpreter.h
  
  Index: interpreter.h
  ===================================================================
  RCS file: /cvs/public/parrot/include/parrot/interpreter.h,v
  retrieving revision 1.146
  retrieving revision 1.147
  diff -u -w -r1.146 -r1.147
  --- interpreter.h     13 Jul 2004 14:09:16 -0000      1.146
  +++ interpreter.h     22 Jul 2004 04:31:09 -0000      1.147
  @@ -1,7 +1,7 @@
   /* interpreter.h
    *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: interpreter.h,v 1.146 2004/07/13 14:09:16 leo Exp $
  + *     $Id: interpreter.h,v 1.147 2004/07/22 04:31:09 leo Exp $
    *  Overview:
    *     The interpreter api handles running the operations
    *  Data Structure and Algorithms:
  @@ -146,7 +146,7 @@
       UINTVAL current_class_offset; /* Offset into the class array of the
                                       currently found method */
       UINTVAL recursion_depth;    /* Sub call resursion depth */
  -
  +    int runloop_level;                  /* for reentering run loop */
   } parrot_context_t;
   
   struct _Thread_data;    /* in thread.h */
  
  
  
  1.5       +25 -2     parrot/languages/python/t/pie/b2.t
  
  Index: b2.t
  ===================================================================
  RCS file: /cvs/public/parrot/languages/python/t/pie/b2.t,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -w -r1.4 -r1.5
  --- b2.t      19 Jul 2004 15:57:09 -0000      1.4
  +++ b2.t      22 Jul 2004 04:31:13 -0000      1.5
  @@ -1,9 +1,9 @@
  -# $Id: b2.t,v 1.4 2004/07/19 15:57:09 leo Exp $
  +# $Id: b2.t,v 1.5 2004/07/22 04:31:13 leo Exp $
   
   use strict;
   use lib '../../lib';
   
  -use Parrot::Test tests => 4;
  +use Parrot::Test tests => 5;
   
   sub test {
       language_output_is('python', $_[0], '', $_[1]);
  @@ -99,3 +99,26 @@
   if __name__ == '__main__':
       main()
   CODE
  +
  +test(<<'CODE', 'izip() generator with pi() object');
  +def izip(*args):
  +    args = map(iter, args)
  +    while 1:
  +        yield tuple([x.next() for x in args])
  +
  +class PI(object):
  +    def __iter__(self):
  +     i = 0
  +     while 1:
  +         yield "314159265"[i]
  +         i = i + 1
  +
  +def main():
  +    pi = PI()
  +    for x, y in izip(xrange(6), pi):
  +        print y,
  +    print "ok"
  +
  +if __name__ == '__main__':
  +    main()
  +CODE
  
  
  
  1.5       +6 -1      parrot/src/inter_run.c
  
  Index: inter_run.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/inter_run.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -w -r1.4 -r1.5
  --- inter_run.c       12 Jul 2004 20:35:40 -0000      1.4
  +++ inter_run.c       22 Jul 2004 04:31:16 -0000      1.5
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: inter_run.c,v 1.4 2004/07/12 20:35:40 nicholas Exp $
  +$Id: inter_run.c,v 1.5 2004/07/22 04:31:16 leo Exp $
   
   =head1 NAME
   
  @@ -45,11 +45,14 @@
        * But these are necessary to catch exceptions in reentered
        * run loops, e.g. if a delegate methods throws an exception
        */
  +    interpreter->ctx.runloop_level++;
   #if ! STACKED_EXCEPTIONS
       if (!interpreter->exceptions)
   #endif
       {
           new_internal_exception(interpreter);
  +        interpreter->exceptions->runloop_level =
  +            interpreter->ctx.runloop_level;
           if (setjmp(interpreter->exceptions->destination)) {
               /* an exception was thrown */
               offset = handle_exception(interpreter);
  @@ -71,8 +74,10 @@
       if (STACKED_EXCEPTIONS) {
           Parrot_exception *e = interpreter->exceptions;
           interpreter->exceptions = e->prev;
  +        e->prev = interpreter->exc_free_list;
           interpreter->exc_free_list = e;
       }
  +    interpreter->ctx.runloop_level--;
       /*
        * not yet - this needs classifying of exceptions and handlers
        * so that only an exit handler does catch this exception
  
  
  
  1.63      +2 -2      parrot/src/trace.c
  
  Index: trace.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/trace.c,v
  retrieving revision 1.62
  retrieving revision 1.63
  diff -u -w -r1.62 -r1.63
  --- trace.c   13 Jul 2004 14:09:32 -0000      1.62
  +++ trace.c   22 Jul 2004 04:31:16 -0000      1.63
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: trace.c,v 1.62 2004/07/13 14:09:32 leo Exp $
  +$Id: trace.c,v 1.63 2004/07/22 04:31:16 leo Exp $
   
   =head1 NAME
   
  @@ -52,7 +52,7 @@
                       PIO_eprintf(interpreter, "%S=PMC(%#p Str:(NULL))",
                           VTABLE_name(interpreter, pmc), pmc);
                   else {
  -                    escaped = PDB_escape(PObj_bufstart(s), s->strlen);
  +                    escaped = PDB_escape(s->strstart, s->strlen);
                       PIO_eprintf(interpreter, "%S=PMC(%#p Str:\"%s\")",
                           VTABLE_name(interpreter, pmc), pmc,
                           escaped ? escaped : "(null)");
  
  
  

Reply via email to