Skip to content

Commit 06db319

Browse files
committed
Merge branch 'main' into inlinecomp2
* main: pythongh-102304: Consolidate Direct Usage of _Py_RefTotal (pythongh-102514) pythongh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives (in Objects/) (python#102218) pythongh-102507 Remove invisible pagebreak characters (python#102531) pythongh-102515: Remove unused imports in the `Lib/` directory (python#102516) Remove or update bitbucket links (pythonGH-101963) pythongh-101100: Fix sphinx warnings in `zipapp` and `zipfile` modules (python#102526) pythonGH-102397: Fix segfault from race condition in signal handling (python#102399) Fix style in argparse.rst (python#101733) Post 3.12.0a6 fix typo in async generator code field name `ag_code` (python#102448) Python 3.12.0a6
2 parents 90b34de + cbb0aa7 commit 06db319

File tree

160 files changed

+1089
-482
lines changed

Some content is hidden

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

160 files changed

+1089
-482
lines changed

Doc/distributing/index.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ Key terms
3939
developers and documentation authors responsible for the maintenance and
4040
evolution of the standard packaging tools and the associated metadata and
4141
file format standards. They maintain a variety of tools, documentation
42-
and issue trackers on both `GitHub <https://github.com/pypa>`__ and
43-
`Bitbucket <https://bitbucket.org/pypa/>`__.
42+
and issue trackers on `GitHub <https://github.com/pypa>`__.
4443
* ``distutils`` is the original build and distribution system first added
4544
to the Python standard library in 1998. While direct use of ``distutils``
4645
is being phased out, it still laid the foundation for the current packaging

Doc/installing/index.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ Key terms
5252
developers and documentation authors responsible for the maintenance and
5353
evolution of the standard packaging tools and the associated metadata and
5454
file format standards. They maintain a variety of tools, documentation,
55-
and issue trackers on both `GitHub <https://github.com/pypa>`__ and
56-
`Bitbucket <https://bitbucket.org/pypa/>`__.
55+
and issue trackers on `GitHub <https://github.com/pypa>`__.
5756
* ``distutils`` is the original build and distribution system first added to
5857
the Python standard library in 1998. While direct use of ``distutils`` is
5958
being phased out, it still laid the foundation for the current packaging

Doc/library/argparse.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ around an instance of :class:`argparse.ArgumentParser`. It is a container for
3434
argument specifications and has options that apply to the parser as whole::
3535

3636
parser = argparse.ArgumentParser(
37-
prog = 'ProgramName',
38-
description = 'What the program does',
39-
epilog = 'Text at the bottom of help')
37+
prog='ProgramName',
38+
description='What the program does',
39+
epilog='Text at the bottom of help')
4040

4141
The :meth:`ArgumentParser.add_argument` method attaches individual argument
4242
specifications to the parser. It supports positional arguments, options that

