Skip to content

Commit 83ee5ee

Browse files
Deploy preview for PR 1193 🛫
1 parent e19f95e commit 83ee5ee

File tree

576 files changed

+787
-894
lines changed

Some content is hidden

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

576 files changed

+787
-894
lines changed

pr-preview/pr-1193/_sources/library/urllib.parse.rst.txt

Lines changed: 65 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ URL Parsing
5050
The URL parsing functions focus on splitting a URL string into its components,
5151
or on combining URL components into a URL string.
5252

53-
.. function:: urlparse(urlstring, scheme='', allow_fragments=True)
53+
.. function:: urlsplit(urlstring, scheme=None, allow_fragments=True)
5454

55-
Parse a URL into six components, returning a 6-item :term:`named tuple`. This
56-
corresponds to the general structure of a URL:
57-
``scheme://netloc/path;parameters?query#fragment``.
55+
Parse a URL into five components, returning a 5-item :term:`named tuple`
56+
:class:`SplitResult` or :class:`SplitResultBytes`.
57+
This corresponds to the general structure of a URL:
58+
``scheme://netloc/path?query#fragment``.
5859
Each tuple item is a string, possibly empty. The components are not broken up
5960
into smaller parts (for example, the network location is a single string), and %
6061
escapes are not expanded. The delimiters as shown above are not part of the
@@ -64,15 +65,15 @@ or on combining URL components into a URL string.
6465
.. doctest::
6566
:options: +NORMALIZE_WHITESPACE
6667

