| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -40,7 +40,7 @@ jobs: | |||
| 40 | 40 | - name: 'Build documentation' | |
| 41 | 41 | run: xvfb-run make -C Doc/ PYTHON=../python SPHINXOPTS="-q -W --keep-going -j4" doctest html | |
| 42 | 42 | - name: 'Upload' | |
| 43 | - uses: actions/upload-artifact@v2.2.3 | ||
| 43 | + uses: actions/upload-artifact@v2.2.4 | ||
| 44 | 44 | with: | |
| 45 | 45 | name: doc-html | |
| 46 | 46 | path: Doc/build/html | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -59,3 +59,11 @@ bound into a function. | |||
| 59 | 59 | ||
| 60 | 60 | For efficiently iterating over the line numbers in a code object, use `the API described in PEP 626 | |
| 61 | 61 | <https://www.python.org/dev/peps/pep-0626/#out-of-process-debuggers-and-profilers>`_. | |
| 62 | + | ||
| 63 | + .. c:function:: int PyCode_Addr2Location(PyObject *co, int byte_offset, int *start_line, int *start_column, int *end_line, int *end_column) | ||
| 64 | + | ||
| 65 | + Sets the passed ``int`` pointers to the source code line and column numbers | ||
| 66 | + for the instruction at ``byte_offset``. Sets the value to ``0`` when | ||
| 67 | + information is not available for any particular element. | ||
| 68 | + | ||
| 69 | + Returns ``1`` if the function succeeds and 0 otherwise. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -853,6 +853,8 @@ is available in ``argparse`` and adds support for boolean actions such as | |||
| 853 | 853 | >>> parser.parse_args(['--no-foo']) | |
| 854 | 854 | Namespace(foo=False) | |
| 855 | 855 | ||
| 856 | + .. versionadded:: 3.9 | ||
| 857 | + | ||
| 856 | 858 | The recommended way to create a custom action is to extend :class:`Action`, | |
| 857 | 859 | overriding the ``__call__`` method and optionally the ``__init__`` and | |
| 858 | 860 | ``format_usage`` methods. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -325,3 +325,8 @@ Writing and reading a bzip2-compressed file in binary mode: | |||
| 325 | 325 | ... content = f.read() | |
| 326 | 326 | >>> content == data # Check equality to original object after round-trip | |
| 327 | 327 | True | |
| 328 | + | ||
| 329 | + .. testcleanup:: | ||
| 330 | + | ||
| 331 | + import os | ||
| 332 | + os.remove("myfile.bz2") | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -46,6 +46,11 @@ can be customized by end users easily. | |||
| 46 | 46 | ||
| 47 | 47 | import configparser | |
| 48 | 48 | ||
| 49 | + .. testcleanup:: | ||
| 50 | + | ||
| 51 | + import os | ||
| 52 | + os.remove("example.ini") | ||
| 53 | + | ||
| 49 | 54 | ||
| 50 | 55 | Quick Start | |
| 51 | 56 | ----------- | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,13 +8,11 @@ | |||
| 8 | 8 | :synopsis: The implementation of the importlib metadata. | |
| 9 | 9 | ||
| 10 | 10 | .. versionadded:: 3.8 | |
| 11 | + .. versionchanged:: 3.10 | ||
| 12 | + ``importlib.metadata`` is no longer provisional. | ||
| 11 | 13 | ||
| 12 | 14 | **Source code:** :source:`Lib/importlib/metadata.py` | |
| 13 | 15 | ||
| 14 | - .. note:: | ||
| 15 | - This functionality is provisional and may deviate from the usual | ||
| 16 | - version semantics of the standard library. | ||
| 17 | - | ||
| 18 | 16 | ``importlib.metadata`` is a library that provides for access to installed | |
| 19 | 17 | package metadata. Built in part on Python's import system, this library | |
| 20 | 18 | intends to replace similar functionality in the `entry point | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -391,6 +391,9 @@ I/O Base Classes | |||
| 391 | 391 | to control the number of lines read: no more lines will be read if the | |
| 392 | 392 | total size (in bytes/characters) of all lines so far exceeds *hint*. | |
| 393 | 393 | ||
| 394 | + *hint* values of ``0`` or less, as well as ``None``, are treated as no | ||
| 395 | + hint. | ||
| 396 | + | ||
| 394 | 397 | Note that it's already possible to iterate on file objects using ``for | |
| 395 | 398 | line in file: ...`` without calling ``file.readlines()``. | |
| 396 | 399 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -340,6 +340,14 @@ the :mod:`glob` module.) | |||
| 340 | 340 | that contains symbolic links. On Windows, it converts forward slashes to | |
| 341 | 341 | backward slashes. To normalize case, use :func:`normcase`. | |
| 342 | 342 | ||
| 343 | + .. note:: | ||
| 344 | + On POSIX systems, in accordance with `IEEE Std 1003.1 2013 Edition; 4.13 | ||
| 345 | + Pathname Resolution <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>`_, | ||
| 346 | + if a pathname begins with exactly two slashes, the first component | ||
| 347 | + following the leading characters may be interpreted in an implementation-defined | ||
| 348 | + manner, although more than two leading characters shall be treated as a | ||
| 349 | + single character. | ||
| 350 | + | ||
| 343 | 351 | .. versionchanged:: 3.6 | |
| 344 | 352 | Accepts a :term:`path-like object`. | |
| 345 | 353 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -473,7 +473,7 @@ The output for the example would look similar to this: | |||
| 473 | 473 | ['Traceback (most recent call last):\n', | |
| 474 | 474 | ' File "<doctest default[0]>", line 10, in <module>\n lumberjack()\n ^^^^^^^^^^^^\n', | |
| 475 | 475 | ' File "<doctest default[0]>", line 4, in lumberjack\n bright_side_of_death()\n ^^^^^^^^^^^^^^^^^^^^^^\n', | |
| 476 | - ' File "<doctest default[0]>", line 7, in bright_side_of_death\n return tuple()[0]\n ^^^^^^^^^^\n', | ||
| 476 | + ' File "<doctest default[0]>", line 7, in bright_side_of_death\n return tuple()[0]\n ~~~~~~~^^^\n', | ||
| 477 | 477 | 'IndexError: tuple index out of range\n'] | |
| 478 | 478 | *** extract_tb: | |
| 479 | 479 | [<FrameSummary file <doctest...>, line 10 in <module>>, | |
@@ -482,7 +482,7 @@ The output for the example would look similar to this: | |||
| 482 | 482 | *** format_tb: | |
| 483 | 483 | [' File "<doctest default[0]>", line 10, in <module>\n lumberjack()\n ^^^^^^^^^^^^\n', | |
| 484 | 484 | ' File "<doctest default[0]>", line 4, in lumberjack\n bright_side_of_death()\n ^^^^^^^^^^^^^^^^^^^^^^\n', | |
| 485 | - ' File "<doctest default[0]>", line 7, in bright_side_of_death\n return tuple()[0]\n ^^^^^^^^^^\n'] | ||
| 485 | + ' File "<doctest default[0]>", line 7, in bright_side_of_death\n return tuple()[0]\n ~~~~~~~^^^\n'] | ||
| 486 | 486 | *** tb_lineno: 10 | |
| 487 | 487 | ||
| 488 | 488 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1015,6 +1015,39 @@ Internal types | |||
| 1015 | 1015 | If a code object represents a function, the first item in :attr:`co_consts` is | |
| 1016 | 1016 | the documentation string of the function, or ``None`` if undefined. | |
| 1017 | 1017 | ||
| 1018 | + .. method:: codeobject.co_positions() | ||
| 1019 | + | ||
| 1020 | + Returns an iterable over the source code positions of each bytecode | ||
| 1021 | + instruction in the code object. | ||
| 1022 | + | ||
| 1023 | + The iterator returns tuples containing the ``(start_line, end_line, | ||
| 1024 | + start_column, end_column)``. The *i-th* tuple corresponds to the | ||
| 1025 | + position of the source code that compiled to the *i-th* instruction. | ||
| 1026 | + Column information is 0-indexed utf-8 byte offsets on the given source | ||
| 1027 | + line. | ||
| 1028 | + | ||
| 1029 | + This positional information can be missing. A non-exhaustive lists of | ||
| 1030 | + cases where this may happen: | ||
| 1031 | + | ||
| 1032 | + - Running the interpreter with :option:`-X` ``no_debug_ranges``. | ||
| 1033 | + - Loading a pyc file compiled while using :option:`-X` ``no_debug_ranges``. | ||
| 1034 | + - Position tuples corresponding to artificial instructions. | ||
| 1035 | + - Line and column numbers that can't be represented due to | ||
| 1036 | + implementation specific limitations. | ||
| 1037 | + | ||
| 1038 | + When this occurs, some or all of the tuple elements can be | ||
| 1039 | + :const:`None`. | ||
| 1040 | + | ||
| 1041 | + .. versionadded:: 3.11 | ||
| 1042 | + | ||
| 1043 | + .. note:: | ||
| 1044 | + This feature requires storing column positions in code objects which may | ||
| 1045 | + result in a small increase of disk usage of compiled Python files or | ||
| 1046 | + interpreter memory usage. To avoid storing the extra information and/or | ||
| 1047 | + deactivate printing the extra traceback information, the | ||
| 1048 | + :option:`-X` ``no_debug_ranges`` command line flag or the :envvar:`PYTHONNODEBUGRANGES` | ||
| 1049 | + environment variable can be used. | ||
| 1050 | + | ||
| 1018 | 1051 | .. _frame-objects: | |
| 1019 | 1052 | ||
| 1020 | 1053 | Frame objects | |
| Back | FazBrowse Home | New Git URL |
0 commit comments