This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mnewman
Recipients georg.brandl, mnewman
Date 2010-02-18.21:23:59
SpamBayes Score 5.8942384e-09
Marked as misclassified No
Message-id <>
Content is not covered in the online documents:

However, it does have a docstring in "C:\Python31\Lib\test\" (see below). The current example for "captured_output" does not work. Looks like someone moved it from "captured_stdout" but did not fully update it. Note the old example still references "captured_stdout". 

# Here's the current code in "":

def captured_output(stream_name):
    """Run the 'with' statement body using a StringIO object in place of a
    specific attribute on the sys module.
    Example use (with 'stream_name=stdout')::

       with captured_stdout() as s:
       assert s.getvalue() == "hello"
    import io
    orig_stdout = getattr(sys, stream_name)
    setattr(sys, stream_name, io.StringIO())
        yield getattr(sys, stream_name)
        setattr(sys, stream_name, orig_stdout)

def captured_stdout():
    return captured_output("stdout")

# Example for captured_output should now be:

       with captured_output("stdout") as s:
       assert s.getvalue() == "hello"

# It would be nice to reconcile the online doc versus the docstrings, since it confusing and makes me confused whether captured_stdout is deprecated.
Date User Action Args
2010-02-18 21:24:01mnewmansetrecipients: + mnewman, georg.brandl
2010-02-18 21:24:01mnewmansetmessageid: <>
2010-02-18 21:23:59mnewmanlinkissue7960 messages
2010-02-18 21:23:59mnewmancreate