Skip to content

Commit

Permalink
Merge branch 'main' into inlinecomp2
Browse files Browse the repository at this point in the history
* main: (67 commits)
  pythongh-99108: Add missing md5/sha1 defines to Modules/Setup (python#102308)
  pythongh-100227: Move _str_replace_inf to PyInterpreterState (pythongh-102333)
  pythongh-100227: Move the dtoa State to PyInterpreterState (pythongh-102331)
  pythonGH-102305: Expand some macros in generated_cases.c.h (python#102309)
  Migrate to new PSF mailgun account (python#102284)
  pythongh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives (in Python/) (python#102193)
  pythonGH-90744: Fix erroneous doc links in the sys module (python#101319)
  pythongh-87092: Make jump target label equal to the offset of the target in the instructions sequence (python#102093)
  pythongh-101101: Unstable C API tier (PEP 689) (pythonGH-101102)
  IDLE: Simplify DynOptionsMenu __init__code (python#101371)
  pythongh-101561: Add typing.override decorator (python#101564)
  pythongh-101825: Clarify that as_integer_ratio() output is always normalized (python#101843)
  pythongh-101773: Optimize creation of Fractions in private methods (python#101780)
  pythongh-102251: Updates to test_imp Toward Fixing Some Refleaks (pythongh-102254)
  pythongh-102296 Document that inspect.Parameter kinds support ordering (pythonGH-102297)
  pythongh-102250: Fix double-decref in COMPARE_AND_BRANCH error case (pythonGH-102287)
  pythongh-101100: Fix sphinx warnings in `types` module (python#102274)
  pythongh-91038: Change default argument value to `False` instead of `0` (python#31621)
  pythongh-101765: unicodeobject: use Py_XDECREF correctly (python#102283)
  [doc] Improve grammar/fix missing word (pythonGH-102060)
  ...
  • Loading branch information
carljm committed Feb 28, 2023
2 parents 67f50ba + 360ef84 commit 73dc0ed
Show file tree
Hide file tree
Showing 199 changed files with 6,464 additions and 3,116 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,11 @@ jobs:
- uses: actions/checkout@v3
- name: Install Homebrew dependencies
run: brew install pkg-config [email protected] xz gdbm tcl-tk
- name: Prepare Homebrew environment variables
run: |
echo "CFLAGS=-I$(brew --prefix gdbm)/include -I$(brew --prefix xz)/include" >> $GITHUB_ENV
echo "LDFLAGS=-L$(brew --prefix gdbm)/lib -I$(brew --prefix xz)/lib" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=$(brew --prefix [email protected])/lib/pkgconfig:$(brew --prefix tcl-tk)/lib/pkgconfig" >> $GITHUB_ENV
- name: Configure CPython
run: |
CFLAGS="-I$(brew --prefix gdbm)/include -I$(brew --prefix xz)/include" \
LDFLAGS="-L$(brew --prefix gdbm)/lib -I$(brew --prefix xz)/lib" \
PKG_CONFIG_PATH="$(brew --prefix tcl-tk)/lib/pkgconfig" \
./configure \
--with-pydebug \
--prefix=/opt/python-dev \
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/new-bugs-announce-notifier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ jobs:
- name: Send notification
uses: actions/github-script@v6
env:
MAILGUN_API_KEY: ${{ secrets.PSF_MAILGUN_KEY }}
MAILGUN_API_KEY: ${{ secrets.MAILGUN_PYTHON_ORG_MAILGUN_KEY }}
with:
script: |
const Mailgun = require("mailgun.js");
const formData = require('form-data');
const mailgun = new Mailgun(formData);
const DOMAIN = "mg.python.org";
const DOMAIN = "mailgun.python.org";
const mg = mailgun.client({username: 'api', key: process.env.MAILGUN_API_KEY});
github.rest.issues.get({
issue_number: context.issue.number,
Expand All @@ -44,7 +44,7 @@ jobs:
};
const data = {
from: "CPython Issues <github@mg.python.org>",
from: "CPython Issues <github@mailgun.python.org>",
to: "[email protected]",
subject: `[Issue ${issue.data.number}] ${issue.data.title}`,
template: "new-github-issue",
Expand Down
2 changes: 1 addition & 1 deletion Doc/bugs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Click on the "New issue" button in the top bar to report a new issue.
The submission form has two fields, "Title" and "Comment".

For the "Title" field, enter a *very* short description of the problem;
less than ten words is good.
fewer than ten words is good.

In the "Comment" field, describe the problem in detail, including what you
expected to happen and what did happen. Be sure to include whether any
Expand Down
98 changes: 92 additions & 6 deletions Doc/c-api/code.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,47 @@ bound into a function.
Return the number of free variables in *co*.
.. c:function:: PyCodeObject* PyCode_New(int argcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, PyObject *linetable, PyObject *exceptiontable)
.. c:function:: PyCodeObject* PyUnstable_Code_New(int argcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, PyObject *linetable, PyObject *exceptiontable)
Return a new code object. If you need a dummy code object to create a frame,
use :c:func:`PyCode_NewEmpty` instead. Calling :c:func:`PyCode_New` directly
will bind you to a precise Python version since the definition of the bytecode
changes often. The many arguments of this function are inter-dependent in complex
use :c:func:`PyCode_NewEmpty` instead.
Since the definition of the bytecode changes often, calling
:c:func:`PyCode_New` directly can bind you to a precise Python version.
The many arguments of this function are inter-dependent in complex
ways, meaning that subtle changes to values are likely to result in incorrect
execution or VM crashes. Use this function only with extreme care.
.. versionchanged:: 3.11
Added ``exceptiontable`` parameter.
.. c:function:: PyCodeObject* PyCode_NewWithPosOnlyArgs(int argcount, int posonlyargcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, PyObject *linetable, PyObject *exceptiontable)
.. index:: single: PyCode_New
.. versionchanged:: 3.12
Renamed from ``PyCode_New`` as part of :ref:`unstable-c-api`.
The old name is deprecated, but will remain available until the
signature changes again.
.. c:function:: PyCodeObject* PyUnstable_Code_NewWithPosOnlyArgs(int argcount, int posonlyargcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, PyObject *linetable, PyObject *exceptiontable)
Similar to :c:func:`PyCode_New`, but with an extra "posonlyargcount" for positional-only arguments.
The same caveats that apply to ``PyCode_New`` also apply to this function.
.. versionadded:: 3.8
.. index:: single: PyCode_NewWithPosOnlyArgs
.. versionadded:: 3.8 as ``PyCode_NewWithPosOnlyArgs``
.. versionchanged:: 3.11
Added ``exceptiontable`` parameter.
.. versionchanged:: 3.12
Renamed to ``PyUnstable_Code_NewWithPosOnlyArgs``.
The old name is deprecated, but will remain available until the
signature changes again.
.. c:function:: PyCodeObject* PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno)
Return a new empty code object with the specified filename,
Expand Down Expand Up @@ -165,3 +184,70 @@ bound into a function.
:c:func:`PyErr_WriteUnraisable`. Otherwise it should return ``0``.
.. versionadded:: 3.12
Extra information
-----------------
To support low-level extensions to frame evaluation, such as external
just-in-time compilers, it is possible to attach arbitrary extra data to
code objects.
These functions are part of the unstable C API tier:
this functionality is a CPython implementation detail, and the API
may change without deprecation warnings.
.. c:function:: Py_ssize_t PyUnstable_Eval_RequestCodeExtraIndex(freefunc free)
Return a new an opaque index value used to adding data to code objects.
You generally call this function once (per interpreter) and use the result
with ``PyCode_GetExtra`` and ``PyCode_SetExtra`` to manipulate
data on individual code objects.
If *free* is not ``NULL``: when a code object is deallocated,
*free* will be called on non-``NULL`` data stored under the new index.
Use :c:func:`Py_DecRef` when storing :c:type:`PyObject`.
.. index:: single: _PyEval_RequestCodeExtraIndex
.. versionadded:: 3.6 as ``_PyEval_RequestCodeExtraIndex``
.. versionchanged:: 3.12
Renamed to ``PyUnstable_Eval_RequestCodeExtraIndex``.
The old private name is deprecated, but will be available until the API
changes.
.. c:function:: int PyUnstable_Code_GetExtra(PyObject *code, Py_ssize_t index, void **extra)
Set *extra* to the extra data stored under the given index.
Return 0 on success. Set an exception and return -1 on failure.
If no data was set under the index, set *extra* to ``NULL`` and return
0 without setting an exception.
.. index:: single: _PyCode_GetExtra
.. versionadded:: 3.6 as ``_PyCode_GetExtra``
.. versionchanged:: 3.12
Renamed to ``PyUnstable_Code_GetExtra``.
The old private name is deprecated, but will be available until the API
changes.
.. c:function:: int PyUnstable_Code_SetExtra(PyObject *code, Py_ssize_t index, void *extra)
Set the extra data stored under the given index to *extra*.
Return 0 on success. Set an exception and return -1 on failure.
.. index:: single: _PyCode_SetExtra
.. versionadded:: 3.6 as ``_PyCode_SetExtra``
.. versionchanged:: 3.12
Renamed to ``PyUnstable_Code_SetExtra``.
The old private name is deprecated, but will be available until the API
changes.
45 changes: 23 additions & 22 deletions Doc/c-api/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,9 @@ Querying the error indicator
.. c:function:: void PyErr_Fetch(PyObject **ptype, PyObject **pvalue, PyObject **ptraceback)
As of 3.12, this function is deprecated. Use :c:func:`PyErr_GetRaisedException` instead.
.. deprecated:: 3.12
Use :c:func:`PyErr_GetRaisedException` instead.
Retrieve the error indicator into three variables whose addresses are passed.
If the error indicator is not set, set all three variables to ``NULL``. If it is
Expand All @@ -447,8 +449,10 @@ Querying the error indicator
.. note::
This function is normally only used by code that needs to catch exceptions or
by code that needs to save and restore the error indicator temporarily, e.g.::
This function is normally only used by legacy code that needs to catch
exceptions or save and restore the error indicator temporarily.
For example::
{
PyObject *type, *value, *traceback;
Expand All @@ -459,15 +463,17 @@ Querying the error indicator
PyErr_Restore(type, value, traceback);
}
.. deprecated:: 3.12
.. c:function:: void PyErr_Restore(PyObject *type, PyObject *value, PyObject *traceback)
As of 3.12, this function is deprecated. Use :c:func:`PyErr_SetRaisedException` instead.
.. deprecated:: 3.12
Use :c:func:`PyErr_SetRaisedException` instead.
Set the error indicator from the three objects. If the error indicator is
already set, it is cleared first. If the objects are ``NULL``, the error
Set the error indicator from the three objects,
*type*, *value*, and *traceback*,
clearing the existing exception if one is set.
If the objects are ``NULL``, the error
indicator is cleared. Do not pass a ``NULL`` type and non-``NULL`` value or
traceback. The exception type should be a class. Do not pass an invalid
exception type or value. (Violating these rules will cause subtle problems
Expand All @@ -478,18 +484,17 @@ Querying the error indicator
.. note::
This function is normally only used by code that needs to save and restore the
error indicator temporarily. Use :c:func:`PyErr_Fetch` to save the current
error indicator.
.. deprecated:: 3.12
This function is normally only used by legacy code that needs to
save and restore the error indicator temporarily.
Use :c:func:`PyErr_Fetch` to save the current error indicator.
.. c:function:: void PyErr_NormalizeException(PyObject **exc, PyObject **val, PyObject **tb)
As of 3.12, this function is deprecated.
Use :c:func:`PyErr_GetRaisedException` instead of :c:func:`PyErr_Fetch` to avoid
any possible de-normalization.
.. deprecated:: 3.12
Use :c:func:`PyErr_GetRaisedException` instead,
to avoid any possible de-normalization.
Under certain circumstances, the values returned by :c:func:`PyErr_Fetch` below
can be "unnormalized", meaning that ``*exc`` is a class object but ``*val`` is
Expand All @@ -507,8 +512,6 @@ Querying the error indicator
PyException_SetTraceback(val, tb);
}
.. deprecated:: 3.12
.. c:function:: PyObject* PyErr_GetHandledException(void)
Expand Down Expand Up @@ -756,14 +759,12 @@ Exception Objects
.. c:function:: PyObject* PyException_GetArgs(PyObject *ex)
Return args of the given exception as a new reference,
as accessible from Python through :attr:`args`.
Return :attr:`~BaseException.args` of exception *ex*.
.. c:function:: void PyException_SetArgs(PyObject *ex, PyObject *args)
Set the args of the given exception,
as accessible from Python through :attr:`args`.
Set :attr:`~BaseException.args` of exception *ex* to *args*.
.. _unicodeexceptions:
Expand Down
2 changes: 1 addition & 1 deletion Doc/c-api/init.rst
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ Process-wide parameters
.. deprecated:: 3.11
.. c:function:: w_char* Py_GetPythonHome()
.. c:function:: wchar_t* Py_GetPythonHome()
Return the default "home", that is, the value set by a previous call to
:c:func:`Py_SetPythonHome`, or the value of the :envvar:`PYTHONHOME`
Expand Down
36 changes: 33 additions & 3 deletions Doc/c-api/stable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
C API Stability
***************

Python's C API is covered by the Backwards Compatibility Policy, :pep:`387`.
While the C API will change with every minor release (e.g. from 3.9 to 3.10),
most changes will be source-compatible, typically by only adding new API.
Unless documented otherwise, Python's C API is covered by the Backwards
Compatibility Policy, :pep:`387`.
Most changes to it are source-compatible (typically by only adding new API).
Changing existing API or removing API is only done after a deprecation period
or to fix serious issues.

Expand All @@ -18,8 +18,38 @@ way; see :ref:`stable-abi-platform` below).
So, code compiled for Python 3.10.0 will work on 3.10.8 and vice versa,
but will need to be compiled separately for 3.9.x and 3.10.x.

There are two tiers of C API with different stability exepectations:

- *Unstable API*, may change in minor versions without a deprecation period.
It is marked by the ``PyUnstable`` prefix in names.
- *Limited API*, is compatible across several minor releases.
When :c:macro:`Py_LIMITED_API` is defined, only this subset is exposed
from ``Python.h``.

These are discussed in more detail below.

Names prefixed by an underscore, such as ``_Py_InternalState``,
are private API that can change without notice even in patch releases.
If you need to use this API, consider reaching out to
`CPython developers <https://discuss.python.org/c/core-dev/c-api/30>`_
to discuss adding public API for your use case.

.. _unstable-c-api:

Unstable C API
==============

.. index:: single: PyUnstable

Any API named with the ``PyUnstable`` prefix exposes CPython implementation
details, and may change in every minor release (e.g. from 3.9 to 3.10) without
any deprecation warnings.
However, it will not change in a bugfix release (e.g. from 3.10.0 to 3.10.1).

It is generally intended for specialized, low-level tools like debuggers.

Projects that use this API are expected to follow
CPython development and spend extra effort adjusting to changes.


Stable Application Binary Interface
Expand Down
2 changes: 2 additions & 0 deletions Doc/data/refcounts.dat
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,8 @@ PyEval_EvalFrameEx:int:throwflag::
PyEval_MergeCompilerFlags:int:::
PyEval_MergeCompilerFlags:PyCompilerFlags*:cf::

PyException_GetArgs:PyObject*::+1:

PyException_GetCause:PyObject*::+1:
PyException_GetCause:PyObject*:ex:0:

Expand Down
2 changes: 1 addition & 1 deletion Doc/howto/logging-cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2538,7 +2538,7 @@ should be logged, or the ``extra`` keyword parameter to indicate additional
contextual information to be added to the log). So you cannot directly make
logging calls using :meth:`str.format` or :class:`string.Template` syntax,
because internally the logging package uses %-formatting to merge the format
string and the variable arguments. There would no changing this while preserving
string and the variable arguments. There would be no changing this while preserving
backward compatibility, since all logging calls which are out there in existing
code will be using %-format strings.

Expand Down
4 changes: 2 additions & 2 deletions Doc/library/asyncio-eventloop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,8 @@ Opening network connections
When a server's IPv4 path and protocol are working, but the server's
IPv6 path and protocol are not working, a dual-stack client
application experiences significant connection delay compared to an
IPv4-only client. This is undesirable because it causes the dual-
stack client to have a worse user experience. This document
IPv4-only client. This is undesirable because it causes the
dual-stack client to have a worse user experience. This document
specifies requirements for algorithms that reduce this user-visible
delay and provides an algorithm.

Expand Down
Loading

0 comments on commit 73dc0ed

Please sign in to comment.