diff options
author | Martin Panter <vadmium+py@gmail.com> | 2016-07-29 01:49:37 (GMT) |
---|---|---|
committer | Martin Panter <vadmium+py@gmail.com> | 2016-07-29 01:49:37 (GMT) |
commit | 6a09315ff098224da138ff708e470ebc1c0ba8ac (patch) | |
tree | e21713f5da3e25fa00aaf284c51273d2acde2884 /Doc/faq | |
parent | 10ea19f69c0bdb2c47aaa29c62dcb1f41825a3dc (diff) | |
parent | 1050d2d0c7730c6c533246bb2404937739a7775c (diff) | |
download | cpython-6a09315ff098224da138ff708e470ebc1c0ba8ac.zip cpython-6a09315ff098224da138ff708e470ebc1c0ba8ac.tar.gz cpython-6a09315ff098224da138ff708e470ebc1c0ba8ac.tar.bz2 |
Issue #26462: Merge code block fixes from 3.5
Diffstat (limited to 'Doc/faq')
-rw-r--r-- | Doc/faq/extending.rst | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/Doc/faq/extending.rst b/Doc/faq/extending.rst index 852e35f..3eafdf1 100644 --- a/Doc/faq/extending.rst +++ b/Doc/faq/extending.rst @@ -146,7 +146,9 @@ this object to :data:`sys.stdout` and :data:`sys.stderr`. Call print_error, or just allow the standard traceback mechanism to work. Then, the output will go wherever your ``write()`` method sends it. -The easiest way to do this is to use the :class:`io.StringIO` class:: +The easiest way to do this is to use the :class:`io.StringIO` class: + +.. code-block:: pycon >>> import io, sys >>> sys.stdout = io.StringIO() @@ -156,7 +158,9 @@ The easiest way to do this is to use the :class:`io.StringIO` class:: foo hello world! -A custom object to do the same would look like this:: +A custom object to do the same would look like this: + +.. code-block:: pycon >>> import io, sys >>> class StdoutCatcher(io.TextIOBase): @@ -222,11 +226,15 @@ How do I debug an extension? When using GDB with dynamically loaded extensions, you can't set a breakpoint in your extension until your extension is loaded. -In your ``.gdbinit`` file (or interactively), add the command:: +In your ``.gdbinit`` file (or interactively), add the command: + +.. code-block:: none br _PyImport_LoadDynamicModule -Then, when you run GDB:: +Then, when you run GDB: + +.. code-block:: shell-session $ gdb /local/bin/python gdb) run myscript.py |