Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f596616

Browse files
Merge branch 'main' into patch-1
2 parents cff3ab2 + f703c96 commit f596616

61 files changed

Lines changed: 1207 additions & 791 deletions

Some content is hidden

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

Doc/library/signal.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ The variables defined in the :mod:`signal` module are:
266266
.. data:: NSIG
267267

268268
One more than the number of the highest signal number.
269+
Use :func:`valid_signals` to get valid signal numbers.
269270

270271

271272
.. data:: ITIMER_REAL

Doc/library/subprocess.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,3 +1529,39 @@ runtime):
15291529

15301530
:mod:`shlex`
15311531
Module which provides function to parse and escape command lines.
1532+
1533+
1534+
.. _disable_vfork:
1535+
.. _disable_posix_spawn:
1536+
1537+
Disabling use of ``vfork()`` or ``posix_spawn()``
1538+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1539+
1540+
On Linux, :mod:`subprocess` defaults to using the ``vfork()`` system call
1541+
internally when it is safe to do so rather than ``fork()``. This greatly
1542+
improves performance.
1543+
1544+
If you ever encounter a presumed highly-unusual situation where you need to
1545+
prevent ``vfork()`` from being used by Python, you can set the
1546+
:attr:`subprocess._USE_VFORK` attribute to a false value.
1547+
1548+
subprocess._USE_VFORK = False # See CPython issue gh-NNNNNN.
1549+
1550+
Setting this has no impact on use of ``posix_spawn()`` which could use
1551+
``vfork()`` internally within its libc implementation. There is a similar
1552+
:attr:`subprocess._USE_POSIX_SPAWN` attribute if you need to prevent use of
1553+
that.
1554+
1555+
subprocess._USE_POSIX_SPAWN = False # See CPython issue gh-NNNNNN.
1556+
1557+
It is safe to set these to false on any Python version. They will have no
1558+
effect on older versions when unsupported. Do not assume the attributes are
1559+
available to read. Despite their names, a true value does not indicate that the
1560+
corresponding function will be used, only that that it may be.
1561+
1562+
Please file issues any time you have to use these private knobs with a way to
1563+
reproduce the issue you were seeing. Link to that issue from a comment in your
1564+
code.
1565+
1566+
.. versionadded:: 3.8 ``_USE_POSIX_SPAWN``
1567+
.. versionadded:: 3.11 ``_USE_VFORK``

Doc/whatsnew/3.11.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,8 @@ Deprecated
10681068
* :mod:`pipes`
10691069
* :mod:`sndhdr`
10701070
* :mod:`spwd`
1071+
* :mod:`sunau`
1072+
* :mod:`telnetlib`
10711073

10721074
(Contributed by Brett Cannon in :issue:`47061`.)
10731075

