6 The C implementations should follow the `kernel/git coding style
7 <http://www.kernel.org/doc/Documentation/CodingStyle>`_.
13 Python code follows `PEP8 <http://www.python.org/dev/peps/pep-0008/>`_
14 with regard to coding style and `PEP257
15 <http://www.python.org/dev/peps/pep-0257/>`_ with regard to docstring
16 style. Multi-line docstrings should have one short summary line,
17 followed by a blank line and a series of paragraphs. The last
18 paragraph should be followed by a line that closes the docstring (no
19 blank line in between). Here's an example from
20 ``lib/bup/helpers.py``::
23 """Delete a file at path 'f' if it currently exists.
25 Unlike os.unlink(), does not throw an exception if the file didn't already
30 Module-level docstrings follow exactly the same guidelines but without the
31 blank line between the summary and the details.
37 Avoid finally: blocks in favor of explict catches because a throw
38 from a finally block will lose any pending exception. An explicit
39 catch can chain it (see below).
41 To behave similarly under Python 2 and 3, use add_ex_tb() to
42 explicitly add stack traces to any exceptions that are going to be
43 re-raised by anything other than a no-argument raise (otherwise the
44 stack trace will be lost)::
55 If an exception is thrown from an exception handler, the pending
56 exception should be "chained" to the new exception as the context.
57 This can be accomplished via ``chain_ex()``::
67 raise chain_ex(ex2, ex)
69 See the end of ``lib/bup/compat.py`` for a functional example.