Skip to content

Commit 7711236

Browse files
committed
Merge branch 'reduce-docstring' into reduce-to-ac
2 parents 6b268a6 + e0e467c commit 7711236

Some content is hidden

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

45 files changed

+661
-88
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Makefile.pre.in @erlend-aasland
1717
Modules/Setup* @erlend-aasland
1818

1919
# asyncio
20-
**/*asyncio* @1st1 @asvetlov @gvanrossum @kumaraditya303 @willingc
20+
**/*asyncio* @1st1 @asvetlov @kumaraditya303 @willingc
2121

2222
# Core
2323
**/*context* @1st1
@@ -281,4 +281,4 @@ Lib/test/test_configparser.py @jaraco
281281
# Doc sections
282282
Doc/reference/ @willingc
283283

284-
**/*weakref* @kumaraditya303
284+
**/*weakref* @kumaraditya303

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
# reproducible: to get the same tools versions (autoconf, aclocal, ...)
4747
runs-on: ubuntu-24.04
4848
container:
49-
image: ghcr.io/python/autoconf:2024.10.11.11293396815
49+
image: ghcr.io/python/autoconf:2024.10.16.11360930377
5050
timeout-minutes: 60
5151
needs: check_source
5252
if: needs.check_source.outputs.run_tests == 'true'

Doc/library/inspect.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,13 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
374374
Return ``True`` if the object is a bound method written in Python.
375375

376376

377+
.. function:: ispackage(object)
378+
379+
Return ``True`` if the object is a :term:`package`.
380+
381+
.. versionadded:: 3.14
382+
383+
377384
.. function:: isfunction(object)
378385

379386
Return ``True`` if the object is a Python function, which includes functions

Doc/library/stdtypes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3889,6 +3889,9 @@ copying.
38893889
.. versionchanged:: 3.5
38903890
memoryviews can now be indexed with tuple of integers.
38913891

3892+
.. versionchanged:: next
3893+
memoryview is now a :term:`generic type`.
3894+
38923895
:class:`memoryview` has several methods:
38933896

38943897
.. method:: __eq__(exporter)

Doc/tutorial/errors.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ A more complicated example::
464464
executing finally clause
465465
Traceback (most recent call last):
466466
File "<stdin>", line 1, in <module>
467-
divide("2", "0")
467+
divide("2", "1")
468468
~~~~~~^^^^^^^^^^
469469
File "<stdin>", line 3, in divide
470470
result = x / y

Doc/whatsnew/3.14.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ Other language changes
194194
:mod:`copyable <copy>`.
195195
(Contributed by Serhiy Storchaka in :gh:`125767`.)
196196

197+
* The :class:`memoryview` type now supports subscription,
198+
making it a :term:`generic type`.
199+
(Contributed by Brian Schubert in :gh:`126012`.)
200+
197201

198202
New modules
199203
===========
@@ -326,6 +330,10 @@ inspect
326330
If true, string :term:`annotations <annotation>` are displayed without surrounding quotes.
327331
(Contributed by Jelle Zijlstra in :gh:`101552`.)
328332

333+
* Add function :func:`inspect.ispackage` to determine whether an object is a
334+
:term:`package` or not.
335+
(Contributed by Zhikang Yan in :gh:`125634`.)
336+
329337

330338
json
331339
----

Lib/code.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ def _showtraceback(self, typ, value, tb, source):
136136
# Set the line of text that the exception refers to
137137
lines = source.splitlines()
138138
if (source and typ is SyntaxError
139-
and not value.text and len(lines) >= value.lineno):
139+
and not value.text and value.lineno is not None
140+
and len(lines) >= value.lineno):
140141
value.text = lines[value.lineno - 1]
141142
sys.last_exc = sys.last_value = value
142143
if sys.excepthook is sys.__excepthook__:

Lib/functools.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,14 @@ def reduce(function, sequence, initial=_initial_missing):
238238
"""
239239
reduce(function, iterable[, initial], /) -> value
240240
241-
Apply a function of two arguments cumulatively to the items of a sequence
242-
or iterable, from left to right, so as to reduce the iterable to a single
243-
value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates
244-
((((1+2)+3)+4)+5). If initial is present, it is placed before the items
245-
of the iterable in the calculation, and serves as a default when the
246-
iterable is empty.
241+
Apply a function of two arguments cumulatively to the items of an iterable, from left to right.
242+
243+
This effectively reduces the iterable to a single value. If initial is present,
244+
it is placed before the items of the iterable in the calculation, and serves as
245+
a default when the iterable is empty.
246+
247+
For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5])
248+
calculates ((((1 + 2) + 3) + 4) + 5).
247249
"""
248250

249251
it = iter(sequence)

Lib/inspect.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
77
Here are some of the useful functions provided by this module:
88
9-
ismodule(), isclass(), ismethod(), isfunction(), isgeneratorfunction(),
10-
isgenerator(), istraceback(), isframe(), iscode(), isbuiltin(),
11-
isroutine() - check object types
9+
ismodule(), isclass(), ismethod(), ispackage(), isfunction(),
10+
isgeneratorfunction(), isgenerator(), istraceback(), isframe(),
11+
iscode(), isbuiltin(), isroutine() - check object types
1212
getmembers() - get members of an object that satisfy a given condition
1313
1414
getfile(), getsourcefile(), getsource() - find an object's source code
@@ -128,6 +128,7 @@
128128
"ismethoddescriptor",
129129
"ismethodwrapper",
130130
"ismodule",
131+
"ispackage",
131132
"isroutine",
132133
"istraceback",
133134
"markcoroutinefunction",
@@ -186,6 +187,10 @@ def ismethod(object):
186187
"""Return true if the object is an instance method."""
187188
return isinstance(object, types.MethodType)
188189

190+
def ispackage(object):
191+
"""Return true if the object is a package."""
192+
return ismodule(object) and hasattr(object, "__path__")
193+
189194
def ismethoddescriptor(object):
190195
"""Return true if the object is a method descriptor.
191196

Lib/test/audit-tests.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,17 @@ def hook(event, args):
567567
_winapi.CreateNamedPipe(pipe_name, _winapi.PIPE_ACCESS_DUPLEX, 8, 2, 0, 0, 0, 0)
568568

569569

570+
def test_assert_unicode():
571+
import sys
572+
sys.addaudithook(lambda *args: None)
573+
try:
574+
sys.audit(9)
575+
except TypeError:
576+
pass
577+
else:
578+
raise RuntimeError("Expected sys.audit(9) to fail.")
579+
580+
570581
if __name__ == "__main__":
571582
from test.support import suppress_msvcrt_asserts
572583

0 commit comments

Comments
 (0)