Skip to content

Commit b091d97

Browse files
Merge branch 'main' into typing-subst-unpacked-vat-tuple
2 parents 7dcf277 + 6f8367d commit b091d97

Some content is hidden

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

58 files changed

+781
-302
lines changed

Doc/library/dis.rst

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77
**Source code:** :source:`Lib/dis.py`
88

9+
.. testsetup::
10+
11+
import dis
12+
def myfunc(alist):
13+
return len(alist)
14+
915
--------------
1016

1117
The :mod:`dis` module supports the analysis of CPython :term:`bytecode` by
@@ -37,16 +43,17 @@ Example: Given the function :func:`myfunc`::
3743
return len(alist)
3844

3945
the following command can be used to display the disassembly of
40-
:func:`myfunc`::
46+
:func:`myfunc`:
4147

42-
>>> dis.dis(myfunc)
43-
1 0 RESUME 0
48+
.. doctest::
4449

45-
2 2 PUSH_NULL
46-
4 LOAD_GLOBAL 1 (NULL + len)
47-
6 LOAD_FAST 0 (alist)
48-
8 CALL 1
49-
18 RETURN_VALUE
50+
>>> dis.dis(myfunc)
51+
2 0 RESUME 0
52+
<BLANKLINE>
53+
3 2 LOAD_GLOBAL 1 (NULL + len)
54+
14 LOAD_FAST 0 (alist)
55+
16 CALL 1
56+
26 RETURN_VALUE
5057

5158
(The "2" is a line number).
5259

@@ -108,14 +115,15 @@ code.
108115
.. versionchanged:: 3.11
109116
Added the ``show_caches`` parameter.
110117

111-
Example::
118+
Example:
119+
120+
.. doctest::
112121

113122
>>> bytecode = dis.Bytecode(myfunc)
114123
>>> for instr in bytecode:
115124
... print(instr.opname)
116125
...
117126
RESUME
118-
PUSH_NULL
119127
LOAD_GLOBAL
120128
LOAD_FAST
121129
CALL

Doc/library/mailcap.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ standard. However, mailcap files are supported on most Unix systems.
6060
use) to determine whether or not the mailcap line applies. :func:`findmatch`
6161
will automatically check such conditions and skip the entry if the check fails.
6262

63+
.. versionchanged:: 3.11
64+
65+
To prevent security issues with shell metacharacters (symbols that have
66+
special effects in a shell command line), ``findmatch`` will refuse
67+
to inject ASCII characters other than alphanumerics and ``@+=:,./-_``
68+
into the returned command line.
69+
70+
If a disallowed character appears in *filename*, ``findmatch`` will always
71+
return ``(None, None)`` as if no entry was found.
72+
If such a character appears elsewhere (a value in *plist* or in *MIMEtype*),
73+
``findmatch`` will ignore all mailcap entries which use that value.
74+
A :mod:`warning <warnings>` will be raised in either case.
6375

6476
.. function:: getcaps()
6577

