Skip to content

Commit

Permalink
Merge branch 'main' into keep-trailing-slash-wip3
Browse files Browse the repository at this point in the history
  • Loading branch information
barneygale committed Nov 25, 2023
2 parents 435be1b + fbb9027 commit e577a67
Show file tree
Hide file tree
Showing 192 changed files with 3,191 additions and 1,507 deletions.
6 changes: 3 additions & 3 deletions Doc/howto/descriptor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -521,11 +521,11 @@ everyday Python programs.
Descriptor protocol
-------------------

``descr.__get__(self, obj, type=None) -> value``
``descr.__get__(self, obj, type=None)``

``descr.__set__(self, obj, value) -> None``
``descr.__set__(self, obj, value)``

``descr.__delete__(self, obj) -> None``
``descr.__delete__(self, obj)``

That is all there is to it. Define any of these methods and an object is
considered a descriptor and can override default behavior upon being looked up
Expand Down
36 changes: 27 additions & 9 deletions Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ interpreter.
transparent for forward jumps but needs to be taken into account when
reasoning about backward jumps.

.. versionchanged:: 3.13
The output shows logical labels rather than instruction offsets
for jump targets and exception handlers. The ``-O`` command line
option and the ``show_offsets`` argument were added.

Example: Given the function :func:`!myfunc`::

def myfunc(alist):
Expand All @@ -62,12 +67,12 @@ the following command can be used to display the disassembly of
.. doctest::

>>> dis.dis(myfunc)
2 0 RESUME 0
2 RESUME 0
<BLANKLINE>
3 2 LOAD_GLOBAL 1 (len + NULL)
12 LOAD_FAST 0 (alist)
14 CALL 1
22 RETURN_VALUE
3 LOAD_GLOBAL 1 (len + NULL)
LOAD_FAST 0 (alist)
CALL 1
RETURN_VALUE

(The "2" is a line number).

Expand All @@ -80,7 +85,7 @@ The :mod:`dis` module can be invoked as a script from the command line:

.. code-block:: sh
python -m dis [-h] [-C] [infile]
python -m dis [-h] [-C] [-O] [infile]
The following options are accepted:

Expand All @@ -94,6 +99,10 @@ The following options are accepted:

Show inline caches.

.. cmdoption:: -O, --show-offsets

Show offsets of instructions.

If :file:`infile` is specified, its disassembled code will be written to stdout.
Otherwise, disassembly is performed on compiled source code recieved from stdin.

Expand All @@ -107,7 +116,7 @@ The bytecode analysis API allows pieces of Python code to be wrapped in a
code.

.. class:: Bytecode(x, *, first_line=None, current_offset=None,\
show_caches=False, adaptive=False)
show_caches=False, adaptive=False, show_offsets=False)