Include/cpython/unicodeobject.h

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,18 @@ PyAPI_FUNC(int) _PyUnicode_CheckConsistency(
256256
static inline unsigned int PyUnicode_CHECK_INTERNED(PyObject *op) {
257257
return _PyASCIIObject_CAST(op)->state.interned;
258258
}
259-
#define PyUnicode_CHECK_INTERNED(op) PyUnicode_CHECK_INTERNED(_PyObject_CAST(op))
259+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
260+
# define PyUnicode_CHECK_INTERNED(op) PyUnicode_CHECK_INTERNED(_PyObject_CAST(op))
261+
#endif
260262

261263
/* Fast check to determine whether an object is ready. Equivalent to:
262264
PyUnicode_IS_COMPACT(op) || _PyUnicodeObject_CAST(op)->data.any */
263265
static inline unsigned int PyUnicode_IS_READY(PyObject *op) {
264266
return _PyASCIIObject_CAST(op)->state.ready;
265267
}
266-
#define PyUnicode_IS_READY(op) PyUnicode_IS_READY(_PyObject_CAST(op))
268+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
269+
# define PyUnicode_IS_READY(op) PyUnicode_IS_READY(_PyObject_CAST(op))
270+
#endif
267271

268272
/* Return true if the string contains only ASCII characters, or 0 if not. The
269273
string may be compact (PyUnicode_IS_COMPACT_ASCII) or not, but must be
@@ -272,21 +276,27 @@ static inline unsigned int PyUnicode_IS_ASCII(PyObject *op) {
272276
assert(PyUnicode_IS_READY(op));
273277
return _PyASCIIObject_CAST(op)->state.ascii;
274278
}
275-
#define PyUnicode_IS_ASCII(op) PyUnicode_IS_ASCII(_PyObject_CAST(op))
279+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
280+
# define PyUnicode_IS_ASCII(op) PyUnicode_IS_ASCII(_PyObject_CAST(op))
281+
#endif
276282

277283
/* Return true if the string is compact or 0 if not.
278284
No type checks or Ready calls are performed. */
279285
static inline unsigned int PyUnicode_IS_COMPACT(PyObject *op) {
280286
return _PyASCIIObject_CAST(op)->state.compact;
281287
}
282-
#define PyUnicode_IS_COMPACT(op) PyUnicode_IS_COMPACT(_PyObject_CAST(op))
288+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
289+
# define PyUnicode_IS_COMPACT(op) PyUnicode_IS_COMPACT(_PyObject_CAST(op))
290+
#endif
283291

284292
/* Return true if the string is a compact ASCII string (use PyASCIIObject
285293
structure), or 0 if not. No type checks or Ready calls are performed. */
286294
static inline int PyUnicode_IS_COMPACT_ASCII(PyObject *op) {
287295
return (_PyASCIIObject_CAST(op)->state.ascii && PyUnicode_IS_COMPACT(op));
288296
}
289-
#define PyUnicode_IS_COMPACT_ASCII(op) PyUnicode_IS_COMPACT_ASCII(_PyObject_CAST(op))
297+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
298+
# define PyUnicode_IS_COMPACT_ASCII(op) PyUnicode_IS_COMPACT_ASCII(_PyObject_CAST(op))
299+
#endif
290300

291301
enum PyUnicode_Kind {
292302
/* String contains only wstr byte characters. This is only possible
@@ -326,7 +336,9 @@ static inline void* PyUnicode_DATA(PyObject *op) {
326336
}
327337
return _PyUnicode_NONCOMPACT_DATA(op);
328338
}
329-
#define PyUnicode_DATA(op) PyUnicode_DATA(_PyObject_CAST(op))
339+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
340+
# define PyUnicode_DATA(op) PyUnicode_DATA(_PyObject_CAST(op))
341+
#endif
330342

331343
/* Return pointers to the canonical representation cast to unsigned char,
332344
Py_UCS2, or Py_UCS4 for direct character access.
@@ -344,7 +356,9 @@ static inline Py_ssize_t PyUnicode_GET_LENGTH(PyObject *op) {
344356
assert(PyUnicode_IS_READY(op));
345357
return _PyASCIIObject_CAST(op)->length;
346358
}
347-
#define PyUnicode_GET_LENGTH(op) PyUnicode_GET_LENGTH(_PyObject_CAST(op))
359+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
360+
# define PyUnicode_GET_LENGTH(op) PyUnicode_GET_LENGTH(_PyObject_CAST(op))
361+
#endif
348362

349363
/* Write into the canonical representation, this function does not do any sanity
350364
checks and is intended for usage in loops. The caller should cache the
@@ -405,8 +419,10 @@ static inline Py_UCS4 PyUnicode_READ_CHAR(PyObject *unicode, Py_ssize_t index)
405419
assert(kind == PyUnicode_4BYTE_KIND);
406420
return PyUnicode_4BYTE_DATA(unicode)[index];
407421
}
408-
#define PyUnicode_READ_CHAR(unicode, index) \
409-
PyUnicode_READ_CHAR(_PyObject_CAST(unicode), (index))
422+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
423+
# define PyUnicode_READ_CHAR(unicode, index) \
424+
PyUnicode_READ_CHAR(_PyObject_CAST(unicode), (index))
425+
#endif
410426

411427
/* Return a maximum character value which is suitable for creating another
412428
string based on op. This is always an approximation but more efficient
@@ -428,8 +444,10 @@ static inline Py_UCS4 PyUnicode_MAX_CHAR_VALUE(PyObject *op)
428444
assert(kind == PyUnicode_4BYTE_KIND);
429445
return 0x10ffffU;
430446
}
431-
#define PyUnicode_MAX_CHAR_VALUE(op) \
432-
PyUnicode_MAX_CHAR_VALUE(_PyObject_CAST(op))
447+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
448+
# define PyUnicode_MAX_CHAR_VALUE(op) \
449+
PyUnicode_MAX_CHAR_VALUE(_PyObject_CAST(op))
450+
#endif
433451

434452
/* === Public API ========================================================= */
435453

@@ -465,7 +483,9 @@ static inline int PyUnicode_READY(PyObject *op)
465483
}
466484
return _PyUnicode_Ready(op);
467485
}
468-
#define PyUnicode_READY(op) PyUnicode_READY(_PyObject_CAST(op))
486+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
487+
# define PyUnicode_READY(op) PyUnicode_READY(_PyObject_CAST(op))
488+
#endif
469489

