Skip to content

Commit 7d59b7e

Browse files
Rename allow_none to missing_as_none.
1 parent b578c9d commit 7d59b7e

File tree

5 files changed

+126
-124
lines changed

5 files changed

+126
-124
lines changed

Doc/library/urllib.parse.rst

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,15 @@ 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=None, allow_fragments=True, *, allow_none=False)
53+
.. function:: urlparse(urlstring, scheme=None, allow_fragments=True, *, missing_as_none=False)
5454

5555
Parse a URL into six components, returning a 6-item :term:`named tuple`. This
5656
corresponds to the general structure of a URL:
5757
``scheme://netloc/path;parameters?query#fragment``.
58-
Each tuple item is a string, possibly empty, or ``None`` if *allow_none* is true.
58+
Each tuple item is a string, possibly empty, or ``None`` if
59+
*missing_as_none* is true.
5960
Not defined component are represented an empty string (by default) or
60-
``None`` if *allow_none* is true.
61+
``None`` if *missing_as_none* is true.
6162
The components are not broken up
6263
into smaller parts (for example, the network location is a single string), and %
6364
escapes are not expanded. The delimiters as shown above are not part of the
@@ -90,7 +91,7 @@ or on combining URL components into a URL string.
9091
>>> urlparse("http://docs.python.org?")
9192
ParseResult(scheme='http', netloc='docs.python.org',
9293
path='', params='', query='', fragment='')
93-
>>> urlparse("http://docs.python.org?", allow_none=True)
94+
>>> urlparse("http://docs.python.org?", missing_as_none=True)
9495
ParseResult(scheme='http', netloc='docs.python.org',
9596
path='', params=None, query='', fragment=None)
9697

@@ -112,7 +113,7 @@ or on combining URL components into a URL string.
112113
>>> urlparse('help/Python.html')
113114
ParseResult(scheme='', netloc='', path='help/Python.html',
114115
params='', query='', fragment='')
115-
>>> urlparse('help/Python.html', allow_none=True)
116+
>>> urlparse('help/Python.html', missing_as_none=True)
116117
ParseResult(scheme=None, netloc=None, path='help/Python.html',
117118
params=None, query=None, fragment=None)
118119

@@ -124,7 +125,7 @@ or on combining URL components into a URL string.
124125
If the *allow_fragments* argument is false, fragment identifiers are not
125126
recognized. Instead, they are parsed as part of the path, parameters
126127
or query component, and :attr:`fragment` is set to ``None`` or the empty
127-
string (depending on the value of *allow_none*) in the return value.
128+
string (depending on the value of *missing_as_none*) in the return value.
128129

129130
The return value is a :term:`named tuple`, which means that its items can
130131
be accessed by index or as named attributes, which are:
@@ -156,7 +157,7 @@ or on combining URL components into a URL string.
156157
| | | if present | |
157158
+------------------+-------+-------------------------+-------------------------------+
158159

159-
.. [1] Depending on the value of the *allow_none* argument.
160+
.. [1] Depending on the value of the *missing_as_none* argument.
160161
161162
Reading the :attr:`port` attribute will raise a :exc:`ValueError` if
162163
an invalid port is specified in the URL. See section
@@ -209,7 +210,7 @@ or on combining URL components into a URL string.
209210
now raise :exc:`ValueError`.
210211

211212
.. versionchanged:: next
212-
Added the *allow_none* parameter.
213+
Added the *missing_as_none* parameter.
213214

214215

215216
.. function:: parse_qs(qs, keep_blank_values=False, strict_parsing=False, encoding='utf-8', errors='replace', max_num_fields=None, separator='&')
@@ -317,15 +318,15 @@ or on combining URL components into a URL string.
317318
If *keep_empty* is true, empty strings are kept in the result (for example,
318319
a ``?`` for an empty query), only ``None`` components are omitted.
319320
This allows to restore the URL that was parsed with option
320-
``allow_none=True``.
321+
``missing_as_none=True``.
321322
By default, *keep_empty* is true if *parts* is the result of the
322-
:func:`urlparse` call with ``allow_none=True``.
323+
:func:`urlparse` call with ``missing_as_none=True``.
323324

324325
.. versionchanged:: next
325326
Added the *keep_empty* parameter.
326327

327328

328-
.. function:: urlsplit(urlstring, scheme=None, allow_fragments=True, *, allow_none=False)
329+
.. function:: urlsplit(urlstring, scheme=None, allow_fragments=True, *, missing_as_none=False)
329330

330331
This is similar to :func:`urlparse`, but does not split the params from the URL.
331332
This should generally be used instead of :func:`urlparse` if the more recent URL
@@ -363,7 +364,7 @@ or on combining URL components into a URL string.
363364
| | | if present | |
364365
+------------------+-------+-------------------------+-------------------------------+
365366

