[issue13188] generator.throw() ignores __traceback__ of exception

2011-10-27 Thread Petri Lehtinen
Petri Lehtinen added the comment: Ok, I think we have reached a consensus. Closing. -- status: open -> closed versions: -Python 2.7 ___ Python tracker ___ _

[issue13188] generator.throw() ignores __traceback__ of exception

2011-10-27 Thread Antoine Pitrou
Antoine Pitrou added the comment: I agree with Arkadiusz, this doesn't seem to match Python 2's exception semantics, where you always specify the traceback explicitly if you want to. -- ___ Python tracker ___

[issue13188] generator.throw() ignores __traceback__ of exception

2011-10-27 Thread Arkadiusz Wahlig
Arkadiusz Wahlig added the comment: I don't think this should be applied to 2.7. In 2.x, the full exception info consists of the (type, value, traceback)-trio. Programmer is expected to pass this around to retain full exception info. Re-raising just the value (exception instance) using "raise

[issue13188] generator.throw() ignores __traceback__ of exception

2011-10-26 Thread Petri Lehtinen
Petri Lehtinen added the comment: It seems this cannot be achieved the same way in 2.7 as the traceback is not directly associated with the exception. However, if we're currently in an exception handler and sys.exc_info() corresponds to the exception passed to generator.throw(), we could use

[issue13188] generator.throw() ignores __traceback__ of exception

2011-10-25 Thread Petri Lehtinen
Petri Lehtinen added the comment: The same issue exists on 2.7, working on a patch. -- status: closed -> open versions: +Python 2.7 ___ Python tracker ___ __

[issue13188] generator.throw() ignores __traceback__ of exception

2011-10-18 Thread Petri Lehtinen
Petri Lehtinen added the comment: BTW, shouldn't this be applied to 2.7 too? -- ___ Python tracker ___ ___ Python-bugs-list mailing l

[issue13188] generator.throw() ignores __traceback__ of exception

2011-10-18 Thread Petri Lehtinen
Petri Lehtinen added the comment: Antoine Pitrou wrote: > Actually, it is documented: > “Return the traceback associated with the exception as a new reference (...)” Ah, you're right. It just doesn't have the green "Return value: New reference" note. Thanks for committing! -- ___

[issue13188] generator.throw() ignores __traceback__ of exception

2011-10-18 Thread Antoine Pitrou
Changes by Antoine Pitrou : -- resolution: -> fixed stage: patch review -> committed/rejected status: open -> closed ___ Python tracker ___ _

[issue13188] generator.throw() ignores __traceback__ of exception

2011-10-18 Thread Roundup Robot
Roundup Robot added the comment: New changeset dcf5cc88d5c9 by Antoine Pitrou in branch '3.2': Issue #13188: When called without an explicit traceback argument, http://hg.python.org/cpython/rev/dcf5cc88d5c9 New changeset f4e3db1194e4 by Antoine Pitrou in branch 'default': Issue #13188: When cal

[issue13188] generator.throw() ignores __traceback__ of exception

2011-10-18 Thread Antoine Pitrou
Antoine Pitrou added the comment: Actually, it is documented: “Return the traceback associated with the exception as a new reference (...)” http://docs.python.org/dev/c-api/exceptions.html#PyException_GetTraceback Thanks for the patch, will apply! -- __

[issue13188] generator.throw() ignores __traceback__ of exception

2011-10-18 Thread Petri Lehtinen
Petri Lehtinen added the comment: Attached an updated patch. I incref'd the return value of PyErr_GetTraceback() because PyErr_Restore() steals the reference. The documentation of PyErr_GetTraceback() doesn't tell whether it returns a new or borrowed reference, but apparently a new reference

[issue13188] generator.throw() ignores __traceback__ of exception

2011-10-18 Thread Andreas Stührk
Andreas Stührk added the comment: It leaks because `PyException_GetTraceback()` already returns a new reference, hence the "Py_XINCREF(tb)" is wrong. -- nosy: +Trundle ___ Python tracker _

[issue13188] generator.throw() ignores __traceback__ of exception

2011-10-18 Thread Antoine Pitrou
Antoine Pitrou added the comment: Thank you! There is a memory leak somewhere: $ ./python -m test -R 3:2 test_generators [1/1] test_generators beginning 5 repetitions 12345 . test_generators leaked [1945, 1945] references, sum=3890 1 test failed: test_generators Also, since the patch

[issue13188] generator.throw() ignores __traceback__ of exception

2011-10-18 Thread Petri Lehtinen
Petri Lehtinen added the comment: Attached a patch that fixes this. The test case is a bit ugly, as it only checks that the traceback's depth is correct. -- keywords: +patch nosy: +ezio.melotti, petri.lehtinen stage: -> patch review Added file: http://bugs.python.org/file23443/issue13

[issue13188] generator.throw() ignores __traceback__ of exception

2011-10-15 Thread Antoine Pitrou
New submission from Antoine Pitrou : In the following code, the original traceback attached to the exception thrown into the generator is ignored: def gen(): try: yield except: raise g = gen() try: 1/0 except ZeroDivisionError as v: g.throw(v) But if you repla