470490
/* Get a copy of a Unicode string. */
471491
PyAPI_FUNC(PyObject*) _PyUnicode_Copy(
@@ -606,7 +626,9 @@ static inline Py_ssize_t PyUnicode_WSTR_LENGTH(PyObject *op)
606626
return _PyCompactUnicodeObject_CAST(op)->wstr_length;
607627
}
608628
}
609-
#define PyUnicode_WSTR_LENGTH(op) PyUnicode_WSTR_LENGTH(_PyObject_CAST(op))
629+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
630+
# define PyUnicode_WSTR_LENGTH(op) PyUnicode_WSTR_LENGTH(_PyObject_CAST(op))
631+
#endif
610632

611633
/* Returns the deprecated Py_UNICODE representation's size in code units
612634
(this includes surrogate pairs as 2 units).
@@ -625,7 +647,9 @@ static inline Py_ssize_t PyUnicode_GET_SIZE(PyObject *op)
625647
return PyUnicode_WSTR_LENGTH(op);
626648
_Py_COMP_DIAG_POP
627649
}
628-
#define PyUnicode_GET_SIZE(op) PyUnicode_GET_SIZE(_PyObject_CAST(op))
650+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
651+
# define PyUnicode_GET_SIZE(op) PyUnicode_GET_SIZE(_PyObject_CAST(op))
652+
#endif
629653

630654
Py_DEPRECATED(3.3)
631655
static inline Py_ssize_t PyUnicode_GET_DATA_SIZE(PyObject *op)
@@ -635,7 +659,9 @@ static inline Py_ssize_t PyUnicode_GET_DATA_SIZE(PyObject *op)
635659
return PyUnicode_GET_SIZE(op) * Py_UNICODE_SIZE;
636660
_Py_COMP_DIAG_POP
637661
}
638-
#define PyUnicode_GET_DATA_SIZE(op) PyUnicode_GET_DATA_SIZE(_PyObject_CAST(op))
662+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
663+
# define PyUnicode_GET_DATA_SIZE(op) PyUnicode_GET_DATA_SIZE(_PyObject_CAST(op))
664+
#endif
639665

640666
/* Alias for PyUnicode_AsUnicode(). This will create a wchar_t/Py_UNICODE
641667
representation on demand. Using this macro is very inefficient now,
@@ -655,7 +681,9 @@ static inline Py_UNICODE* PyUnicode_AS_UNICODE(PyObject *op)
655681
return PyUnicode_AsUnicode(op);
656682
_Py_COMP_DIAG_POP
657683
}
658-
#define PyUnicode_AS_UNICODE(op) PyUnicode_AS_UNICODE(_PyObject_CAST(op))
684+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
685+
# define PyUnicode_AS_UNICODE(op) PyUnicode_AS_UNICODE(_PyObject_CAST(op))
686+
#endif
659687

660688
Py_DEPRECATED(3.3)
661689
static inline const char* PyUnicode_AS_DATA(PyObject *op)
@@ -665,7 +693,9 @@ static inline const char* PyUnicode_AS_DATA(PyObject *op)
665693
return (const char *)PyUnicode_AS_UNICODE(op);
666694
_Py_COMP_DIAG_POP
667695
}
668-
#define PyUnicode_AS_DATA(op) PyUnicode_AS_DATA(_PyObject_CAST(op))
696+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
697+
# define PyUnicode_AS_DATA(op) PyUnicode_AS_DATA(_PyObject_CAST(op))
698+
#endif
669699

670700

671701
/* --- _PyUnicodeWriter API ----------------------------------------------- */

0 commit comments

Comments
 (0)