diff options
author | Martin Panter <vadmium+py@gmail.com> | 2016-07-26 09:18:21 (GMT) |
---|---|---|
committer | Martin Panter <vadmium+py@gmail.com> | 2016-07-26 09:18:21 (GMT) |
commit | 1050d2d0c7730c6c533246bb2404937739a7775c (patch) | |
tree | 68d901cd196aead4df7c3b074ebf2df6e85678e7 /Doc/faq/extending.rst | |
parent | 87ec85f4208bf329e6454fd3e2639c613b2b61af (diff) | |
download | cpython-1050d2d0c7730c6c533246bb2404937739a7775c.zip cpython-1050d2d0c7730c6c533246bb2404937739a7775c.tar.gz cpython-1050d2d0c7730c6c533246bb2404937739a7775c.tar.bz2 |
Issue #26462: Doc: reduce literal_block warnings, fix syntax highlighting.
Patch by Julien Palard.
Diffstat (limited to 'Doc/faq/extending.rst')
-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 |