Skip to content

Commit 7c9e141

Browse files
authored
Merge branch '3.14' into backport-5763bfd-3.14
2 parents 14a352a + 6337bfd commit 7c9e141

4 files changed

Lines changed: 45 additions & 9 deletions

File tree

Doc/c-api/exceptions.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -499,12 +499,12 @@ Querying the error indicator
499499
.. c:function:: void PyErr_SetRaisedException(PyObject *exc)
500500
501501
Set *exc* as the exception currently being raised,
502-
clearing the existing exception if one is set.
502+
clearing the existing exception if one is set. If *exc* is ``NULL``,
503+
just clear the existing exception.
503504
504-
.. warning::
505+
*exc* must be a valid exception or ``NULL``.
505506
506-
This call ":term:`steals <steal>`" a reference to *exc*,
507-
which must be a valid exception.
507+
This call ":term:`steals <steal>`" a reference to *exc*.
508508
509509
.. versionadded:: 3.12
510510

Doc/library/mimetypes.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,13 @@ behavior of the module.
118118
Previously, Windows registry settings were ignored.
119119

120120

121-
.. function:: read_mime_types(filename)
121+
.. function:: read_mime_types(file)
122122

123-
Load the type map given in the file *filename*, if it exists. The type map is
124-
returned as a dictionary mapping filename extensions, including the leading dot
125-
(``'.'``), to strings of the form ``'type/subtype'``. If the file *filename*
126-
does not exist or cannot be read, ``None`` is returned.
123+
Load the type map given in the file named by *file*, if it exists. *file*
124+
must be a string specifying the name of the file to read. The type map is
125+
returned as a dictionary mapping file extensions, including the leading dot
126+
(``'.'``), to strings of the form ``'type/subtype'``. If the file does not
127+
exist or cannot be read, ``None`` is returned.
127128

128129

129130
.. function:: add_type(type, ext, strict=True)

Doc/library/uu.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,9 @@ This module is no longer part of the Python standard library.
1111
It was :ref:`removed in Python 3.13 <whatsnew313-pep594>` after
1212
being deprecated in Python 3.11. The removal was decided in :pep:`594`.
1313

14+
Encoding and decoding in the uu format can instead be achieved using
15+
:func:`codecs.encode` and :func:`codecs.decode`, specifying ``"uu"``
16+
as the encoding.
17+
1418
The last version of Python that provided the :mod:`!uu` module was
1519
`Python 3.12 <https://docs.python.org/3.12/library/uu.html>`_.

Lib/test/test_getopt.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,18 @@ def test_getopt(self):
149149
('-a', ''), ('--alpha', '')])
150150
self.assertEqual(args, ['arg1', 'arg2'])
151151

152+
# Allow string for single long argument
153+
opts, args = getopt.getopt(cmdline, 'a::', 'alpha=?')
154+
self.assertEqual(opts, [('-a', '1'), ('--alpha', '2'), ('--alpha', ''),
155+
('-a', ''), ('--alpha', '')])
156+
self.assertEqual(args, ['arg1', 'arg2'])
157+
158+
# Pass everything after -- as args
159+
cmdline = ['-a1', '--alpha=2', '--', '-b', '--beta=5']
160+
opts, args = getopt.getopt(cmdline, 'a:b', ['alpha=', 'beta'])
161+
self.assertEqual(opts, [('-a', '1'), ('--alpha', '2')])
162+
self.assertEqual(args, ['-b', '--beta=5'])
163+
152164
self.assertError(getopt.getopt, cmdline, 'a:b', ['alpha', 'beta'])
153165

154166
def test_gnu_getopt(self):
@@ -191,6 +203,25 @@ def test_gnu_getopt(self):
191203
self.assertEqual(args, ['arg1', '-b', '1', '--alpha', '--beta=2',
192204
'--beta', '3', 'arg2'])
193205

206+
# Allow string for single long argument
207+
opts, args = getopt.gnu_getopt(cmdline, 'ab:', 'alpha')
208+
self.assertEqual(opts, [('-a', '')])
209+
self.assertEqual(args, ['arg1', '-b', '1', '--alpha', '--beta=2',
210+
'--beta', '3', 'arg2'])
211+
212+
# Pass everything after -- as args
213+
cmdline = ['-a1', '--alpha=2', '--', '-b', '--beta=5']
214+
opts, args = getopt.gnu_getopt(cmdline, 'a:b', ['alpha=', 'beta'])
215+
self.assertEqual(opts, [('-a', '1'), ('--alpha', '2')])
216+
self.assertEqual(args, ['-b', '--beta=5'])
217+
218+
# In order arguments
219+
cmdline = ["gamma", "--alpha=3"]
220+
opts, args = getopt.gnu_getopt(cmdline, '-', ["alpha="])
221+
self.assertEqual(opts, [(None, ['gamma']), ('--alpha', '3')])
222+
self.assertEqual(args, [])
223+
224+
194225
def test_issue4629(self):
195226
longopts, shortopts = getopt.getopt(['--help='], '', ['help='])
196227
self.assertEqual(longopts, [('--help', '')])

0 commit comments

Comments
 (0)