Doc/using/cmdline.rst

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,37 @@ automatically enabled, if available on your platform (see
183183
Automatic enabling of tab-completion and history editing.
184184

185185

186+
.. _using-on-generic-options:
187+
186188
Generic options
187189
~~~~~~~~~~~~~~~
188190

189191
.. cmdoption:: -?
190192
-h
191193
--help
192194

193-
Print a short description of all command line options.
195+
Print a short description of all command line options and corresponding
196+
environment variables and exit.
197+
198+
.. cmdoption:: --help-env
199+
200+
Print a short description of Python-specific environment variables
201+
and exit.
202+
203+
.. versionadded:: 3.11
204+
205+
.. cmdoption:: --help-xoptions
194206

207+
Print a description of implementation-specific :option:`-X` options
208+
and exit.
209+
210+
.. versionadded:: 3.11
211+
212+
.. cmdoption:: --help-all
213+
214+
Print complete usage information and exit.
215+
216+
.. versionadded:: 3.11
195217

196218
.. cmdoption:: -V
197219
--version
@@ -212,6 +234,7 @@ Generic options
212234
.. versionadded:: 3.6
213235
The ``-VV`` option.
214236

237+
215238
.. _using-on-misc-options:
216239

217240
Miscellaneous options
@@ -460,6 +483,7 @@ Miscellaneous options
460483
See :ref:`warning-filter` and :ref:`describing-warning-filters` for more
461484
details.
462485

486+
463487
.. cmdoption:: -x
464488

465489
Skip the first line of the source, allowing use of non-Unix forms of
@@ -553,6 +577,7 @@ Miscellaneous options
553577
The ``-X frozen_modules`` option.
554578

555579

580+
556581
Options you shouldn't use
557582
~~~~~~~~~~~~~~~~~~~~~~~~~
558583

Include/boolobject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ PyAPI_DATA(PyLongObject) _Py_FalseStruct;
1919
PyAPI_DATA(PyLongObject) _Py_TrueStruct;
2020

2121
/* Use these macros */
22-
#define Py_False ((PyObject *) &_Py_FalseStruct)
23-
#define Py_True ((PyObject *) &_Py_TrueStruct)
22+
#define Py_False _PyObject_CAST(&_Py_FalseStruct)
23+
#define Py_True _PyObject_CAST(&_Py_TrueStruct)
2424

2525
// Test if an object is the True singleton, the same as "x is True" in Python.
2626
PyAPI_FUNC(int) Py_IsTrue(PyObject *x);

Include/ceval.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords(
3131

3232
/* Deprecated since PyEval_CallObjectWithKeywords is deprecated */
3333
#define PyEval_CallObject(callable, arg) \
34-
PyEval_CallObjectWithKeywords(callable, arg, (PyObject *)NULL)
34+
PyEval_CallObjectWithKeywords(callable, arg, _PyObject_CAST(_Py_NULL))
3535

3636
Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallFunction(
3737
PyObject *callable, const char *format, ...);

Include/cpython/code.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ typedef uint16_t _Py_CODEUNIT;
8888
PyObject *co_qualname; /* unicode (qualname, for reference) */ \
8989
PyObject *co_linetable; /* bytes object that holds location info */ \
9090
PyObject *co_weakreflist; /* to support weakrefs to code objects */ \
91+
void *_co_code; /* cached co_code object/attribute */ \
9192
/* Scratch space for extra data relating to the code object. \
9293
Type is a void* to keep the format private in codeobject.c to force \
9394
people to go through the proper APIs. */ \

Include/pyerrors.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ PyAPI_FUNC(void) PyException_SetContext(PyObject *, PyObject *);
6262

6363
PyAPI_FUNC(const char *) PyExceptionClass_Name(PyObject *);
6464

65-
#define PyExceptionInstance_Class(x) ((PyObject*)Py_TYPE(x))
65+
#define PyExceptionInstance_Class(x) _PyObject_CAST(Py_TYPE(x))
6666

6767
#define _PyBaseExceptionGroup_Check(x) \
6868
PyObject_TypeCheck(x, (PyTypeObject *)PyExc_BaseExceptionGroup)

Include/pyport.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,23 @@
2424
//
2525
// The type argument must not be a constant type.
2626
#ifdef __cplusplus
27+
#include <cstddef>
2728
# define _Py_STATIC_CAST(type, expr) static_cast<type>(expr)
2829
extern "C++" {
2930
namespace {
31+
template <typename type>
32+
inline type _Py_CAST_impl(long int ptr) {
33+
return reinterpret_cast<type>(ptr);
34+
}
35+
template <typename type>
36+
inline type _Py_CAST_impl(int ptr) {
37+
return reinterpret_cast<type>(ptr);
38+
}
39+
template <typename type>
40+
inline type _Py_CAST_impl(std::nullptr_t) {
41+
return static_cast<type>(nullptr);
42+
}
43+
3044
template <typename type, typename expr_type>
3145
inline type _Py_CAST_impl(expr_type *expr) {
3246
return reinterpret_cast<type>(expr);

Lib/dis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ def _unpack_opargs(code):
592592
caches = _inline_cache_entries[deop]
593593
if deop >= HAVE_ARGUMENT:
594594
arg = code[i+1] | extended_arg
595-
extended_arg = (arg << 8) if op == EXTENDED_ARG else 0
595+
extended_arg = (arg << 8) if deop == EXTENDED_ARG else 0
596596
# The oparg is stored as a signed integer
597597
# If the value exceeds its upper limit, it will overflow and wrap
598598
# to a negative integer

Lib/logging/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1498,7 +1498,7 @@ def info(self, msg, *args, **kwargs):
14981498
To pass exception information, use the keyword argument exc_info with
14991499
a true value, e.g.
15001500
1501-
logger.info("Houston, we have a %s", "interesting problem", exc_info=1)
1501+
logger.info("Houston, we have a %s", "notable problem", exc_info=1)
15021502
"""
15031503
if self.isEnabledFor(INFO):
15041504
self._log(INFO, msg, args, **kwargs)

0 commit comments

Comments
 (0)