Closed Bug 350559 Opened 18 years ago Closed 18 years ago

js1_7/geniter/throw-after-close.js|js1_7/geniter/throw-forever.js, result: FAILED

Categories

(Core :: JavaScript Engine, defect)

x86
All
defect
Not set
normal

Tracking

()

VERIFIED FIXED
mozilla1.8.1

People

(Reporter: bc, Assigned: igor)

References

()

Details

(Keywords: regression, verified1.8.1)

Attachments

(1 file)

regression since 20060827 trunk. bug 350312?

js1_7/geniter/throw-after-close.js
 Expected value 'false', Actual value 'it.throw("foobar") failed

js1_7/geniter/throw-forever.js
Expected value 'false', Actual value 'it.throw("baz") failed'
This is a regression from the patch for bug 349320.

PEP 342 is unclear about what throw on a closed generator should do:

    3. Add a new throw() method for generator-iterators, which raises
       an exception at the point where the generator was paused, and
       which returns the next value yielded by the generator, raising
       StopIteration if the generator exits without yielding another
       value.  (If the generator does not catch the passed-in exception,
       or raises a different exception, then that exception propagates
       to the caller.)

Nevertheless, the JS implementation before rev 3.35 of jsiter.c, and Python 2.5c1, both let the thrown exception propagate, rather than raising StopIteration.

/be
Assignee: general → igor.bukanov
Blocks: 349320
Attached patch FixSplinter Review
There are no reasons not be compatible with Python.
Attachment #235930 - Flags: review?(brendan)
Comment on attachment 235930 [details] [diff] [review]
Fix

Simple and direct -- only nit is the default: case with assertion that op is JSGENOP_CLOSE -- with a disjoint sum type like JSGeneratorOp, unless we expect to add more ops, covering all cases with switch seems better (GCC will warn if someone adds an enumerator and forgets to extend the switch).

/be
Attachment #235930 - Flags: review?(brendan)
Attachment #235930 - Flags: review+
Attachment #235930 - Flags: approval1.8.1?
Regression fix needed on branch.

/be
Flags: blocking1.8.1?
(In reply to comment #3)
> (From update of attachment 235930 [details] [diff] [review] [edit])
> Simple and direct -- only nit is the default: case with assertion that op is
> JSGENOP_CLOSE -- with a disjoint sum type like JSGeneratorOp, unless we expect
> to add more ops, covering all cases with switch seems better (GCC will warn if
> someone adds an enumerator and forgets to extend the switch).

In this switch it does not matter, but try to replace "default with assert" in the outer switch and GCC starts to complain about not initialized wasNewborn variable :(. Using default+assert is less ugly for my eyes then #ifdef __GNUC__ (especially taking into account that GNUC when read as transliterated into latin  Russian sounds like "vile" or "foul" for my ears ;). Then for consistency it make sense to use default+assert in all 3 switches across the function.
(In reply to comment #5)
> (In reply to comment #3)
> In this switch it does not matter, but try to replace "default with assert" in
> the outer switch and GCC starts to complain about not initialized wasNewborn
> variable :(.

GCC is weak that way.

> Using default+assert is less ugly for my eyes then #ifdef __GNUC__
> (especially taking into account that GNUC when read as transliterated into
> latin  Russian sounds like "vile" or "foul" for my ears ;).

I had no idea -- that's karmic backlash, right there ;-)

> Then for
> consistency it make sense to use default+assert in all 3 switches across the
> function.

Cool -- nit retracted.

/be
I committed the patch from comment 2 to the trunk:

Checking in jsiter.c;
/cvsroot/mozilla/js/src/jsiter.c,v  <--  jsiter.c
new revision: 3.37; previous revision: 3.36
done
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
(In reply to comment #6)
> > Using default+assert is less ugly for my eyes then #ifdef __GNUC__
> > (especially taking into account that GNUC when read as transliterated into
> > latin  Russian sounds like "vile" or "foul" for my ears ;).
> 
> I had no idea -- that's karmic backlash, right there ;-)

There are a few jokes in Russian with that word game GNU(s|c)<->vile, like "vile soft showed it quality".
Flags: in-testsuite+
Flags: blocking1.8.1? → blocking1.8.1+
Target Milestone: --- → mozilla1.8.1
Comment on attachment 235930 [details] [diff] [review]
Fix

a=beltzner for the 181drivers
Attachment #235930 - Flags: approval1.8.1? → approval1.8.1+
verified fixed 1.9 20060830 windows/mac*/linux
Status: RESOLVED → VERIFIED
I committed the patch from comment 2 to MOZILLA_1_8_BRANCH:

Checking in jsiter.c;
/cvsroot/mozilla/js/src/jsiter.c,v  <--  jsiter.c
new revision: 3.17.2.13; previous revision: 3.17.2.12
done
Keywords: fixed1.8.1
verified fixed 1.8 20060831 windows/mac*/linux
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: