Deferreds are Beautiful documentation has incorrect output

[email protected]
Newsgroups gmane.comp.python.twisted.bugs
Message-ID <[email protected]>
New submission from ezyang <None>:

In "Exceptions will only be handled by errbacks", the ostensible output is:

{{{
callback 1
        got result: success
        about to raise exception
errback
we got an exception: Traceback (most recent call last):
  File "./deferred_ex2.py", line 85, in ?
    nonDeferredExample("success")
--- <exception caught here> ---
  File "./deferred_ex2.py", line 46, in nonDeferredExample
    result = failAtHandlingResult(result)
  File "./deferred_ex2.py", line 35, in failAtHandlingResult
    raise RuntimeError, "whoops! we encountered an error"
exceptions.RuntimeError: whoops! we encountered an error
}}}

This doesn't actually make much sense, since nonDeferredExample is a non-existent function in the code.

The real output should look something like:

{{{
callback 1
	got result: success
	about to raise exception
errback
we got an exception: Traceback (most recent call last):
  File "deferred_ex2.py", line 85, in <module>
    behindTheScenes("success")
--- <exception caught here> ---
  File "deferred_ex2.py", line 46, in behindTheScenes
    result = failAtHandlingResult(result)
  File "deferred_ex2.py", line 35, in failAtHandlingResult
    raise RuntimeError, "whoops! we encountered an error"
exceptions.RuntimeError: whoops! we encountered an error


-------------------------------------------------

callback 1
	got result: success
	about to raise exception
errback
we got an exception: Traceback (most recent call last):
  File "deferred_ex2.py", line 88, in <module>
    deferredExample()
  File "deferred_ex2.py", line 81, in deferredExample
    d.callback("success")
  File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py", line 243, in callback
    self._startRunCallbacks(result)
  File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py", line 312, in _startRunCallbacks
    self._runCallbacks()
--- <exception caught here> ---
  File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py", line 328, in _runCallbacks
    self.result = callback(self.result, *args, **kw)
  File "deferred_ex2.py", line 35, in failAtHandlingResult
    raise RuntimeError, "whoops! we encountered an error"
exceptions.RuntimeError: whoops! we encountered an error
}}}

Although I'm a little confused why the sample wants to run itself twice.

----------
Type     : defect
Component: core
Keywords : 
Priority : normal
Nosy     : 
----------
http://twistedmatrix.com/trac/ticket/3941
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.