Skip to content

Commit 5ae2c33

Browse files
authored
Merge branch 'main' into unicode-stringprep
2 parents 02a21af + 7c653e2 commit 5ae2c33

18 files changed

Lines changed: 93 additions & 35 deletions

Doc/c-api/arg.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,13 +399,18 @@ inside nested parentheses. They are:
399399
their default value --- when an optional argument is not specified,
400400
:c:func:`PyArg_ParseTuple` does not touch the contents of the corresponding C
401401
variable(s).
402+
For example, the format string ``"OO|OO"`` corresponds to the Python
403+
signature ``f(a, b, c=None, d=None)``.
402404

403405
``$``
404406
:c:func:`PyArg_ParseTupleAndKeywords` only:
405407
Indicates that the remaining arguments in the Python argument list are
406-
keyword-only. Currently, all keyword-only arguments must also be optional
407-
arguments, so ``|`` must always be specified before ``$`` in the format
408-
string.
408+
keyword-only.
409+
They are optional if ``|`` was specified before ``$``, and required otherwise.
410+
``|`` cannot be specified after ``$``.
411+
For example, the format string ``"O|O$O"`` corresponds to the Python
412+
signature ``f(a, b=None, *, c=None)``,
413+
and the format string ``"OO$OO"`` corresponds to ``f(a, b, *, c, d)``.
409414

410415
.. versionadded:: 3.3
411416

Doc/library/subprocess.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ underlying :class:`Popen` interface can be used directly.
236236

237237
.. attribute:: returncode
238238

239-
Exit status of the child process. If the process exited due to a
240-
signal, this will be the negative signal number.
239+
Exit status of the child process, an integer. If the process
240+
exited due to a signal, this will be the negative signal number.
241241

242242
.. attribute:: cmd
243243

Doc/library/zipfile.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,10 @@ ZipFile objects
285285
Added support for specifying member name encoding for reading
286286
metadata in the zipfile's directory and file headers.
287287

288+
.. versionchanged:: next
289+
Deleting a writable, open :class:`zipfile.ZipFile` now emits a
290+
:exc:`ResourceWarning`. Use as a :term:`context manager` or call
291+
:meth:`~zipfile.ZipFile.close` explicitly.
288292

289293
.. method:: ZipFile.close()
290294

Lib/subprocess.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,16 @@ def __init__(self, returncode, cmd, output=None, stderr=None):
143143
self.stderr = stderr
144144

145145
def __str__(self):
146-
if self.returncode and self.returncode < 0:
146+
if isinstance(self.returncode, int) and self.returncode < 0:
147147
try:
148148
return "Command %r died with %r." % (
149149
self.cmd, signal.Signals(-self.returncode))
150150
except ValueError:
151151
return "Command %r died with unknown signal %d." % (
152152
self.cmd, -self.returncode)
153153
else:
154-
return "Command %r returned non-zero exit status %d." % (
155-
self.cmd, self.returncode)
154+
return (f"Command {self.cmd!r} returned non-zero "
155+
f"exit status {self.returncode}.")
156156

157157
@property
158158
def stdout(self):

Lib/test/test_bigmem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ def test_repeat_small(self, size):
901901
def test_repeat_large(self, size):
902902
return self.basic_test_repeat(size)
903903

904-
@bigmemtest(size=_1G - 1, memuse=12)
904+
@bigmemtest(size=_1G - 1, memuse=pointer_size * 3)
905905
def test_repeat_large_2(self, size):
906906
return self.basic_test_repeat(size)
907907

Lib/test/test_hashlib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,12 +691,12 @@ def test_case_md5_2(self):
691691
)
692692

693693
@unittest.skipIf(sys.maxsize < _4G + 5, 'test cannot run on 32-bit systems')
694-
@bigmemtest(size=_4G + 5, memuse=1, dry_run=False)
694+
@bigmemtest(size=_4G + 5, memuse=2, dry_run=False)
695695
def test_case_md5_huge(self, size):
696696
self.check('md5', b'A'*size, 'c9af2dff37468ce5dfee8f2cfc0a9c6d')
697697

698698
@unittest.skipIf(sys.maxsize < _4G - 1, 'test cannot run on 32-bit systems')
699-
@bigmemtest(size=_4G - 1, memuse=1, dry_run=False)
699+
@bigmemtest(size=_4G - 1, memuse=2, dry_run=False)
700700
def test_case_md5_uintmax(self, size):
701701
self.check('md5', b'A'*size, '28138d306ff1b8281f1a9067e1a1a2b3')
702702

Lib/test/test_re.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2251,7 +2251,7 @@ def test_large_search(self, size):
22512251

22522252
# The huge memuse is because of re.sub() using a list and a join()
22532253
# to create the replacement result.
2254-
@bigmemtest(size=_2G, memuse=16 + 2)
2254+
@bigmemtest(size=_2G, memuse=16 + 3)
22552255
def test_large_subn(self, size):
22562256
# Issue #10182: indices were 32-bit-truncated.
22572257
s = 'a' * size

Lib/test/test_subprocess.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2449,6 +2449,16 @@ def test_CalledProcessError_str(self):
24492449
err = subprocess.CalledProcessError(-9876543, "fake cmd")
24502450
self.assertEqual(str(err), "Command 'fake cmd' died with unknown signal 9876543.")
24512451

2452+
# returncode which is not an integer, which happens for example when
2453+
# Popen is mocked: str() must not fail
2454+
for returncode in (None, "2", 2.5, [2]):
2455+
with self.subTest(returncode=returncode):
2456+
err = subprocess.CalledProcessError(returncode, "fake cmd")
2457+
self.assertEqual(
2458+
str(err),
2459+
f"Command 'fake cmd' returned non-zero "
2460+
f"exit status {returncode}.")
2461+
24522462
def test_preexec(self):
24532463
# DISCLAIMER: Setting environment variables is *not* a good use
24542464
# of a preexec_fn. This is merely a test.

Lib/test/test_tcl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ def test_huge_string_call(self, size):
805805

806806
@support.cpython_only
807807
@unittest.skipUnless(INT_MAX < PY_SSIZE_T_MAX, "needs UINT_MAX < SIZE_MAX")
808-
@support.bigmemtest(size=INT_MAX + 1, memuse=2, dry_run=False)
808+
@support.bigmemtest(size=INT_MAX + 1, memuse=3, dry_run=False)
809809
def test_huge_string_builtins(self, size):
810810
tk = self.interp.tk
811811
value = '1' + ' ' * size

Lib/test/test_typing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9806,6 +9806,7 @@ def test_order_in_union(self):
98069806
for args in itertools.permutations(get_args(expr1)):
98079807
with self.subTest(args=args):
98089808
self.assertEqual(expr1, reduce(operator.or_, args))
9809+
self.assertEqual(expr1, Union[args])
98099810

98109811
expr2 = Union[Annotated[int, 1], str, Annotated[str, {}], int]
98119812
for args in itertools.permutations(get_args(expr2)):

0 commit comments

Comments
 (0)