Skip to content

Commit 4670696

Browse files
authored
Merge branch 'main' into fix-for-running-tests-issue-131290
2 parents 678893f + ef4fe70 commit 4670696

File tree

152 files changed

+3369
-2322
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+3369
-2322
lines changed

Doc/glossary.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,10 @@ Glossary
800800
thread removes *key* from *mapping* after the test, but before the lookup.
801801
This issue can be solved with locks or by using the EAFP approach.
802802

803+
lexical analyzer
804+
805+
Formal name for the *tokenizer*; see :term:`token`.
806+
803807
list
804808
A built-in Python :term:`sequence`. Despite its name it is more akin
805809
to an array in other languages than to a linked list since access to
@@ -1291,6 +1295,17 @@ Glossary
12911295
See also :term:`binary file` for a file object able to read and write
12921296
:term:`bytes-like objects <bytes-like object>`.
12931297

1298+
token
1299+
1300+
A small unit of source code, generated by the
1301+
:ref:`lexical analyzer <lexical>` (also called the *tokenizer*).
1302+
Names, numbers, strings, operators,
1303+
newlines and similar are represented by tokens.
1304+
1305+
The :mod:`tokenize` module exposes Python's lexical analyzer.
1306+
The :mod:`token` module contains information on the various types
1307+
of tokens.
1308+
12941309
triple-quoted string
12951310
A string which is bound by three instances of either a quotation mark
12961311
(") or an apostrophe ('). While they don't provide any functionality

Doc/library/dis.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ details of bytecode instructions as :class:`Instruction` instances:
535535
:class:`dis.Positions` object holding the
536536
start and end locations that are covered by this instruction.
537537

538-
.. data::cache_info
538+
.. data:: cache_info
539539

540540
Information about the cache entries of this instruction, as
541541
triplets of the form ``(name, size, data)``, where the ``name``

Doc/library/pickletools.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ordinary users of the :mod:`pickle` module probably won't find the
1919

2020
.. _pickletools-cli:
2121

22-
Command line usage
22+
Command-line usage
2323
------------------
2424

2525
.. versionadded:: 3.2
@@ -48,7 +48,7 @@ For example, with a tuple ``(1, 2)`` pickled in file ``x.pickle``:
4848
9: . STOP
4949
highest protocol among opcodes = 2
5050
51-
Command line options
51+
Command-line options
5252
^^^^^^^^^^^^^^^^^^^^
5353

5454
.. program:: pickletools
@@ -72,12 +72,16 @@ Command line options
7272

7373
.. option:: -p, --preamble=<preamble>
7474

75-
When more than one pickle file are specified, print given preamble
75+
When more than one pickle file is specified, print given preamble
7676
before each disassembly.
7777

78+
.. option:: pickle_file
7879

80+
A pickle file to read, or ``-`` to indicate reading from standard input.
7981

80-
Programmatic Interface
82+
83+
84+
Programmatic interface
8185
----------------------
8286

8387

Doc/reference/lexical_analysis.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ Lexical analysis
88
.. index:: lexical analysis, parser, token
99

1010
A Python program is read by a *parser*. Input to the parser is a stream of
11-
*tokens*, generated by the *lexical analyzer*. This chapter describes how the
12-
lexical analyzer breaks a file into tokens.
11+
:term:`tokens <token>`, generated by the *lexical analyzer* (also known as
12+
the *tokenizer*).
13+
This chapter describes how the lexical analyzer breaks a file into tokens.
1314

1415
Python reads program text as Unicode code points; the encoding of a source file
1516
can be given by an encoding declaration and defaults to UTF-8, see :pep:`3120`

Doc/tutorial/errors.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ complaint you get while you are still learning Python::
2424
SyntaxError: invalid syntax
2525

2626
The parser repeats the offending line and displays little arrows pointing
27-
at the token in the line where the error was detected. The error may be
28-
caused by the absence of a token *before* the indicated token. In the
29-
example, the error is detected at the function :func:`print`, since a colon
30-
(``':'``) is missing before it. File name and line number are printed so you
31-
know where to look in case the input came from a script.
27+
at the place where the error was detected. Note that this is not always the
28+
place that needs to be fixed. In the example, the error is detected at the
29+
function :func:`print`, since a colon (``':'``) is missing just before it.
30+
31+
The file name (``<stdin>`` in our example) and line number are printed so you
32+
know where to look in case the input came from a file.
3233

3334

3435
.. _tut-exceptions:

Doc/tutorial/interactive.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ Alternatives to the Interactive Interpreter
3737

3838
This facility is an enormous step forward compared to earlier versions of the
3939
interpreter; however, some wishes are left: It would be nice if the proper
40-
indentation were suggested on continuation lines (the parser knows if an indent
41-
token is required next). The completion mechanism might use the interpreter's
42-
symbol table. A command to check (or even suggest) matching parentheses,
43-
quotes, etc., would also be useful.
40+
indentation were suggested on continuation lines (the parser knows if an
41+
:data:`~token.INDENT` token is required next). The completion mechanism might
42+
use the interpreter's symbol table. A command to check (or even suggest)
43+
matching parentheses, quotes, etc., would also be useful.
4444

4545
One alternative enhanced interactive interpreter that has been around for quite
4646
some time is IPython_, which features tab completion, object exploration and

Include/cpython/code.h

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -8,70 +8,19 @@
88
extern "C" {
99
#endif
1010

11-
/* Total tool ids available */
12-
#define _PY_MONITORING_TOOL_IDS 8
13-
/* Count of all local monitoring events */
14-
#define _PY_MONITORING_LOCAL_EVENTS 11
15-
/* Count of all "real" monitoring events (not derived from other events) */
16-
#define _PY_MONITORING_UNGROUPED_EVENTS 16
17-
/* Count of all monitoring events */
18-
#define _PY_MONITORING_EVENTS 19
19-
20-
/* Tables of which tools are active for each monitored event. */
21-
typedef struct _Py_LocalMonitors {
22-
uint8_t tools[_PY_MONITORING_LOCAL_EVENTS];
23-
} _Py_LocalMonitors;
24-
25-
typedef struct _Py_GlobalMonitors {
26-
uint8_t tools[_PY_MONITORING_UNGROUPED_EVENTS];
27-
} _Py_GlobalMonitors;
28-
29-
3011
typedef struct {
3112
PyObject *_co_code;
3213
PyObject *_co_varnames;
3314
PyObject *_co_cellvars;
3415
PyObject *_co_freevars;
3516
} _PyCoCached;
3617

37-
/* Ancillary data structure used for instrumentation.
38-
Line instrumentation creates this with sufficient
39-
space for one entry per code unit. The total size
40-
of the data will be `bytes_per_entry * Py_SIZE(code)` */
41-
typedef struct {
42-
uint8_t bytes_per_entry;
43-
uint8_t data[1];
44-
} _PyCoLineInstrumentationData;
45-
46-
4718
typedef struct {
4819
int size;
4920
int capacity;
5021
struct _PyExecutorObject *executors[1];
5122
} _PyExecutorArray;
5223

53-
/* Main data structure used for instrumentation.
54-
* This is allocated when needed for instrumentation
55-
*/
56-
typedef struct {
57-
/* Monitoring specific to this code object */
58-
_Py_LocalMonitors local_monitors;
59-
/* Monitoring that is active on this code object */
60-
_Py_LocalMonitors active_monitors;
61-
/* The tools that are to be notified for events for the matching code unit */
62-
uint8_t *tools;
63-
/* The version of tools when they instrument the code */
64-
uintptr_t tool_versions[_PY_MONITORING_TOOL_IDS];
65-
/* Information to support line events */
66-
_PyCoLineInstrumentationData *lines;
67-
/* The tools that are to be notified for line events for the matching code unit */
68-
uint8_t *line_tools;
69-
/* Information to support instruction events */
70-
/* The underlying instructions, which can themselves be instrumented */
71-
uint8_t *per_instruction_opcodes;
72-
/* The tools that are to be notified for instruction events for the matching code unit */
73-
uint8_t *per_instruction_tools;
74-
} _PyCoMonitoringData;
7524

7625
#ifdef Py_GIL_DISABLED
7726

@@ -151,7 +100,7 @@ typedef struct {
151100
_PyExecutorArray *co_executors; /* executors from optimizer */ \
152101
_PyCoCached *_co_cached; /* cached co_* attributes */ \
153102
uintptr_t _co_instrumentation_version; /* current instrumentation version */ \
154-
_PyCoMonitoringData *_co_monitoring; /* Monitoring data */ \
103+
struct _PyCoMonitoringData *_co_monitoring; /* Monitoring data */ \
155104
Py_ssize_t _co_unique_id; /* ID used for per-thread refcounting */ \
156105
int _co_firsttraceable; /* index of first traceable instruction */ \
157106
/* Scratch space for extra data relating to the code object. \

Include/cpython/object.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,6 @@ PyAPI_FUNC(int) PyObject_VisitManagedDict(PyObject *obj, visitproc visit, void *
512512
PyAPI_FUNC(int) _PyObject_SetManagedDict(PyObject *obj, PyObject *new_dict);
513513
PyAPI_FUNC(void) PyObject_ClearManagedDict(PyObject *obj);
514514

515-
#define TYPE_MAX_WATCHERS 8
516515

517516
typedef int(*PyType_WatchCallback)(PyTypeObject *);
518517
PyAPI_FUNC(int) PyType_AddWatcher(PyType_WatchCallback callback);

Include/internal/pycore_atexit.h

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,44 +12,6 @@ extern "C" {
1212
#endif
1313

1414

15-
//###############
16-
// runtime atexit
17-
18-
typedef void (*atexit_callbackfunc)(void);
19-
20-
struct _atexit_runtime_state {
21-
PyMutex mutex;
22-
#define NEXITFUNCS 32
23-
atexit_callbackfunc callbacks[NEXITFUNCS];
24-
int ncallbacks;
25-
};
26-
27-
28-
//###################
29-
// interpreter atexit
30-
31-
typedef void (*atexit_datacallbackfunc)(void *);
32-
33-
typedef struct atexit_callback {
34-
atexit_datacallbackfunc func;
35-
void *data;
36-
struct atexit_callback *next;
37-
} atexit_callback;
38-
39-
struct atexit_state {
40-
#ifdef Py_GIL_DISABLED
41-
PyMutex ll_callbacks_lock;
42-
#endif
43-
atexit_callback *ll_callbacks;
44-
45-
// XXX The rest of the state could be moved to the atexit module state
46-
// and a low-level callback added for it during module exec.
47-
// For the moment we leave it here.
48-
49-
// List containing tuples with callback information.
50-
// e.g. [(func, args, kwargs), ...]
51-
PyObject *callbacks;
52-
};
5315

5416
#ifdef Py_GIL_DISABLED
5517
# define _PyAtExit_LockCallbacks(state) PyMutex_Lock(&state->ll_callbacks_lock);

Include/internal/pycore_backoff.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,7 @@ extern "C" {
1010
#endif
1111

1212
#include <assert.h>
13-
#include <stdbool.h>
14-
#include <stdint.h>
15-
16-
17-
typedef struct {
18-
uint16_t value_and_backoff;
19-
} _Py_BackoffCounter;
20-
13+
#include "pycore_structs.h" // _Py_BackoffCounter
2114

2215
/* 16-bit countdown counters using exponential backoff.
2316

0 commit comments

Comments
 (0)