Skip to content

Commit

Permalink
Merge branch 'main' into inlinecomp2
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
carljm committed Mar 8, 2023
2 parents 90b34de + cbb0aa7 commit 06db319
Show file tree
Hide file tree
Showing 160 changed files with 1,089 additions and 482 deletions.
3 changes: 1 addition & 2 deletions Doc/distributing/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ Key terms
developers and documentation authors responsible for the maintenance and
evolution of the standard packaging tools and the associated metadata and
file format standards. They maintain a variety of tools, documentation
and issue trackers on both `GitHub <https://github.com/pypa>`__ and
`Bitbucket <https://bitbucket.org/pypa/>`__.
and issue trackers on `GitHub <https://github.com/pypa>`__.
* ``distutils`` is the original build and distribution system first added
to the Python standard library in 1998. While direct use of ``distutils``
is being phased out, it still laid the foundation for the current packaging
Expand Down
3 changes: 1 addition & 2 deletions Doc/installing/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ Key terms
developers and documentation authors responsible for the maintenance and
evolution of the standard packaging tools and the associated metadata and
file format standards. They maintain a variety of tools, documentation,
and issue trackers on both `GitHub <https://github.com/pypa>`__ and
`Bitbucket <https://bitbucket.org/pypa/>`__.
and issue trackers on `GitHub <https://github.com/pypa>`__.
* ``distutils`` is the original build and distribution system first added to
the Python standard library in 1998. While direct use of ``distutils`` is
being phased out, it still laid the foundation for the current packaging
Expand Down
6 changes: 3 additions & 3 deletions Doc/library/argparse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ around an instance of :class:`argparse.ArgumentParser`. It is a container for
argument specifications and has options that apply to the parser as whole::

parser = argparse.ArgumentParser(
prog = 'ProgramName',
description = 'What the program does',
epilog = 'Text at the bottom of help')
prog='ProgramName',
description='What the program does',
epilog='Text at the bottom of help')

