Skip to content

Commit 05a2366

Browse files
authored
Merge branch 'main' into TracebackException-swallows-cause-context-flasey-exception
2 parents 3f59327 + d87e7f3 commit 05a2366

35 files changed

+252
-125
lines changed

Doc/library/annotationlib.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,12 @@ Functions
303303
.. function:: get_annotate_function(obj)
304304

305305
Retrieve the :term:`annotate function` for *obj*. Return :const:`!None`
306-
if *obj* does not have an annotate function.
306+
if *obj* does not have an annotate function. *obj* may be a class, function,
307+
module, or a namespace dictionary for a class. The last case is useful during
308+
class creation, e.g. in the ``__new__`` method of a metaclass.
307309

308310
This is usually equivalent to accessing the :attr:`~object.__annotate__`
309-
attribute of *obj*, but direct access to the attribute may return the wrong
310-
object in certain situations involving metaclasses. This function should be
311-
used instead of accessing the attribute directly.
311+
attribute of *obj*, but access through this public function is preferred.
312312

313313
.. versionadded:: 3.14
314314

Doc/library/pathlib.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,12 @@ conforming to :rfc:`8089`.
871871

872872
.. versionadded:: 3.13
873873

874+
.. versionchanged:: next
875+
If a URL authority (e.g. a hostname) is present and resolves to a local
876+
address, it is discarded. If an authority is present and *doesn't*
877+
resolve to a local address, then on Windows a UNC path is returned (as
878+
before), and on other platforms a :exc:`ValueError` is raised.
879+
874880

875881
.. method:: Path.as_uri()
876882

Doc/library/re.rst

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,23 @@ The special characters are:
250250
``[a\-z]``) or if it's placed as the first or last character
251251
(e.g. ``[-a]`` or ``[a-]``), it will match a literal ``'-'``.
252252

253-
* Special characters lose their special meaning inside sets. For example,
253+
* Special characters except backslash lose their special meaning inside sets.
254+
For example,
254255
``[(+*)]`` will match any of the literal characters ``'('``, ``'+'``,
255256
``'*'``, or ``')'``.
256257

257258
.. index:: single: \ (backslash); in regular expressions
258259

259-
* Character classes such as ``\w`` or ``\S`` (defined below) are also accepted
260-
inside a set, although the characters they match depend on the flags_ used.
260+
* Backslash either escapes characters which have special meaning in a set
261+
such as ``'-'``, ``']'``, ``'^'`` and ``'\\'`` itself or signals
262+
a special sequence which represents a single character such as
263+
``\xa0`` or ``\n`` or a character class such as ``\w`` or ``\S``
264+
(defined below).
265+
Note that ``\b`` represents a single "backspace" character,
266+
not a word boundary as outside a set, and numeric escapes
267+
such as ``\1`` are always octal escapes, not group references.
268+
Special sequences which do not match a single character such as ``\A``
269+
and ``\Z`` are not allowed.
261270

262271
.. index:: single: ^ (caret); in regular expressions
263272

Doc/library/urllib.request.rst

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,16 @@ The :mod:`urllib.request` module defines the following functions:
158158
>>> 'file:' + pathname2url(path)
159159
'file:///C:/Program%20Files'
160160

161-
.. versionchanged:: 3.14
162-
Paths beginning with a slash are converted to URLs with authority
163-
sections. For example, the path ``/etc/hosts`` is converted to
164-
the URL ``///etc/hosts``.
165-
166161
.. versionchanged:: 3.14
167162
Windows drive letters are no longer converted to uppercase, and ``:``
168163
characters not following a drive letter no longer cause an
169164
:exc:`OSError` exception to be raised on Windows.
170165

166+
.. versionchanged:: 3.14
167+
Paths beginning with a slash are converted to URLs with authority
168+
sections. For example, the path ``/etc/hosts`` is converted to
169+
the URL ``///etc/hosts``.
170+
171171

172172
.. function:: url2pathname(url)
173173

@@ -186,6 +186,13 @@ The :mod:`urllib.request` module defines the following functions:
186186
characters not following a drive letter no longer cause an
187187
:exc:`OSError` exception to be raised on Windows.
188188

189+
.. versionchanged:: next
190+
This function calls :func:`socket.gethostbyname` if the URL authority
191+
isn't empty or ``localhost``. If the authority resolves to a local IP
192+
address then it is discarded; otherwise, on Windows a UNC path is
193+
returned (as before), and on other platforms a
194+
:exc:`~urllib.error.URLError` is raised.
195+
189196

190197
.. function:: getproxies()
191198

Doc/whatsnew/3.14.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,6 +1197,25 @@ urllib
11971197
supporting SHA-256 digest authentication as specified in :rfc:`7616`.
11981198
(Contributed by Calvin Bui in :gh:`128193`.)
11991199

1200+
* Improve standards compliance when parsing and emitting ``file:`` URLs.
1201+
1202+
In :func:`urllib.request.url2pathname`:
1203+
1204+
- Discard URL authorities that resolve to a local IP address.
1205+
- Raise :exc:`~urllib.error.URLError` if a URL authority doesn't resolve
1206+
to ``localhost``, except on Windows where we return a UNC path.
1207+
1208+
In :func:`urllib.request.pathname2url`:
1209+
1210+
- Include an empty URL authority when a path begins with a slash. For
1211+
example, the path ``/etc/hosts`` is converted to the URL ``///etc/hosts``.
1212+
1213+
On Windows, drive letters are no longer converted to uppercase, and ``:``
1214+
characters not following a drive letter no longer cause an :exc:`OSError`
1215+
exception to be raised.
1216+
1217+
(Contributed by Barney Gale in :gh:`125866`.)
1218+
12001219

12011220
uuid
12021221
----

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_global_strings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ struct _Py_global_strings {
7878
STRUCT_FOR_ID(__and__)
7979
STRUCT_FOR_ID(__anext__)
8080
STRUCT_FOR_ID(__annotate__)
81+
STRUCT_FOR_ID(__annotate_func__)
8182
STRUCT_FOR_ID(__annotations__)
83+
STRUCT_FOR_ID(__annotations_cache__)
8284
STRUCT_FOR_ID(__args__)
8385
STRUCT_FOR_ID(__await__)
8486
STRUCT_FOR_ID(__bases__)

Include/internal/pycore_magic_number.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ Known values:
274274
Python 3.14a6 3619 (Renumber RESUME opcode from 149 to 128)
275275
Python 3.14a6 3620 (Optimize bytecode for all/any/tuple called on a genexp)
276276
Python 3.14a7 3621 (Optimize LOAD_FAST opcodes into LOAD_FAST_BORROW)
277+
Python 3.14a7 3622 (Store annotations in different class dict keys)
277278
278279
Python 3.15 will start with 3650
279280
@@ -286,7 +287,7 @@ PC/launcher.c must also be updated.
286287
287288
*/
288289

289-
#define PYC_MAGIC_NUMBER 3621
290+
#define PYC_MAGIC_NUMBER 3622
290291
/* This is equivalent to converting PYC_MAGIC_NUMBER to 2 bytes
291292
(little-endian) and then appending b'\r\n'. */
292293
#define PYC_MAGIC_NUMBER_TOKEN \

Include/internal/pycore_runtime_init_generated.h

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_unicodeobject_generated.h

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)