Skip to content

Commit b257a16

Browse files
committed
Merge branch 'main' into lockfreecp
* main: (76 commits) Fix syntax error in struct doc example (python#102160) pythongh-99108: Import MD5 and SHA1 from HACL* (python#102089) pythonGH-101777: `queue.rst`: use 2 spaces after a period to be consistent. (python#102143) Few coverage nitpicks for the cmath module (python#102067) pythonGH-100982: Restrict `FOR_ITER_RANGE` to a single instruction to allow instrumentation. (pythonGH-101985) pythongh-102135: Update turtle docs to rename wikipedia demo to rosette (python#102137) pythongh-99942: python.pc on android/cygwin should link to libpython per configure.ac (pythonGH-100356) pythongh-95672 fix typo SkitTest to SkipTest (pythongh-102119) pythongh-101936: Update the default value of fp from io.StringIO to io.BytesIO (pythongh-102100) pythongh-102008: simplify test_except_star by using sys.exception() instead of sys.exc_info() (python#102009) pythongh-101903: Remove obsolete undefs for previously removed macros Py_EnterRecursiveCall and Py_LeaveRecursiveCall (python#101923) pythongh-100556: Improve clarity of `or` docs (python#100589) pythongh-101777: Make `PriorityQueue` docs slightly clearer (python#102026) pythongh-101965: Fix usage of Py_EnterRecursiveCall return value in _bisectmodule.c (pythonGH-101966) pythongh-101578: Amend exception docs (python#102057) pythongh-101961 fileinput.hookcompressed should not set the encoding value for the binary mode (pythongh-102068) pythongh-102056: Fix a few bugs in error handling of exception printing code (python#102078) pythongh-102011: use sys.exception() instead of sys.exc_info() in docs where possible (python#102012) pythongh-101566: Sync with zipp 3.14. (pythonGH-102018) pythonGH-99818: improve the documentation for zipfile.Path and Traversable (pythonGH-101589) ...
2 parents 31f0d54 + 8f64747 commit b257a16

File tree

245 files changed

+11589
-5956
lines changed

Some content is hidden

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

245 files changed

+11589
-5956
lines changed

.github/workflows/build.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,25 @@ jobs:
154154
needs: check_source
155155
if: needs.check_source.outputs.run_tests == 'true'
156156
env:
157+
HOMEBREW_NO_ANALYTICS: 1
158+
HOMEBREW_NO_AUTO_UPDATE: 1
159+
HOMEBREW_NO_INSTALL_CLEANUP: 1
157160
PYTHONSTRICTEXTENSIONBUILD: 1
158161
steps:
159162
- uses: actions/checkout@v3
160-
- name: Prepare homebrew environment variables
163+
- name: Install Homebrew dependencies
164+
run: brew install pkg-config [email protected] xz gdbm tcl-tk
165+
- name: Prepare Homebrew environment variables
161166
run: |
162-
echo "LDFLAGS=-L$(brew --prefix tcl-tk)/lib" >> $GITHUB_ENV
167+
echo "CFLAGS=-I$(brew --prefix gdbm)/include -I$(brew --prefix xz)/include" >> $GITHUB_ENV
168+
echo "LDFLAGS=-L$(brew --prefix gdbm)/lib -I$(brew --prefix xz)/lib" >> $GITHUB_ENV
163169
echo "PKG_CONFIG_PATH=$(brew --prefix [email protected])/lib/pkgconfig:$(brew --prefix tcl-tk)/lib/pkgconfig" >> $GITHUB_ENV
164170
- name: Configure CPython
165-
run: ./configure --with-pydebug --prefix=/opt/python-dev
171+
run: |
172+
./configure \
173+
--with-pydebug \
174+
--prefix=/opt/python-dev \
175+
--with-openssl="$(brew --prefix [email protected])"
166176
- name: Build CPython
167177
run: make -j4
168178
- name: Display build info

Doc/c-api/dict.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Dictionary Objects
8080
8181
.. c:function:: int PyDict_DelItem(PyObject *p, PyObject *key)
8282
83-
Remove the entry in dictionary *p* with key *key*. *key* must be hashable;
83+
Remove the entry in dictionary *p* with key *key*. *key* must be :term:`hashable`;
8484
if it isn't, :exc:`TypeError` is raised.
8585
If *key* is not in the dictionary, :exc:`KeyError` is raised.
8686
Return ``0`` on success or ``-1`` on failure.

Doc/c-api/exceptions.rst

Lines changed: 40 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -402,58 +402,45 @@ Querying the error indicator
402402
403403
.. c:function:: PyObject *PyErr_GetRaisedException(void)
404404
405-
Returns the exception currently being raised, clearing the exception at
406-
the same time. Do not confuse this with the exception currently being
407-
handled which can be accessed with :c:func:`PyErr_GetHandledException`.
405+
Return the exception currently being raised, clearing the error indicator at
406+
the same time.
408407
409-
.. note::
408+
This function is used by code that needs to catch exceptions,
409+
or code that needs to save and restore the error indicator temporarily.
410410
411-
This function is normally only used by code that needs to catch exceptions or
412-
by code that needs to save and restore the error indicator temporarily, e.g.::
411+
For example::
413412
414-
{
415-
PyObject *exc = PyErr_GetRaisedException();
413+
{
414+
PyObject *exc = PyErr_GetRaisedException();
416415
417-
/* ... code that might produce other errors ... */
416+
/* ... code that might produce other errors ... */
418417
419-
PyErr_SetRaisedException(exc);
420-
}
418+
PyErr_SetRaisedException(exc);
419+
}
420+
421+
.. seealso:: :c:func:`PyErr_GetHandledException`,
422+
to save the exception currently being handled.
421423
422424
.. versionadded:: 3.12
423425
424426
425427
.. c:function:: void PyErr_SetRaisedException(PyObject *exc)
426428
427-
Sets the exception currently being raised ``exc``.
428-
If the exception is already set, it is cleared first.
429-
430-
``exc`` must be a valid exception.
431-
(Violating this rules will cause subtle problems later.)
432-
This call consumes a reference to the ``exc`` object: you must own a
433-
reference to that object before the call and after the call you no longer own
434-
that reference.
435-
(If you don't understand this, don't use this function. I warned you.)
429+
Set *exc* as the exception currently being raised,
430+
clearing the existing exception if one is set.
436431
437-
.. note::
432+
.. warning::
438433
439-
This function is normally only used by code that needs to save and restore the
440-
error indicator temporarily. Use :c:func:`PyErr_GetRaisedException` to save
441-
the current exception, e.g.::
442-
443-
{
444-
PyObject *exc = PyErr_GetRaisedException();
445-
446-
/* ... code that might produce other errors ... */
447-
448-
PyErr_SetRaisedException(exc);
449-
}
434+
This call steals a reference to *exc*, which must be a valid exception.
450435
451436
.. versionadded:: 3.12
452437
453438
454439
.. c:function:: void PyErr_Fetch(PyObject **ptype, PyObject **pvalue, PyObject **ptraceback)
455440
456-
As of 3.12, this function is deprecated. Use :c:func:`PyErr_GetRaisedException` instead.
441+
.. deprecated:: 3.12
442+
443+
Use :c:func:`PyErr_GetRaisedException` instead.
457444
458445
Retrieve the error indicator into three variables whose addresses are passed.
459446
If the error indicator is not set, set all three variables to ``NULL``. If it is
@@ -462,8 +449,10 @@ Querying the error indicator
462449
463450
.. note::
464451
465-
This function is normally only used by code that needs to catch exceptions or
466-
by code that needs to save and restore the error indicator temporarily, e.g.::
452+
This function is normally only used by legacy code that needs to catch
453+
exceptions or save and restore the error indicator temporarily.
454+
455+
For example::
467456
468457
{
469458
PyObject *type, *value, *traceback;
@@ -474,15 +463,17 @@ Querying the error indicator
474463
PyErr_Restore(type, value, traceback);
475464
}
476465
477-
.. deprecated:: 3.12
478-
479466
480467
.. c:function:: void PyErr_Restore(PyObject *type, PyObject *value, PyObject *traceback)
481468
482-
As of 3.12, this function is deprecated. Use :c:func:`PyErr_SetRaisedException` instead.
469+
.. deprecated:: 3.12
470+
471+
Use :c:func:`PyErr_SetRaisedException` instead.
483472
484-
Set the error indicator from the three objects. If the error indicator is
485-
already set, it is cleared first. If the objects are ``NULL``, the error
473+
Set the error indicator from the three objects,
474+
*type*, *value*, and *traceback*,
475+
clearing the existing exception if one is set.
476+
If the objects are ``NULL``, the error
486477
indicator is cleared. Do not pass a ``NULL`` type and non-``NULL`` value or
487478
traceback. The exception type should be a class. Do not pass an invalid
488479
exception type or value. (Violating these rules will cause subtle problems
@@ -493,18 +484,17 @@ Querying the error indicator
493484
494485
.. note::
495486
496-
This function is normally only used by code that needs to save and restore the
497-
error indicator temporarily. Use :c:func:`PyErr_Fetch` to save the current
498-
error indicator.
499-
500-
.. deprecated:: 3.12
487+
This function is normally only used by legacy code that needs to
488+
save and restore the error indicator temporarily.
489+
Use :c:func:`PyErr_Fetch` to save the current error indicator.
501490
502491
503492
.. c:function:: void PyErr_NormalizeException(PyObject **exc, PyObject **val, PyObject **tb)
504493
505-
As of 3.12, this function is deprecated.
506-
Use :c:func:`PyErr_GetRaisedException` instead of :c:func:`PyErr_Fetch` to avoid
507-
any possible de-normalization.
494+
.. deprecated:: 3.12
495+
496+
Use :c:func:`PyErr_GetRaisedException` instead,
497+
to avoid any possible de-normalization.
508498
509499
Under certain circumstances, the values returned by :c:func:`PyErr_Fetch` below
510500
can be "unnormalized", meaning that ``*exc`` is a class object but ``*val`` is
@@ -522,8 +512,6 @@ Querying the error indicator
522512
PyException_SetTraceback(val, tb);
523513
}
524514
525-
.. deprecated:: 3.12
526-
527515
528516
.. c:function:: PyObject* PyErr_GetHandledException(void)
529517
@@ -771,14 +759,12 @@ Exception Objects
771759
772760
.. c:function:: PyObject* PyException_GetArgs(PyObject *ex)
773761
774-
Return args of the given exception as a new reference,
775-
as accessible from Python through :attr:`args`.
762+
Return :attr:`~BaseException.args` of exception *ex*.
776763
777764
778765
.. c:function:: void PyException_SetArgs(PyObject *ex, PyObject *args)
779766
780-
Set the args of the given exception,
781-
as accessible from Python through :attr:`args`.
767+
Set :attr:`~BaseException.args` of exception *ex* to *args*.
782768
783769
784770
.. _unicodeexceptions:

Doc/c-api/function.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ There are a few functions specific to Python functions.
169169
before the modification to *func* takes place, so the prior state of *func*
170170
can be inspected. The runtime is permitted to optimize away the creation of
171171
function objects when possible. In such cases no event will be emitted.
172-
Although this creates the possitibility of an observable difference of
172+
Although this creates the possibility of an observable difference of
173173
runtime behavior depending on optimization decisions, it does not change
174174
the semantics of the Python code being executed.
175175

Doc/c-api/module.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,15 +388,15 @@ objects dynamically. Note that both ``PyModule_FromDefAndSpec`` and
388388
389389
.. c:function:: PyObject * PyModule_FromDefAndSpec(PyModuleDef *def, PyObject *spec)
390390
391-
Create a new module object, given the definition in *module* and the
391+
Create a new module object, given the definition in *def* and the
392392
ModuleSpec *spec*. This behaves like :c:func:`PyModule_FromDefAndSpec2`
393393
with *module_api_version* set to :const:`PYTHON_API_VERSION`.
394394
395395
.. versionadded:: 3.5
396396
397397
.. c:function:: PyObject * PyModule_FromDefAndSpec2(PyModuleDef *def, PyObject *spec, int module_api_version)
398398
399-
Create a new module object, given the definition in *module* and the
399+
Create a new module object, given the definition in *def* and the
400400
ModuleSpec *spec*, assuming the API version *module_api_version*.
401401
If that version does not match the version of the running interpreter,
402402
a :exc:`RuntimeWarning` is emitted.

Doc/c-api/object.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ Object Protocol
281281
282282
.. c:function:: Py_hash_t PyObject_HashNotImplemented(PyObject *o)
283283
284-
Set a :exc:`TypeError` indicating that ``type(o)`` is not hashable and return ``-1``.
284+
Set a :exc:`TypeError` indicating that ``type(o)`` is not :term:`hashable` and return ``-1``.
285285
This function receives special treatment when stored in a ``tp_hash`` slot,
286286
allowing a type to explicitly indicate to the interpreter that it is not
287287
hashable.

Doc/data/refcounts.dat

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,9 @@ PyErr_GetExcInfo:PyObject**:ptype:+1:
606606
PyErr_GetExcInfo:PyObject**:pvalue:+1:
607607
PyErr_GetExcInfo:PyObject**:ptraceback:+1:
608608

609+
PyErr_GetRaisedException:PyObject*::+1:
610+
PyErr_SetRaisedException::::
611+
609612
PyErr_GivenExceptionMatches:int:::
610613
PyErr_GivenExceptionMatches:PyObject*:given:0:
611614
PyErr_GivenExceptionMatches:PyObject*:exc:0:
@@ -836,6 +839,8 @@ PyEval_EvalFrameEx:int:throwflag::
836839
PyEval_MergeCompilerFlags:int:::
837840
PyEval_MergeCompilerFlags:PyCompilerFlags*:cf::
838841

842+
PyException_GetArgs:PyObject*::+1:
843+
839844
PyException_GetCause:PyObject*::+1:
840845
PyException_GetCause:PyObject*:ex:0:
841846

Doc/faq/programming.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1979,7 +1979,7 @@ method result will be released right away. The disadvantage is that if
19791979
instances accumulate, so too will the accumulated method results. They
19801980
can grow without bound.
19811981

1982-
The *lru_cache* approach works with methods that have hashable
1982+
The *lru_cache* approach works with methods that have :term:`hashable`
19831983
arguments. It creates a reference to the instance unless special
19841984
efforts are made to pass in weak references.
19851985

Doc/library/abc.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The :mod:`collections` module has some concrete classes that derive from
2121
ABCs; these can, of course, be further derived. In addition, the
2222
:mod:`collections.abc` submodule has some ABCs that can be used to test whether
2323
a class or instance provides a particular interface, for example, if it is
24-
hashable or if it is a mapping.
24+
:term:`hashable` or if it is a mapping.
2525

2626

2727
This module provides the metaclass :class:`ABCMeta` for defining ABCs and

Doc/library/argparse.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1867,7 +1867,7 @@ Sub-commands
18671867
...
18681868
>>> # create the top-level parser
18691869
>>> parser = argparse.ArgumentParser()
1870-
>>> subparsers = parser.add_subparsers()
1870+
>>> subparsers = parser.add_subparsers(required=True)
18711871
>>>
18721872
>>> # create the parser for the "foo" command
18731873
>>> parser_foo = subparsers.add_parser('foo')

Doc/library/asyncio-stream.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,20 @@ StreamReader
206206

207207
.. coroutinemethod:: read(n=-1)
208208

209-
Read up to *n* bytes. If *n* is not provided, or set to ``-1``,
210-
read until EOF and return all read bytes.
209+
Read up to *n* bytes from the stream.
211210

211+
If *n* is not provided or set to ``-1``,
212+
read until EOF, then return all read :class:`bytes`.
212213
If EOF was received and the internal buffer is empty,
213214
return an empty ``bytes`` object.
214215

216+
If *n* is ``0``, return an empty ``bytes`` object immediately.
217+
218+
If *n* is positive, return at most *n* available ``bytes``
219+
as soon as at least 1 byte is available in the internal buffer.
220+
If EOF is received before any byte is read, return an empty
221+
``bytes`` object.
222+
215223
.. coroutinemethod:: readline()
216224

217225
Read one line, where "line" is a sequence of bytes

0 commit comments

Comments
 (0)