The :meth:`ArgumentParser.add_argument` method attaches individual argument
specifications to the parser. It supports positional arguments, options that
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/venv.rst
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ subclass which installs setuptools and pip into a created virtual environment::
:param context: The information for the virtual environment
creation request being processed.
"""
url = 'https://bitbucket.org/pypa/setuptools/downloads/ez_setup.py'
url = "https://bootstrap.pypa.io/ez_setup.py"
self.install_script(context, 'setuptools', url)
# clear up the setuptools archive which gets downloaded
pred = lambda o: o.startswith('setuptools-') and o.endswith('.tar.gz')
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/zipapp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ using the :func:`create_archive` function::
>>> import zipapp
>>> zipapp.create_archive('old_archive.pyz', 'new_archive.pyz', '/usr/bin/python3')

To update the file in place, do the replacement in memory using a :class:`BytesIO`
To update the file in place, do the replacement in memory using a :class:`~io.BytesIO`
object, and then overwrite the source afterwards. Note that there is a risk
when overwriting a file in place that an error will result in the loss of
the original file. This code does not protect against such errors, but
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/zipfile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ ZipFile Objects
(``ZipExtFile``) is read-only and provides the following methods:
:meth:`~io.BufferedIOBase.read`, :meth:`~io.IOBase.readline`,
:meth:`~io.IOBase.readlines`, :meth:`~io.IOBase.seek`,
:meth:`~io.IOBase.tell`, :meth:`__iter__`, :meth:`~iterator.__next__`.
:meth:`~io.IOBase.tell`, :meth:`~container.__iter__`, :meth:`~iterator.__next__`.
These objects can operate independently of the ZipFile.

With ``mode='w'``, a writable file handle is returned, which supports the
Expand Down
1 change: 1 addition & 0 deletions Include/cpython/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#endif

PyAPI_FUNC(void) _Py_NewReference(PyObject *op);
PyAPI_FUNC(void) _Py_NewReferenceNoTotal(PyObject *op);

#ifdef Py_TRACE_REFS
/* Py_TRACE_REFS is such major surgery that we call external routines. */
Expand Down
23 changes: 20 additions & 3 deletions Include/internal/pycore_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,23 @@ PyAPI_FUNC(void) _Py_NO_RETURN _Py_FatalRefcountErrorFunc(
#define _Py_FatalRefcountError(message) \
_Py_FatalRefcountErrorFunc(__func__, (message))


#ifdef Py_REF_DEBUG
/* The symbol is only exposed in the API for the sake of extensions
built against the pre-3.12 stable ABI. */
PyAPI_DATA(Py_ssize_t) _Py_RefTotal;

extern void _Py_AddRefTotal(Py_ssize_t);
extern void _Py_IncRefTotal(void);
extern void _Py_DecRefTotal(void);
# define _Py_DEC_REFTOTAL() _Py_RefTotal--
#endif

// Increment reference count by n
static inline void _Py_RefcntAdd(PyObject* op, Py_ssize_t n)
{
#ifdef Py_REF_DEBUG
_Py_RefTotal += n;
_Py_AddRefTotal(n);
#endif
op->ob_refcnt += n;
}
Expand All @@ -52,7 +64,7 @@ _Py_DECREF_SPECIALIZED(PyObject *op, const destructor destruct)
{
_Py_DECREF_STAT_INC();
#ifdef Py_REF_DEBUG
_Py_RefTotal--;
_Py_DEC_REFTOTAL();
#endif
if (--op->ob_refcnt != 0) {
assert(op->ob_refcnt > 0);
Expand All @@ -70,7 +82,7 @@ _Py_DECREF_NO_DEALLOC(PyObject *op)
{
_Py_DECREF_STAT_INC();
#ifdef Py_REF_DEBUG
_Py_RefTotal--;
_Py_DEC_REFTOTAL();
#endif
op->ob_refcnt--;
#ifdef Py_DEBUG
Expand All @@ -80,6 +92,11 @@ _Py_DECREF_NO_DEALLOC(PyObject *op)
#endif
}

#ifdef Py_REF_DEBUG
# undef _Py_DEC_REFTOTAL
#endif


PyAPI_FUNC(int) _PyType_CheckConsistency(PyTypeObject *type);
PyAPI_FUNC(int) _PyDict_CheckConsistency(PyObject *mp, int check_content);

Expand Down
25 changes: 21 additions & 4 deletions Include/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,21 @@ you can count such references to the type object.)
*/

#ifdef Py_REF_DEBUG
PyAPI_DATA(Py_ssize_t) _Py_RefTotal;
# if defined(Py_LIMITED_API) && Py_LIMITED_API+0 < 0x030A0000
extern Py_ssize_t _Py_RefTotal;
# define _Py_INC_REFTOTAL() _Py_RefTotal++
# define _Py_DEC_REFTOTAL() _Py_RefTotal--
# elif defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
extern void _Py_IncRefTotal(void);
extern void _Py_DecRefTotal(void);
# define _Py_INC_REFTOTAL() _Py_IncRefTotal()
# define _Py_DEC_REFTOTAL() _Py_DecRefTotal()
# elif !defined(Py_LIMITED_API) || Py_LIMITED_API+0 > 0x030C0000
extern void _Py_IncRefTotal_DO_NOT_USE_THIS(void);
extern void _Py_DecRefTotal_DO_NOT_USE_THIS(void);
# define _Py_INC_REFTOTAL() _Py_IncRefTotal_DO_NOT_USE_THIS()
# define _Py_DEC_REFTOTAL() _Py_DecRefTotal_DO_NOT_USE_THIS()
# endif
PyAPI_FUNC(void) _Py_NegativeRefcount(const char *filename, int lineno,
PyObject *op);
#endif /* Py_REF_DEBUG */
Expand Down Expand Up @@ -519,8 +533,8 @@ static inline void Py_INCREF(PyObject *op)
// Non-limited C API and limited C API for Python 3.9 and older access
// directly PyObject.ob_refcnt.
#ifdef Py_REF_DEBUG
_Py_RefTotal++;
#endif
_Py_INC_REFTOTAL();
#endif // Py_REF_DEBUG
op->ob_refcnt++;
#endif
}
Expand All @@ -539,7 +553,7 @@ static inline void Py_DECREF(PyObject *op) {
static inline void Py_DECREF(const char *filename, int lineno, PyObject *op)
{
_Py_DECREF_STAT_INC();
_Py_RefTotal--;
_Py_DEC_REFTOTAL();
if (--op->ob_refcnt != 0) {
if (op->ob_refcnt < 0) {
_Py_NegativeRefcount(filename, lineno, op);
Expand All @@ -564,6 +578,9 @@ static inline void Py_DECREF(PyObject *op)
#define Py_DECREF(op) Py_DECREF(_PyObject_CAST(op))
#endif

#undef _Py_INC_REFTOTAL
#undef _Py_DEC_REFTOTAL


/* Safely decref `op` and set `op` to NULL, especially useful in tp_clear
* and tp_dealloc implementations.
Expand Down
4 changes: 2 additions & 2 deletions Include/patchlevel.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
#define PY_MINOR_VERSION 12
#define PY_MICRO_VERSION 0
#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA
#define PY_RELEASE_SERIAL 5
#define PY_RELEASE_SERIAL 6

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

/* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2.
Expand Down
1 change: 0 additions & 1 deletion Lib/_pylong.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
tricky or non-obvious code is not worth it. For people looking for
maximum performance, they should use something like gmpy2."""

import sys
import re
import decimal

