Skip to content

Commit 0a19f34

Browse files
Merge remote-tracking branch 'upstream/master' into pep612
2 parents d09d088 + f5e97b7 commit 0a19f34

File tree

77 files changed

+5906
-4706
lines changed

Some content is hidden

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

77 files changed

+5906
-4706
lines changed

Doc/library/enum.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,12 @@ helper, :class:`auto`.
6767

6868
.. class:: auto
6969

70-
Instances are replaced with an appropriate value for Enum members. By default, the initial value starts at 1.
70+
Instances are replaced with an appropriate value for Enum members.
71+
:class:`StrEnum` defaults to the lower-cased version of the member name,
72+
while other Enums default to 1 and increase from there.
7173

7274
.. versionadded:: 3.6 ``Flag``, ``IntFlag``, ``auto``
73-
75+
.. versionadded:: 3.10 ``StrEnum``
7476

7577
Creating an Enum
7678
----------------
@@ -1164,6 +1166,15 @@ and raise an error if the two do not match::
11641166
In Python 2 code the :attr:`_order_` attribute is necessary as definition
11651167
order is lost before it can be recorded.
11661168

1169+
1170+
_Private__names
1171+
"""""""""""""""
1172+
1173+
Private names are not converted to Enum members, but remain normal attributes.
1174+
1175+
.. versionchanged:: 3.10
1176+
1177+
11671178
``Enum`` member type
11681179
""""""""""""""""""""
11691180

Doc/library/logging.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,8 +1096,8 @@ functions.
10961096
suitable value.
10971097

10981098
.. versionchanged:: 3.7
1099-
The *level* parameter was defaulted to level ``CRITICAL``. See Issue
1100-
#28524 for more information about this change.
1099+
The *level* parameter was defaulted to level ``CRITICAL``. See
1100+
:issue:`28524` for more information about this change.
11011101

11021102
.. function:: addLevelName(level, levelName)
11031103

@@ -1174,7 +1174,9 @@ functions.
11741174
| | to ``'a'``. |
11751175
+--------------+---------------------------------------------+
11761176
| *format* | Use the specified format string for the |
1177-
| | handler. |
1177+
| | handler. Defaults to attributes |
1178+
| | ``levelname``, ``name`` and ``message`` |
1179+
| | separated by colons. |
11781180
+--------------+---------------------------------------------+
11791181
| *datefmt* | Use the specified date/time format, as |
11801182
| | accepted by :func:`time.strftime`. |

Doc/library/subprocess.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,7 @@ be used directly:
12811281
12821282
becomes::
12831283

1284-
output=check_output("dmesg | grep hda", shell=True)
1284+
output = check_output("dmesg | grep hda", shell=True)
12851285

12861286

12871287
Replacing :func:`os.system`

Doc/library/unittest.mock.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,10 @@ the *new_callable* argument to :func:`patch`.
262262
this is a new Mock (created on first access). See the
263263
:attr:`return_value` attribute.
264264

265-
* *unsafe*: By default if any attribute starts with *assert* or
266-
*assret* will raise an :exc:`AttributeError`. Passing ``unsafe=True``
267-
will allow access to these attributes.
265+
* *unsafe*: By default, accessing any attribute with name starting with
266+
*assert*, *assret*, *asert*, *aseert* or *assrt* will raise an
267+
:exc:`AttributeError`. Passing ``unsafe=True`` will allow access to
268+
these attributes.
268269

269270
.. versionadded:: 3.5
270271

Doc/reference/compound_stmts.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -796,12 +796,12 @@ The :keyword:`!async for` statement
796796
.. productionlist:: python-grammar
797797
async_for_stmt: "async" `for_stmt`
798798

799-
An :term:`asynchronous iterable` is able to call asynchronous code in its
800-
*iter* implementation, and :term:`asynchronous iterator` can call asynchronous
801-
code in its *next* method.
799+
An :term:`asynchronous iterable` provides an ``__aiter__`` method that directly
800+
returns an :term:`asynchronous iterator`, which can call asynchronous code in
801+
its ``__anext__`` method.
802802

803803
The ``async for`` statement allows convenient iteration over asynchronous
804-
iterators.
804+
iterables.
805805

806806
The following code::
807807

Doc/whatsnew/3.10.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,11 @@ Removed
480480
into their code.
481481
(Contributed by Dong-hee Na and Terry J. Reedy in :issue:`42299`.)
482482

483+
* Removed the :c:func:`PyModule_GetWarningsModule` function that was useless
484+
now due to the _warnings module was converted to a builtin module in 2.6.
485+
(Contributed by Hai Shi in :issue:`42599`.)
486+
487+
483488
Porting to Python 3.10
484489
======================
485490

Grammar/python.gram

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ invalid_arguments:
646646
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "Generator expression must be parenthesized") }
647647
| a=args ',' args { _PyPegen_arguments_parsing_error(p, a) }
648648
invalid_kwarg:
649-
| a=expression '=' {
649+
| expression a='=' {
650650
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(
651651
a, "expression cannot contain assignment, perhaps you meant \"==\"?") }
652652
invalid_named_expression:

Include/cpython/fileutils.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,6 @@ PyAPI_FUNC(FILE *) _Py_wfopen(
9595
const wchar_t *path,
9696
const wchar_t *mode);
9797

98-
PyAPI_FUNC(FILE*) _Py_fopen(
99-
const char *pathname,
100-
const char *mode);
101-
10298
PyAPI_FUNC(FILE*) _Py_fopen_obj(
10399
PyObject *path,
104100
const char *mode);

Include/cpython/pylifecycle.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ PyAPI_FUNC(void) _Py_PyAtExit(void (*func)(PyObject *), PyObject *);
4444
PyAPI_FUNC(void) _Py_RestoreSignals(void);
4545

4646
PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *);
47+
PyAPI_FUNC(int) _Py_FdIsInteractive(FILE *fp, PyObject *filename);
4748

4849
PyAPI_FUNC(void) _Py_SetProgramFullPath(const wchar_t *);
4950

Include/cpython/pythonrun.h

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
#ifndef Py_CPYTHON_PYTHONRUN_H
2+
# error "this header file must not be included directly"
3+
#endif
4+
5+
PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *);
6+
PyAPI_FUNC(int) _PyRun_SimpleFileObject(
7+
FILE *fp,
8+
PyObject *filename,
9+
int closeit,
10+
PyCompilerFlags *flags);
11+
PyAPI_FUNC(int) PyRun_AnyFileExFlags(
12+
FILE *fp,
13+
const char *filename, /* decoded from the filesystem encoding */
14+
int closeit,
15+
PyCompilerFlags *flags);
16+
PyAPI_FUNC(int) _PyRun_AnyFileObject(
17+
FILE *fp,
18+
PyObject *filename,
19+
int closeit,
20+
PyCompilerFlags *flags);
21+
PyAPI_FUNC(int) PyRun_SimpleFileExFlags(
22+
FILE *fp,
23+
const char *filename, /* decoded from the filesystem encoding */
24+
int closeit,
25+
PyCompilerFlags *flags);
26+
PyAPI_FUNC(int) PyRun_InteractiveOneFlags(
27+
FILE *fp,
28+
const char *filename, /* decoded from the filesystem encoding */
29+
PyCompilerFlags *flags);
30+
PyAPI_FUNC(int) PyRun_InteractiveOneObject(
31+
FILE *fp,
32+
PyObject *filename,
33+
PyCompilerFlags *flags);
34+
PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(
35+
FILE *fp,
36+
const char *filename, /* decoded from the filesystem encoding */
37+
PyCompilerFlags *flags);
38+
PyAPI_FUNC(int) _PyRun_InteractiveLoopObject(
39+
FILE *fp,
40+
PyObject *filename,
41+
PyCompilerFlags *flags);
42+
43+
44+
PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *,
45+
PyObject *, PyCompilerFlags *);
46+
47+
PyAPI_FUNC(PyObject *) PyRun_FileExFlags(
48+
FILE *fp,
49+
const char *filename, /* decoded from the filesystem encoding */
50+
int start,
51+
PyObject *globals,
52+
PyObject *locals,
53+
int closeit,
54+
PyCompilerFlags *flags);
55+
56+
57+
PyAPI_FUNC(PyObject *) Py_CompileStringExFlags(
58+
const char *str,
59+
const char *filename, /* decoded from the filesystem encoding */
60+
int start,
61+
PyCompilerFlags *flags,
62+
int optimize);
63+
PyAPI_FUNC(PyObject *) Py_CompileStringObject(
64+
const char *str,
65+
PyObject *filename, int start,
66+
PyCompilerFlags *flags,
67+
int optimize);
68+
69+
#define Py_CompileString(str, p, s) Py_CompileStringExFlags(str, p, s, NULL, -1)
70+
#define Py_CompileStringFlags(str, p, s, f) Py_CompileStringExFlags(str, p, s, f, -1)
71+
72+
73+
PyAPI_FUNC(const char *) _Py_SourceAsString(
74+
PyObject *cmd,
75+
const char *funcname,
76+
const char *what,
77+
PyCompilerFlags *cf,
78+
PyObject **cmd_copy);
79+
80+
PyAPI_FUNC(struct symtable *) Py_SymtableStringObject(
81+
const char *str,
82+
PyObject *filename,
83+
int start);
84+
85+
PyAPI_FUNC(struct symtable *) _Py_SymtableStringObjectFlags(
86+
const char *str,
87+
PyObject *filename,
88+
int start,
89+
PyCompilerFlags *flags);
90+
91+
92+
/* A function flavor is also exported by libpython. It is required when
93+
libpython is accessed directly rather than using header files which defines
94+
macros below. On Windows, for example, PyAPI_FUNC() uses dllexport to
95+
export functions in pythonXX.dll. */
96+
PyAPI_FUNC(PyObject *) PyRun_String(const char *str, int s, PyObject *g, PyObject *l);
97+
PyAPI_FUNC(int) PyRun_AnyFile(FILE *fp, const char *name);
98+
PyAPI_FUNC(int) PyRun_AnyFileEx(FILE *fp, const char *name, int closeit);
99+
PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *);
100+
PyAPI_FUNC(int) PyRun_SimpleString(const char *s);
101+
PyAPI_FUNC(int) PyRun_SimpleFile(FILE *f, const char *p);
102+
PyAPI_FUNC(int) PyRun_SimpleFileEx(FILE *f, const char *p, int c);
103+
PyAPI_FUNC(int) PyRun_InteractiveOne(FILE *f, const char *p);
104+
PyAPI_FUNC(int) PyRun_InteractiveLoop(FILE *f, const char *p);
105+
PyAPI_FUNC(PyObject *) PyRun_File(FILE *fp, const char *p, int s, PyObject *g, PyObject *l);
106+
PyAPI_FUNC(PyObject *) PyRun_FileEx(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, int c);
107+
PyAPI_FUNC(PyObject *) PyRun_FileFlags(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, PyCompilerFlags *flags);
108+
109+
/* Use macros for a bunch of old variants */
110+
#define PyRun_String(str, s, g, l) PyRun_StringFlags(str, s, g, l, NULL)
111+
#define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags(fp, name, 0, NULL)
112+
#define PyRun_AnyFileEx(fp, name, closeit) \
113+
PyRun_AnyFileExFlags(fp, name, closeit, NULL)
114+
#define PyRun_AnyFileFlags(fp, name, flags) \
115+
PyRun_AnyFileExFlags(fp, name, 0, flags)
116+
#define PyRun_SimpleString(s) PyRun_SimpleStringFlags(s, NULL)
117+
#define PyRun_SimpleFile(f, p) PyRun_SimpleFileExFlags(f, p, 0, NULL)
118+
#define PyRun_SimpleFileEx(f, p, c) PyRun_SimpleFileExFlags(f, p, c, NULL)
119+
#define PyRun_InteractiveOne(f, p) PyRun_InteractiveOneFlags(f, p, NULL)
120+
#define PyRun_InteractiveLoop(f, p) PyRun_InteractiveLoopFlags(f, p, NULL)
121+
#define PyRun_File(fp, p, s, g, l) \
122+
PyRun_FileExFlags(fp, p, s, g, l, 0, NULL)
123+
#define PyRun_FileEx(fp, p, s, g, l, c) \
124+
PyRun_FileExFlags(fp, p, s, g, l, c, NULL)
125+
#define PyRun_FileFlags(fp, p, s, g, l, flags) \
126+
PyRun_FileExFlags(fp, p, s, g, l, 0, flags)
127+
128+
129+
/* Stuff with no proper home (yet) */
130+
PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, const char *);
131+
PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState;

Include/pylifecycle.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ PyAPI_FUNC(void) _Py_NO_RETURN Py_Exit(int);
3232
/* Bootstrap __main__ (defined in Modules/main.c) */
3333
PyAPI_FUNC(int) Py_Main(int argc, wchar_t **argv);
3434

35+
PyAPI_FUNC(int) Py_FrozenMain(int argc, char **argv);
36+
3537
PyAPI_FUNC(int) Py_BytesMain(int argc, char **argv);
3638

3739
/* In pathconfig.c */

0 commit comments

Comments
 (0)