366-
.. [2] Depending on the value of the *allow_none* argument.
367+
.. [2] Depending on the value of the *missing_as_none* argument.
367368
368369
Reading the :attr:`port` attribute will raise a :exc:`ValueError` if
369370
an invalid port is specified in the URL. See section
@@ -401,7 +402,7 @@ or on combining URL components into a URL string.
401402
Leading WHATWG C0 control and space characters are stripped from the URL.
402403

403404
.. versionchanged:: next
404-
Added the *allow_none* parameter.
405+
Added the *missing_as_none* parameter.
405406

406407
.. _WHATWG spec: https://url.spec.whatwg.org/#concept-basic-url-parser
407408

@@ -418,9 +419,9 @@ or on combining URL components into a URL string.
418419
If *keep_empty* is true, empty strings are kept in the result (for example,
419420
a ``?`` for an empty query), only ``None`` components are omitted.
420421
This allows to restore the URL that was parsed with option
421-
``allow_none=True``.
422+
``missing_as_none=True``.
422423
By default, *keep_empty* is true if *parts* is the result of the
423-
:func:`urlsplit` call with ``allow_none=True``.
424+
:func:`urlsplit` call with ``missing_as_none=True``.
424425

425426
.. versionchanged:: next
426427
Added the *keep_empty* parameter.
@@ -469,12 +470,12 @@ or on combining URL components into a URL string.
469470
Behavior updated to match the semantics defined in :rfc:`3986`.
470471

471472

472-
.. function:: urldefrag(url, *, allow_none=False)
473+
.. function:: urldefrag(url, *, missing_as_none=False)
473474

474475
If *url* contains a fragment identifier, return a modified version of *url*
475476
with no fragment identifier, and the fragment identifier as a separate
476477
string. If there is no fragment identifier in *url*, return *url* unmodified
477-
and an empty string (by default) or ``None`` if *allow_none* is true.
478+
and an empty string (by default) or ``None`` if *missing_as_none* is true.
478479

479480
The return value is a :term:`named tuple`, its items can be accessed by index
480481
or as named attributes:
@@ -487,7 +488,7 @@ or on combining URL components into a URL string.
487488
| :attr:`fragment` | 1 | Fragment identifier | ``None`` or empty string [3]_ |
488489
+------------------+-------+-------------------------+-------------------------------+
489490

490-
.. [3] Depending on the value of the *allow_none* argument.
491+
.. [3] Depending on the value of the *missing_as_none* argument.
491492
492493
See section :ref:`urlparse-result-object` for more information on the result
493494
object.
@@ -496,7 +497,7 @@ or on combining URL components into a URL string.
496497
Result is a structured object rather than a simple 2-tuple.
497498

498499
.. versionchanged:: next
499-
Added the *allow_none* parameter.
500+
Added the *missing_as_none* parameter.
500501

501502
.. function:: unwrap(url)
502503

@@ -518,7 +519,7 @@ purity.
518519

519520
Instead of raising an exception on unusual input, they may instead return some
520521
component parts as empty strings or ``None`` (depending on the value of the
521-
*allow_none* argument).
522+
*missing_as_none* argument).
522523
Or components may contain more than perhaps they should.
523524

524525
We recommend that users of these APIs where the values may be used anywhere
@@ -596,7 +597,7 @@ previous section, as well as an additional method:
596597
differ from the original URL in that the scheme may be normalized to lower
597598
case and empty components may be dropped. Specifically, empty parameters,
598599
queries, and fragment identifiers will be removed unless the URL was parsed
599-
with ``allow_none=True``.
600+
with ``missing_as_none=True``.
600601

601602
For :func:`urldefrag` results, only empty fragment identifiers will be removed.
602603
For :func:`urlsplit` and :func:`urlparse` results, all noted changes will be
@@ -613,7 +614,7 @@ previous section, as well as an additional method:
613614
>>> r2 = urlsplit(r1.geturl())
614615
>>> r2.geturl()
615616
'http://www.Python.org/doc/'
616-
>>> r3 = urlsplit(url, allow_none=True)
617+
>>> r3 = urlsplit(url, missing_as_none=True)
617618
>>> r3.geturl()
618619
'http://www.Python.org/doc/#'
619620

Doc/whatsnew/3.15.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ unittest
779779
urllib.parse
780780
------------
781781

782-
* Add the *allow_none* parameter to :func:`~urllib.parse.urlparse`,
782+
* Add the *missing_as_none* parameter to :func:`~urllib.parse.urlparse`,
783783
:func:`~urllib.parse.urlsplit` and :func:`~urllib.parse.urldefrag` functions.
784784
Add the *keep_empty* parameter to :func:`~urllib.parse.urlunparse` and
785785
:func:`~urllib.parse.urlunsplit` functions.

0 commit comments

Comments
 (0)