Expand Down
2 changes: 2 additions & 0 deletions Lib/concurrent/futures/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
from concurrent.futures import _base
import queue
import multiprocessing as mp
# This import is required to load the multiprocessing.connection submodule
# so that it can be accessed later as `mp.connection`
import multiprocessing.connection
from multiprocessing.queues import Queue
import threading
Expand Down
1 change: 0 additions & 1 deletion Lib/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import types
import inspect
import keyword
import builtins
import functools
import itertools
import abc
Expand Down
1 change: 0 additions & 1 deletion Lib/email/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
]



# Some convenience routines. Don't import Parser and Message as side-effects
# of importing email since those cascadingly import most of the rest of the
# email package.
Expand Down
4 changes: 0 additions & 4 deletions Lib/email/base64mime.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
MISC_LEN = 7



# Helpers
def header_length(bytearray):
"""Return the length of s when it is encoded with base64."""
Expand All @@ -57,7 +56,6 @@ def header_length(bytearray):
return n



def header_encode(header_bytes, charset='iso-8859-1'):
"""Encode a single header line with Base64 encoding in a given charset.
Expand All @@ -72,7 +70,6 @@ def header_encode(header_bytes, charset='iso-8859-1'):
return '=?%s?b?%s?=' % (charset, encoded)



def body_encode(s, maxlinelen=76, eol=NL):
r"""Encode a string with base64.
Expand All @@ -98,7 +95,6 @@ def body_encode(s, maxlinelen=76, eol=NL):
return EMPTYSTRING.join(encvec)



def decode(string):
"""Decode a raw base64 string, returning a bytes object.
Expand Down
5 changes: 0 additions & 5 deletions Lib/email/charset.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from email.encoders import encode_7or8bit



# Flags for types of header encodings
QP = 1 # Quoted-Printable
BASE64 = 2 # Base64
Expand All @@ -32,7 +31,6 @@
EMPTYSTRING = ''



# Defaults
CHARSETS = {
# input header enc body enc output conv
Expand Down Expand Up @@ -104,7 +102,6 @@
}



# Convenience functions for extending the above mappings
def add_charset(charset, header_enc=None, body_enc=None, output_charset=None):
"""Add character set properties to the global registry.
Expand Down Expand Up @@ -153,7 +150,6 @@ def add_codec(charset, codecname):
CODEC_MAP[charset] = codecname



# Convenience function for encoding strings, taking into account
# that they might be unknown-8bit (ie: have surrogate-escaped bytes)
def _encode(string, codec):
Expand All @@ -163,7 +159,6 @@ def _encode(string, codec):
return string.encode(codec)



class Charset:
"""Map character sets to their email properties.
Expand Down
4 changes: 0 additions & 4 deletions Lib/email/encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from quopri import encodestring as _encodestring



def _qencode(s):
enc = _encodestring(s, quotetabs=True)
# Must encode spaces, which quopri.encodestring() doesn't do
Expand All @@ -34,7 +33,6 @@ def encode_base64(msg):
msg['Content-Transfer-Encoding'] = 'base64'



def encode_quopri(msg):
"""Encode the message's payload in quoted-printable.
Expand All @@ -46,7 +44,6 @@ def encode_quopri(msg):
msg['Content-Transfer-Encoding'] = 'quoted-printable'



def encode_7or8bit(msg):
"""Set the Content-Transfer-Encoding header to 7bit or 8bit."""
orig = msg.get_payload(decode=True)
Expand All @@ -64,6 +61,5 @@ def encode_7or8bit(msg):
msg['Content-Transfer-Encoding'] = '7bit'



def encode_noop(msg):
"""Do nothing."""
2 changes: 0 additions & 2 deletions Lib/email/feedparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
NeedMoreData = object()



class BufferedSubFile(object):
"""A file-ish object that can have new data loaded into it.
Expand Down Expand Up @@ -132,7 +131,6 @@ def __next__(self):
return line



class FeedParser:
"""A feed-style parser of email."""

Expand Down
5 changes: 1 addition & 4 deletions Lib/email/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
fcre = re.compile(r'^From ', re.MULTILINE)



class Generator:
"""Generates output from a Message object tree.
Expand Down Expand Up @@ -392,7 +391,7 @@ def _make_boundary(cls, text=None):
def _compile_re(cls, s, flags):
return re.compile(s, flags)



class BytesGenerator(Generator):
"""Generates a bytes version of a Message object tree.
Expand Down Expand Up @@ -443,7 +442,6 @@ def _compile_re(cls, s, flags):
return re.compile(s.encode('ascii'), flags)



_FMT = '[Non-text (%(type)s) part of message omitted, filename %(filename)s]'

class DecodedGenerator(Generator):
Expand Down Expand Up @@ -503,7 +501,6 @@ def _dispatch(self, msg):
}, file=self)



# Helper used by Generator._make_boundary
_width = len(repr(sys.maxsize-1))
_fmt = '%%0%dd' % _width
Expand Down
Loading

0 comments on commit 06db319

Please sign in to comment.