Analyse the bytecode corresponding to a function, generator, asynchronous
generator, coroutine, method, string of source code, or a code object (as
Expand All @@ -132,6 +141,9 @@ code.
If *adaptive* is ``True``, :meth:`.dis` will display specialized bytecode
that may be different from the original bytecode.

If *show_offsets* is ``True``, :meth:`.dis` will include instruction
offsets in the output.

.. classmethod:: from_traceback(tb, *, show_caches=False)

Construct a :class:`Bytecode` instance from the given traceback, setting
Expand Down Expand Up @@ -254,7 +266,8 @@ operation is being performed, so the intermediate analysis object isn't useful:
Added the *show_caches* and *adaptive* parameters.


.. function:: distb(tb=None, *, file=None, show_caches=False, adaptive=False)
.. function:: distb(tb=None, *, file=None, show_caches=False, adaptive=False,
show_offset=False)

Disassemble the top-of-stack function of a traceback, using the last
traceback if none was passed. The instruction causing the exception is
Expand All @@ -269,9 +282,12 @@ operation is being performed, so the intermediate analysis object isn't useful:
.. versionchanged:: 3.11
Added the *show_caches* and *adaptive* parameters.

.. versionchanged:: 3.13
Added the *show_offsets* parameter.

.. function:: disassemble(code, lasti=-1, *, file=None, show_caches=False, adaptive=False)
disco(code, lasti=-1, *, file=None, show_caches=False, adaptive=False)
disco(code, lasti=-1, *, file=None, show_caches=False, adaptive=False,
show_offsets=False)
Disassemble a code object, indicating the last instruction if *lasti* was
provided. The output is divided in the following columns:
Expand All @@ -296,6 +312,8 @@ operation is being performed, so the intermediate analysis object isn't useful:
.. versionchanged:: 3.11
Added the *show_caches* and *adaptive* parameters.

.. versionchanged:: 3.13
Added the *show_offsets* parameter.

.. function:: get_instructions(x, *, first_line=None, show_caches=False, adaptive=False)

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ are always available. They are listed here in alphabetical order.

*buffering* is an optional integer used to set the buffering policy. Pass 0
to switch buffering off (only allowed in binary mode), 1 to select line
buffering (only usable in text mode), and an integer > 1 to indicate the size
buffering (only usable when writing in text mode), and an integer > 1 to indicate the size
in bytes of a fixed-size chunk buffer. Note that specifying a buffer size this
way applies for binary buffered I/O, but ``TextIOWrapper`` (i.e., files opened
with ``mode='r+'``) would have another buffering. To disable buffering in
Expand Down
3 changes: 3 additions & 0 deletions Doc/library/test.rst
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ guidelines to be followed:
Running tests using the command-line interface
----------------------------------------------

.. module:: test.regrtest
:synopsis: Drives the regression test suite.

The :mod:`test` package can be run as a script to drive Python's regression
test suite, thanks to the :option:`-m` option: :program:`python -m test`. Under
the hood, it uses :mod:`test.regrtest`; the call :program:`python -m
Expand Down
3 changes: 3 additions & 0 deletions Doc/library/tkinter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ The modules that provide Tk support include:

Additional modules:

.. module:: _tkinter
:synopsis: A binary module that contains the low-level interface to Tcl/Tk.

:mod:`_tkinter`
A binary module that contains the low-level interface to Tcl/Tk.
It is automatically imported by the main :mod:`tkinter` module,
Expand Down
9 changes: 9 additions & 0 deletions Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,15 @@ copy
any user classes which define the :meth:`!__replace__` method.
(Contributed by Serhiy Storchaka in :gh:`108751`.)

dis
---

* Change the output of :mod:`dis` module functions to show logical
labels for jump targets and exception handlers, rather than offsets.
The offsets can be added with the new ``-O`` command line option or
the ``show_offsets`` parameter.
(Contributed by Irit Katriel in :gh:`112137`.)

dbm
---

Expand Down
33 changes: 18 additions & 15 deletions Include/internal/pycore_crossinterp.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,14 @@ extern void _PyXI_Fini(PyInterpreterState *interp);
// of the exception in the calling interpreter.

typedef struct _excinfo {
const char *type;
struct _excinfo_type {
PyTypeObject *builtin;
const char *name;
const char *qualname;
const char *module;
} type;
const char *msg;
} _Py_excinfo;
} _PyXI_excinfo;


typedef enum error_code {
Expand All @@ -193,13 +198,13 @@ typedef struct _sharedexception {
// The kind of error to propagate.
_PyXI_errcode code;
// The exception information to propagate, if applicable.
// This is populated only for _PyXI_ERR_UNCAUGHT_EXCEPTION.
_Py_excinfo uncaught;
} _PyXI_exception_info;
// This is populated only for some error codes,
// but always for _PyXI_ERR_UNCAUGHT_EXCEPTION.
_PyXI_excinfo uncaught;
} _PyXI_error;

PyAPI_FUNC(PyObject *) _PyXI_ApplyError(_PyXI_error *err);

PyAPI_FUNC(void) _PyXI_ApplyExceptionInfo(
_PyXI_exception_info *info,
PyObject *exctype);

typedef struct xi_session _PyXI_session;
typedef struct _sharedns _PyXI_namespace;
Expand Down Expand Up @@ -251,13 +256,13 @@ struct xi_session {

// This is set if the interpreter is entered and raised an exception
// that needs to be handled in some special way during exit.
_PyXI_errcode *exc_override;
_PyXI_errcode *error_override;
// This is set if exit captured an exception to propagate.
_PyXI_exception_info *exc;
_PyXI_error *error;

// -- pre-allocated memory --
_PyXI_exception_info _exc;
_PyXI_errcode _exc_override;
_PyXI_error _error;
_PyXI_errcode _error_override;
};

PyAPI_FUNC(int) _PyXI_Enter(
Expand All @@ -266,9 +271,7 @@ PyAPI_FUNC(int) _PyXI_Enter(
PyObject *nsupdates);
PyAPI_FUNC(void) _PyXI_Exit(_PyXI_session *session);

PyAPI_FUNC(void) _PyXI_ApplyCapturedException(
_PyXI_session *session,
PyObject *excwrapper);
PyAPI_FUNC(PyObject *) _PyXI_ApplyCapturedException(_PyXI_session *session);
PyAPI_FUNC(int) _PyXI_HasCapturedException(_PyXI_session *session);


Expand Down
5 changes: 5 additions & 0 deletions Include/internal/pycore_typeobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ extern PyTypeObject _PyBufferWrapper_Type;
extern PyObject* _PySuper_Lookup(PyTypeObject *su_type, PyObject *su_obj,
PyObject *name, int *meth_found);


// This is exported for the _testinternalcapi module.
PyAPI_FUNC(PyObject *) _PyType_GetModuleName(PyTypeObject *);


#ifdef __cplusplus
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions Include/patchlevel.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
#define PY_MINOR_VERSION 13
#define PY_MICRO_VERSION 0
#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA
#define PY_RELEASE_SERIAL 1
#define PY_RELEASE_SERIAL 2

/* Version as a string */
#define PY_VERSION "3.13.0a1+"
#define PY_VERSION "3.13.0a2+"
/*--end constants--*/

/* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2.
Expand Down
Loading

0 comments on commit e577a67

Please sign in to comment.