Doc/library/venv.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ subclass which installs setuptools and pip into a created virtual environment::
478478
:param context: The information for the virtual environment
479479
creation request being processed.
480480
"""
481-
url = 'https://bitbucket.org/pypa/setuptools/downloads/ez_setup.py'
481+
url = "https://bootstrap.pypa.io/ez_setup.py"
482482
self.install_script(context, 'setuptools', url)
483483
# clear up the setuptools archive which gets downloaded
484484
pred = lambda o: o.startswith('setuptools-') and o.endswith('.tar.gz')

Doc/library/zipapp.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ using the :func:`create_archive` function::
215215
>>> import zipapp
216216
>>> zipapp.create_archive('old_archive.pyz', 'new_archive.pyz', '/usr/bin/python3')
217217

218-
To update the file in place, do the replacement in memory using a :class:`BytesIO`
218+
To update the file in place, do the replacement in memory using a :class:`~io.BytesIO`
219219
object, and then overwrite the source afterwards. Note that there is a risk
220220
when overwriting a file in place that an error will result in the loss of
221221
the original file. This code does not protect against such errors, but

Doc/library/zipfile.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ ZipFile Objects
288288
(``ZipExtFile``) is read-only and provides the following methods:
289289
:meth:`~io.BufferedIOBase.read`, :meth:`~io.IOBase.readline`,
290290
:meth:`~io.IOBase.readlines`, :meth:`~io.IOBase.seek`,
291-
:meth:`~io.IOBase.tell`, :meth:`__iter__`, :meth:`~iterator.__next__`.
291+
:meth:`~io.IOBase.tell`, :meth:`~container.__iter__`, :meth:`~iterator.__next__`.
292292
These objects can operate independently of the ZipFile.
293293

294294
With ``mode='w'``, a writable file handle is returned, which supports the

Include/cpython/object.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#endif
44

55
PyAPI_FUNC(void) _Py_NewReference(PyObject *op);
6+
PyAPI_FUNC(void) _Py_NewReferenceNoTotal(PyObject *op);
67

78
#ifdef Py_TRACE_REFS
89
/* Py_TRACE_REFS is such major surgery that we call external routines. */

Include/internal/pycore_object.h

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,23 @@ PyAPI_FUNC(void) _Py_NO_RETURN _Py_FatalRefcountErrorFunc(
3737
#define _Py_FatalRefcountError(message) \
3838
_Py_FatalRefcountErrorFunc(__func__, (message))
3939

40+
41+
#ifdef Py_REF_DEBUG
42+
/* The symbol is only exposed in the API for the sake of extensions
43+
built against the pre-3.12 stable ABI. */
44+
PyAPI_DATA(Py_ssize_t) _Py_RefTotal;
45+
46+
extern void _Py_AddRefTotal(Py_ssize_t);
47+
extern void _Py_IncRefTotal(void);
48+
extern void _Py_DecRefTotal(void);
49+
# define _Py_DEC_REFTOTAL() _Py_RefTotal--
50+
#endif
51+
4052
// Increment reference count by n
4153
static inline void _Py_RefcntAdd(PyObject* op, Py_ssize_t n)
4254
{
4355
#ifdef Py_REF_DEBUG
44-
_Py_RefTotal += n;
56+
_Py_AddRefTotal(n);
4557
#endif
4658
op->ob_refcnt += n;
4759
}
@@ -52,7 +64,7 @@ _Py_DECREF_SPECIALIZED(PyObject *op, const destructor destruct)
5264
{
5365
_Py_DECREF_STAT_INC();
5466
#ifdef Py_REF_DEBUG
55-
_Py_RefTotal--;
67+
_Py_DEC_REFTOTAL();
5668
#endif
5769
if (--op->ob_refcnt != 0) {
5870
assert(op->ob_refcnt > 0);
@@ -70,7 +82,7 @@ _Py_DECREF_NO_DEALLOC(PyObject *op)
7082
{
7183
_Py_DECREF_STAT_INC();
7284
#ifdef Py_REF_DEBUG
73-
_Py_RefTotal--;
85+
_Py_DEC_REFTOTAL();
7486
#endif
7587
op->ob_refcnt--;
7688
#ifdef Py_DEBUG
@@ -80,6 +92,11 @@ _Py_DECREF_NO_DEALLOC(PyObject *op)
8092
#endif
8193
}
8294

95+
#ifdef Py_REF_DEBUG
96+
# undef _Py_DEC_REFTOTAL
97+
#endif
98+
99+
83100
PyAPI_FUNC(int) _PyType_CheckConsistency(PyTypeObject *type);
84101
PyAPI_FUNC(int) _PyDict_CheckConsistency(PyObject *mp, int check_content);
85102

Include/object.h

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,21 @@ you can count such references to the type object.)
490490
*/
491491

492492
#ifdef Py_REF_DEBUG
493-
PyAPI_DATA(Py_ssize_t) _Py_RefTotal;
493+
# if defined(Py_LIMITED_API) && Py_LIMITED_API+0 < 0x030A0000
494+
extern Py_ssize_t _Py_RefTotal;
495+
# define _Py_INC_REFTOTAL() _Py_RefTotal++
496+
# define _Py_DEC_REFTOTAL() _Py_RefTotal--
497+
# elif defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
498+
extern void _Py_IncRefTotal(void);
499+
extern void _Py_DecRefTotal(void);
500+
# define _Py_INC_REFTOTAL() _Py_IncRefTotal()
501+
# define _Py_DEC_REFTOTAL() _Py_DecRefTotal()
502+
# elif !defined(Py_LIMITED_API) || Py_LIMITED_API+0 > 0x030C0000
503+
extern void _Py_IncRefTotal_DO_NOT_USE_THIS(void);
504+
extern void _Py_DecRefTotal_DO_NOT_USE_THIS(void);
505+
# define _Py_INC_REFTOTAL() _Py_IncRefTotal_DO_NOT_USE_THIS()
506+
# define _Py_DEC_REFTOTAL() _Py_DecRefTotal_DO_NOT_USE_THIS()
507+
# endif
494508
PyAPI_FUNC(void) _Py_NegativeRefcount(const char *filename, int lineno,
495509
PyObject *op);
496510
#endif /* Py_REF_DEBUG */
@@ -519,8 +533,8 @@ static inline void Py_INCREF(PyObject *op)
519533
// Non-limited C API and limited C API for Python 3.9 and older access
520534
// directly PyObject.ob_refcnt.
521535
#ifdef Py_REF_DEBUG
522-
_Py_RefTotal++;
523-
#endif
536+
_Py_INC_REFTOTAL();
537+
#endif // Py_REF_DEBUG
524538
op->ob_refcnt++;
525539
#endif
526540
}
@@ -539,7 +553,7 @@ static inline void Py_DECREF(PyObject *op) {
539553
static inline void Py_DECREF(const char *filename, int lineno, PyObject *op)
540554
{
541555
_Py_DECREF_STAT_INC();
542-
_Py_RefTotal--;
556+
_Py_DEC_REFTOTAL();
543557
if (--op->ob_refcnt != 0) {
544558
if (op->ob_refcnt < 0) {
545559
_Py_NegativeRefcount(filename, lineno, op);
@@ -564,6 +578,9 @@ static inline void Py_DECREF(PyObject *op)
564578
#define Py_DECREF(op) Py_DECREF(_PyObject_CAST(op))
565579
#endif
566580

581+
#undef _Py_INC_REFTOTAL
582+
#undef _Py_DEC_REFTOTAL
583+
567584

568585
/* Safely decref `op` and set `op` to NULL, especially useful in tp_clear
569586
* and tp_dealloc implementations.

Include/patchlevel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
#define PY_MINOR_VERSION 12
2121
#define PY_MICRO_VERSION 0
2222
#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA
23-
#define PY_RELEASE_SERIAL 5
23+
#define PY_RELEASE_SERIAL 6
2424

2525
/* Version as a string */
26-
#define PY_VERSION "3.12.0a5+"
26+
#define PY_VERSION "3.12.0a6+"
2727
/*--end constants--*/
2828

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

0 commit comments

Comments
 (0)