67-
>>> from urllib.parse import urlparse
68-
>>> urlparse("scheme://netloc/path;parameters?query#fragment")
69-
ParseResult(scheme='scheme', netloc='netloc', path='/path;parameters', params='',
68+
>>> from urllib.parse import urlsplit
69+
>>> urlsplit("scheme://netloc/path?query#fragment")
70+
SplitResult(scheme='scheme', netloc='netloc', path='/path',
7071
query='query', fragment='fragment')
71-
>>> o = urlparse("http://docs.python.org:80/3/library/urllib.parse.html?"
72+
>>> o = urlsplit("http://docs.python.org:80/3/library/urllib.parse.html?"
7273
... "highlight=params#url-parsing")
7374
>>> o
74-
ParseResult(scheme='http', netloc='docs.python.org:80',
75-
path='/3/library/urllib.parse.html', params='',
75+
SplitResult(scheme='http', netloc='docs.python.org:80',
76+
path='/3/library/urllib.parse.html',
7677
query='highlight=params', fragment='url-parsing')
7778
>>> o.scheme
7879
'http'
@@ -85,23 +86,23 @@ or on combining URL components into a URL string.
8586
>>> o._replace(fragment="").geturl()
8687
'http://docs.python.org:80/3/library/urllib.parse.html?highlight=params'
8788

88-
Following the syntax specifications in :rfc:`1808`, urlparse recognizes
89+
Following the syntax specifications in :rfc:`1808`, :func:`!urlsplit` recognizes
8990
a netloc only if it is properly introduced by '//'. Otherwise the
9091
input is presumed to be a relative URL and thus to start with
9192
a path component.
9293

9394
.. doctest::
9495
:options: +NORMALIZE_WHITESPACE
9596

96-
>>> from urllib.parse import urlparse
97-
>>> urlparse('//www.cwi.nl:80/%7Eguido/Python.html')
98-
ParseResult(scheme='', netloc='www.cwi.nl:80', path='/%7Eguido/Python.html',
99-
params='', query='', fragment='')
100-
>>> urlparse('www.cwi.nl/%7Eguido/Python.html')
101-
ParseResult(scheme='', netloc='', path='www.cwi.nl/%7Eguido/Python.html',
102-
params='', query='', fragment='')
103-
>>> urlparse('help/Python.html')
104-
ParseResult(scheme='', netloc='', path='help/Python.html', params='',
97+
>>> from urllib.parse import urlsplit
98+
>>> urlsplit('//www.cwi.nl:80/%7Eguido/Python.html')
99+
SplitResult(scheme='', netloc='www.cwi.nl:80', path='/%7Eguido/Python.html',
100+
query='', fragment='')
101+
>>> urlsplit('www.cwi.nl/%7Eguido/Python.html')
102+
SplitResult(scheme='', netloc='', path='www.cwi.nl/%7Eguido/Python.html',
103+
query='', fragment='')
104+
>>> urlsplit('help/Python.html')
105+
SplitResult(scheme='', netloc='', path='help/Python.html',
105106
query='', fragment='')
106107

107108
The *scheme* argument gives the default addressing scheme, to be
@@ -126,12 +127,9 @@ or on combining URL components into a URL string.
126127
+------------------+-------+-------------------------+------------------------+
127128
| :attr:`path` | 2 | Hierarchical path | empty string |
128129
+------------------+-------+-------------------------+------------------------+
129-
| :attr:`params` | 3 | Parameters for last | empty string |
130-
| | | path element | |
131-
+------------------+-------+-------------------------+------------------------+
132-
| :attr:`query` | 4 | Query component | empty string |
130+
| :attr:`query` | 3 | Query component | empty string |
133131
+------------------+-------+-------------------------+------------------------+
134-
| :attr:`fragment` | 5 | Fragment identifier | empty string |
132+
| :attr:`fragment` | 4 | Fragment identifier | empty string |
135133
+------------------+-------+-------------------------+------------------------+
136134
| :attr:`username` | | User name | :const:`None` |
137135
+------------------+-------+-------------------------+------------------------+
@@ -155,26 +153,30 @@ or on combining URL components into a URL string.
155153
``#``, ``@``, or ``:`` will raise a :exc:`ValueError`. If the URL is
156154
decomposed before parsing, no error will be raised.
157155

156+
Following some of the `WHATWG spec`_ that updates :rfc:`3986`, leading C0
157+
control and space characters are stripped from the URL. ``\n``,
158+
``\r`` and tab ``\t`` characters are removed from the URL at any position.
159+
158160
As is the case with all named tuples, the subclass has a few additional methods
159161
and attributes that are particularly useful. One such method is :meth:`_replace`.
160-
The :meth:`_replace` method will return a new ParseResult object replacing specified
161-
fields with new values.
162+
The :meth:`_replace` method will return a new :class:`SplitResult` object
163+
replacing specified fields with new values.
162164

163165
.. doctest::
164166
:options: +NORMALIZE_WHITESPACE
165167

166-
>>> from urllib.parse import urlparse
167-
>>> u = urlparse('//www.cwi.nl:80/%7Eguido/Python.html')
168+
>>> from urllib.parse import urlsplit
169+
>>> u = urlsplit('//www.cwi.nl:80/%7Eguido/Python.html')
168170
>>> u
169-
ParseResult(scheme='', netloc='www.cwi.nl:80', path='/%7Eguido/Python.html',
170-
params='', query='', fragment='')
171+
SplitResult(scheme='', netloc='www.cwi.nl:80', path='/%7Eguido/Python.html',
172+
query='', fragment='')
171173
>>> u._replace(scheme='http')
172-
ParseResult(scheme='http', netloc='www.cwi.nl:80', path='/%7Eguido/Python.html',
173-
params='', query='', fragment='')
174+
SplitResult(scheme='http', netloc='www.cwi.nl:80', path='/%7Eguido/Python.html',
175+
query='', fragment='')
174176

175177
.. warning::
176178

177-
:func:`urlparse` does not perform validation. See :ref:`URL parsing
179+
:func:`urlsplit` does not perform validation. See :ref:`URL parsing
178180
security <url-parsing-security>` for details.
179181

180182
.. versionchanged:: 3.2
@@ -193,6 +195,14 @@ or on combining URL components into a URL string.
193195
Characters that affect netloc parsing under NFKC normalization will
194196
now raise :exc:`ValueError`.
195197

198+
.. versionchanged:: 3.10
199+
ASCII newline and tab characters are stripped from the URL.
200+
201+
.. versionchanged:: 3.12
202+
Leading WHATWG C0 control and space characters are stripped from the URL.
203+
204+
.. _WHATWG spec: https://url.spec.whatwg.org/#concept-basic-url-parser
205+
196206

197207
.. function:: parse_qs(qs, keep_blank_values=False, strict_parsing=False, encoding='utf-8', errors='replace', max_num_fields=None, separator='&')
198208

@@ -287,93 +297,35 @@ or on combining URL components into a URL string.
287297
separator key, with ``&`` as the default separator.
288298

289299

290-
.. function:: urlunparse(parts)
300+
.. function:: urlunsplit(parts)
291301

292-
Construct a URL from a tuple as returned by ``urlparse()``. The *parts*
293-
argument can be any six-item iterable. This may result in a slightly
302+
Construct a URL from a tuple as returned by ``urlsplit()``. The *parts*
303+
argument can be any five-item iterable. This may result in a slightly
294304
different, but equivalent URL, if the URL that was parsed originally had
295305
unnecessary delimiters (for example, a ``?`` with an empty query; the RFC
296306
states that these are equivalent).
297307

298308

299-
.. function:: urlsplit(urlstring, scheme='', allow_fragments=True)
300-
301-
This is similar to :func:`urlparse`, but does not split the params from the URL.
302-
This should generally be used instead of :func:`urlparse` if the more recent URL
303-
syntax allowing parameters to be applied to each segment of the *path* portion
304-
of the URL (see :rfc:`2396`) is wanted. A separate function is needed to
305-
separate the path segments and parameters. This function returns a 5-item
306-
:term:`named tuple`::
307-
308-
(addressing scheme, network location, path, query, fragment identifier).
309-
310-
The return value is a :term:`named tuple`, its items can be accessed by index
311-
or as named attributes:
312-
313-
+------------------+-------+-------------------------+----------------------+
314-
| Attribute | Index | Value | Value if not present |
315-
+==================+=======+=========================+======================+
316-
| :attr:`scheme` | 0 | URL scheme specifier | *scheme* parameter |
317-
+------------------+-------+-------------------------+----------------------+
318-
| :attr:`netloc` | 1 | Network location part | empty string |
319-
+------------------+-------+-------------------------+----------------------+
320-
| :attr:`path` | 2 | Hierarchical path | empty string |
321-
+------------------+-------+-------------------------+----------------------+
322-
| :attr:`query` | 3 | Query component | empty string |
323-
+------------------+-------+-------------------------+----------------------+
324-
| :attr:`fragment` | 4 | Fragment identifier | empty string |
325-
+------------------+-------+-------------------------+----------------------+
326-
| :attr:`username` | | User name | :const:`None` |
327-
+------------------+-------+-------------------------+----------------------+
328-
| :attr:`password` | | Password | :const:`None` |
329-
+------------------+-------+-------------------------+----------------------+
330-
| :attr:`hostname` | | Host name (lower case) | :const:`None` |
331-
+------------------+-------+-------------------------+----------------------+
332-
| :attr:`port` | | Port number as integer, | :const:`None` |
333-
| | | if present | |
334-
+------------------+-------+-------------------------+----------------------+
335-
336-
Reading the :attr:`port` attribute will raise a :exc:`ValueError` if
337-
an invalid port is specified in the URL. See section
338-
:ref:`urlparse-result-object` for more information on the result object.
339-
340-
Unmatched square brackets in the :attr:`netloc` attribute will raise a
341-
:exc:`ValueError`.
342-
343-
Characters in the :attr:`netloc` attribute that decompose under NFKC
344-
normalization (as used by the IDNA encoding) into any of ``/``, ``?``,
345-
``#``, ``@``, or ``:`` will raise a :exc:`ValueError`. If the URL is
346-
decomposed before parsing, no error will be raised.
347-
348-
Following some of the `WHATWG spec`_ that updates RFC 3986, leading C0
349-
control and space characters are stripped from the URL. ``\n``,
350-
``\r`` and tab ``\t`` characters are removed from the URL at any position.
351-
352-
.. warning::
353-
354-
:func:`urlsplit` does not perform validation. See :ref:`URL parsing
355-
security <url-parsing-security>` for details.
309+
.. function:: urlparse(urlstring, scheme=None, allow_fragments=True)
356310

357-
.. versionchanged:: 3.6
358-
Out-of-range port numbers now raise :exc:`ValueError`, instead of
359-
returning :const:`None`.
311+
This is similar to :func:`urlsplit`, but additionally splits the *path*
312+
component on *path* and *params*.
313+
This function returns a 6-item :term:`named tuple` :class:`ParseResult`
314+
or :class:`ParseResultBytes`.
315+
Its items are the same as for the :func:`!urlsplit` result, except that
316+
*params* is inserted at index 3, between *path* and *query*.
360317

361-
.. versionchanged:: 3.8
362-
Characters that affect netloc parsing under NFKC normalization will
363-
now raise :exc:`ValueError`.
318+
This function is based on obsoleted :rfc:`1738` and :rfc:`1808`, which
319+
listed *params* as the main URL component.
320+
The more recent URL syntax allows parameters to be applied to each segment
321+
of the *path* portion of the URL (see :rfc:`3986`).
322+
:func:`urlsplit` should generally be used instead of :func:`urlparse`.
323+
A separate function is needed to separate the path segments and parameters.
364324

365-
.. versionchanged:: 3.10
366-
ASCII newline and tab characters are stripped from the URL.
367-
368-
.. versionchanged:: 3.12
369-
Leading WHATWG C0 control and space characters are stripped from the URL.
370-
371-
.. _WHATWG spec: https://url.spec.whatwg.org/#concept-basic-url-parser
372-
373-
.. function:: urlunsplit(parts)
325+
.. function:: urlunparse(parts)
374326

375-
Combine the elements of a tuple as returned by :func:`urlsplit` into a
376-
complete URL as a string. The *parts* argument can be any five-item
327+
Combine the elements of a tuple as returned by :func:`urlparse` into a
328+
complete URL as a string. The *parts* argument can be any six-item
377329
iterable. This may result in a slightly different, but equivalent URL, if the
378330
URL that was parsed originally had unnecessary delimiters (for example, a ?
379331
with an empty query; the RFC states that these are equivalent).
@@ -391,7 +343,7 @@ or on combining URL components into a URL string.
391343
'http://www.cwi.nl/%7Eguido/FAQ.html'
392344

393345
The *allow_fragments* argument has the same meaning and default as for
394-
:func:`urlparse`.
346+
:func:`urlsplit`.
395347

396348
.. note::
397349

@@ -531,7 +483,7 @@ individual URL quoting functions.
531483
Structured Parse Results
532484
------------------------
533485

534-
The result objects from the :func:`urlparse`, :func:`urlsplit` and
486+
The result objects from the :func:`urlsplit`, :func:`urlparse` and
535487
:func:`urldefrag` functions are subclasses of the :class:`tuple` type.
536488
These subclasses add the attributes listed in the documentation for
537489
those functions, the encoding and decoding support described in the

pr-preview/pr-1193/_sources/library/venv.rst.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ subclass which installs setuptools and pip into a created virtual environment::
545545
from subprocess import Popen, PIPE
546546
import sys
547547
from threading import Thread
548-
from urllib.parse import urlparse
548+
from urllib.parse import urlsplit
549549
from urllib.request import urlretrieve
550550
import venv
551551

@@ -616,7 +616,7 @@ subclass which installs setuptools and pip into a created virtual environment::
616616
stream.close()
617617

618618
def install_script(self, context, name, url):
619-
_, _, path, _, _, _ = urlparse(url)
619+
_, _, path, _, _ = urlsplit(url)
620620
fn = os.path.split(path)[-1]
621621
binpath = context.bin_path
622622
distpath = os.path.join(binpath, fn)

pr-preview/pr-1193/_sources/library/wsgiref.rst.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111

1212
--------------
1313

14+
.. warning::
15+
16+
:mod:`wsgiref` is a reference implementation and is not recommended for
17+
production. The module only implements basic security checks.
18+
1419
The Web Server Gateway Interface (WSGI) is a standard interface between web
1520
server software and web applications written in Python. Having a standard
1621
interface makes it easy to use an application that supports WSGI with a number

pr-preview/pr-1193/_sources/reference/simple_stmts.rst.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,9 @@ where the :keyword:`import` statement occurs.
831831

832832
The *public names* defined by a module are determined by checking the module's
833833
namespace for a variable named ``__all__``; if defined, it must be a sequence
834-
of strings which are names defined or imported by that module. The names
834+
of strings which are names defined or imported by that module.
835+
Names containing non-ASCII characters must be in the `normalization form`_
836+
NFKC; see :ref:`lexical-names-nonascii` for details. The names
835837
given in ``__all__`` are all considered public and are required to exist. If
836838
``__all__`` is not defined, the set of public names includes all names found
837839
in the module's namespace which do not begin with an underscore character
@@ -865,6 +867,8 @@ determine dynamically the modules to be loaded.
865867

866868
.. audit-event:: import module,filename,sys.path,sys.meta_path,sys.path_hooks import
867869

870+
.. _normalization form: https://www.unicode.org/reports/tr15/#Norm_Forms
871+
868872
.. _future:
869873

870874
Future statements

pr-preview/pr-1193/about.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ <h3>導航</h3>
326326
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
327327
<br>
328328
<br>
329-
最後更新於 2月 05, 2026 (14:16 UTC)。
329+
最後更新於 2月 06, 2026 (00:24 UTC)。
330330

331331
<a href="/bugs.html">發現 bug</a>
332332

pr-preview/pr-1193/bugs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ <h3>導航</h3>
363363
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
364364
<br>
365365
<br>
366-
最後更新於 2月 05, 2026 (14:16 UTC)。
366+
最後更新於 2月 06, 2026 (00:24 UTC)。
367367

368368
<a href="/bugs.html">發現 bug</a>
369369

pr-preview/pr-1193/c-api/abstract.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ <h3>導航</h3>
335335
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
336336
<br>
337337
<br>
338-
最後更新於 2月 05, 2026 (14:16 UTC)。
338+
最後更新於 2月 06, 2026 (00:24 UTC)。
339339

340340
<a href="/bugs.html">發現 bug</a>
341341

pr-preview/pr-1193/c-api/allocation.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ <h3>導航</h3>
544544
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
545545
<br>
546546
<br>
547-
最後更新於 2月 05, 2026 (14:16 UTC)。
547+
最後更新於 2月 06, 2026 (00:24 UTC)。
548548

549549
<a href="/bugs.html">發現 bug</a>
550550

pr-preview/pr-1193/c-api/apiabiversion.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ <h3>導航</h3>
484484
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
485485
<br>
486486
<br>
487-
最後更新於 2月 05, 2026 (14:16 UTC)。
487+
最後更新於 2月 06, 2026 (00:24 UTC)。
488488

489489
<a href="/bugs.html">發現 bug</a>
490490

pr-preview/pr-1193/c-api/arg.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ <h3>導航</h3>
966966
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
967967
<br>
968968
<br>
969-
最後更新於 2月 05, 2026 (14:16 UTC)。
969+
最後更新於 2月 06, 2026 (00:24 UTC)。
970970

971971
<a href="/bugs.html">發現 bug</a>
972972

0 commit comments

Comments
 (0)