@@ -125,7 +125,8 @@ or on combining URL components into a URL string.
125125
126126 If the *allow_fragments * argument is false, fragment identifiers are not
127127 recognized. Instead, they are parsed as part of the path
128- or query component, and :attr: `fragment ` is set to ``None `` or the empty
128+ or query component, and :attr: `fragment <SplitResult.fragment> ` is set to
129+ ``None `` or the empty
129130 string (depending on the value of *missing_as_none *) in the return value.
130131
131132 The return value is a :term: `named tuple `, which means that its items can
@@ -134,37 +135,40 @@ or on combining URL components into a URL string.
134135 +------------------+-------+-------------------------+-------------------------------+
135136 | Attribute | Index | Value | Value if not present |
136137 +==================+=======+=========================+===============================+
137- | :attr: ` scheme ` | 0 | URL scheme specifier | *scheme * parameter or |
138+ | | split- scheme| | 0 | URL scheme specifier | *scheme * parameter or |
138139 | | | | empty string [1 ]_ |
139140 +------------------+-------+-------------------------+-------------------------------+
140- | :attr: ` netloc ` | 1 | Network location part | ``None `` or empty string [1 ]_ |
141+ | | split- netloc| | 1 | Network location part | ``None `` or empty string [1 ]_ |
141142 +------------------+-------+-------------------------+-------------------------------+
142- | :attr: ` path ` | 2 | Hierarchical path | empty string |
143+ | | split- path| | 2 | Hierarchical path | empty string |
143144 +------------------+-------+-------------------------+-------------------------------+
144- | :attr: ` query ` | 3 | Query component | ``None `` or empty string [1 ]_ |
145+ | | split- query| | 3 | Query component | ``None `` or empty string [1 ]_ |
145146 +------------------+-------+-------------------------+-------------------------------+
146- | :attr: ` fragment ` | 4 | Fragment identifier | ``None `` or empty string [1 ]_ |
147+ | | split-frag | | 4 | Fragment identifier | ``None `` or empty string [1 ]_ |
147148 +------------------+-------+-------------------------+-------------------------------+
148- | :attr: ` username ` | | User name | ``None `` |
149+ | | split- username| | | User name | ``None `` |
149150 +------------------+-------+-------------------------+-------------------------------+
150- | :attr: ` password ` | | Password | ``None `` |
151+ | | split- password| | | Password | ``None `` |
151152 +------------------+-------+-------------------------+-------------------------------+
152- | :attr: ` hostname ` | | Host name (lower case) | ``None `` |
153+ | | split- hostname| | | Host name (lower case) | ``None `` |
153154 +------------------+-------+-------------------------+-------------------------------+
154- | :attr: ` port ` | | Port number as integer, | ``None `` |
155+ | | split- port| | | Port number as integer, | ``None `` |
155156 | | | if present | |
156157 +------------------+-------+-------------------------+-------------------------------+
157158
158159 .. [1 ] Depending on the value of the *missing_as_none * argument.
159160
160- Reading the :attr: `port ` attribute will raise a :exc: `ValueError ` if
161+ Reading the :attr: `port <SplitResult.port> ` attribute will raise a
162+ :exc: `ValueError ` if
161163 an invalid port is specified in the URL. See section
162164 :ref: `urlparse-result-object ` for more information on the result object.
163165
164- Unmatched square brackets in the :attr: `netloc ` attribute will raise a
166+ Unmatched square brackets in the :attr: `netloc <SplitResult.netloc> `
167+ attribute will raise a
165168 :exc: `ValueError `.
166169
167- Characters in the :attr: `netloc ` attribute that decompose under NFKC
170+ Characters in the :attr: `netloc <SplitResult.netloc> ` attribute that
171+ decompose under NFKC
168172 normalization (as used by the IDNA encoding) into any of ``/ ``, ``? ``,
169173 ``# ``, ``@ ``, or ``: `` will raise a :exc: `ValueError `. If the URL is
170174 decomposed before parsing, no error will be raised.
@@ -174,8 +178,10 @@ or on combining URL components into a URL string.
174178 ``\r `` and tab ``\t `` characters are removed from the URL at any position.
175179
176180 As is the case with all named tuples, the subclass has a few additional methods
177- and attributes that are particularly useful. One such method is :meth: `_replace `.
178- The :meth: `_replace ` method will return a new :class: `SplitResult ` object
181+ and attributes that are particularly useful. One such method is
182+ :meth: `~SplitResult._replace `.
183+ The :meth: `~SplitResult._replace ` method will return a new
184+ :class: `SplitResult ` object
179185 replacing specified fields with new values.
180186
181187 .. doctest ::
@@ -431,9 +437,9 @@ or on combining URL components into a URL string.
431437 +------------------+-------+-------------------------+-------------------------------+
432438 | Attribute | Index | Value | Value if not present |
433439 +==================+=======+=========================+===============================+
434- | :attr: ` url ` | 0 | URL with no fragment | empty string |
440+ | | defrag- url| | 0 | URL with no fragment | empty string |
435441 +------------------+-------+-------------------------+-------------------------------+
436- | :attr: ` fragment ` | 1 | Fragment identifier | ``None `` or empty string [3 ]_ |
442+ | | defrag-frag | | 1 | Fragment identifier | ``None `` or empty string [3 ]_ |
437443 +------------------+-------+-------------------------+-------------------------------+
438444
439445 .. [3 ] Depending on the value of the *missing_as_none * argument.
@@ -506,14 +512,15 @@ byte values will trigger :exc:`UnicodeDecodeError`.
506512
507513To support easier conversion of result objects between :class: `str ` and
508514:class: `bytes `, all return values from URL parsing functions provide
509- either an :meth: `encode ` method (when the result contains :class: `str `
510- data) or a :meth: `decode ` method (when the result contains :class: `bytes `
515+ either an :meth: `encode <DefragResult.encode> ` method (when the result contains
516+ :class: `str ` data) or a :meth: `decode <DefragResultBytes.decode> ` method (when
517+ the result contains :class: `bytes `
511518data). The signatures of these methods match those of the corresponding
512519:class: `str ` and :class: `bytes ` methods (except that the default encoding
513520is ``'ascii' `` rather than ``'utf-8' ``). Each produces a value of a
514521corresponding type that contains either :class: `bytes ` data (for
515- :meth: `encode ` methods) or :class: `str ` data (for
516- :meth: `decode ` methods).
522+ :meth: `encode <DefragResult.encode> ` methods) or :class: `str ` data (for
523+ :meth: `decode <DefragResultBytes.decode> ` methods).
517524
518525Applications that need to operate on potentially improperly quoted URLs
519526that may contain non-ASCII data will need to do their own decoding from
@@ -537,7 +544,24 @@ The result objects from the :func:`urlsplit`, :func:`urlparse` and
537544:func: `urldefrag ` functions are subclasses of the :class: `tuple ` type.
538545These subclasses add the attributes listed in the documentation for
539546those functions, the encoding and decoding support described in the
540- previous section, as well as an additional method:
547+ previous section, as well as additional methods:
548+
549+ .. |split-scheme | replace :: :attr: `scheme <SplitResult.scheme> `
550+ .. |split-netloc | replace :: :attr: `netloc <SplitResult.netloc> `
551+ .. |split-path | replace :: :attr: `path <SplitResult.path> `
552+ .. |split-query | replace :: :attr: `query <SplitResult.query> `
553+ .. |split-frag | replace :: :attr: `fragment <SplitResult.fragment> `
554+ .. |split-username | replace :: :attr: `username <SplitResult.username> `
555+ .. |split-password | replace :: :attr: `password <SplitResult.password> `
556+ .. |split-hostname | replace :: :attr: `hostname <SplitResult.hostname> `
557+ .. |split-port | replace :: :attr: `port <SplitResult.port> `
558+ .. |defrag-url | replace :: :attr: `url <DefragResult.url> `
559+ .. |defrag-frag | replace :: :attr: `fragment <DefragResult.fragment> `
560+
561+ .. method :: SplitResult._replace(**kwargs)
562+
563+ Return a new structured parse result replacing specified fields with new
564+ values.
541565
542566.. method :: urllib.parse.SplitResult.geturl()
543567
@@ -573,22 +597,75 @@ results when operating on :class:`str` objects:
573597.. class :: DefragResult(url, fragment)
574598
575599 Concrete class for :func: `urldefrag ` results containing :class: `str `
576- data. The :meth: `encode ` method returns a :class: `DefragResultBytes `
577- instance.
600+ data.
601+
602+ .. attribute :: url
603+
604+ URL with no fragment.
605+
606+ .. attribute :: fragment
607+
608+ Fragment identifier.
609+
610+ .. method :: encode(encoding='ascii', errors='strict')
611+
612+ Return a :class: `DefragResultBytes ` instance.
578613
579614 .. versionadded :: 3.2
580615
581616.. class :: ParseResult(scheme, netloc, path, params, query, fragment)
582617
583618 Concrete class for :func: `urlparse ` results containing :class: `str `
584- data. The :meth: `encode ` method returns a :class: `ParseResultBytes `
585- instance.
619+ data.
620+
621+ .. method :: encode(encoding='ascii', errors='strict')
622+
623+ Return a :class: `ParseResultBytes ` instance.
586624
587625.. class :: SplitResult(scheme, netloc, path, query, fragment)
588626
589627 Concrete class for :func: `urlsplit ` results containing :class: `str `
590- data. The :meth: `encode ` method returns a :class: `SplitResultBytes `
591- instance.
628+ data.
629+
630+ .. attribute :: scheme
631+
632+ URL scheme specifier.
633+
634+ .. attribute :: netloc
635+
636+ Network location part.
637+
638+ .. attribute :: path
639+
640+ Hierarchical path.
641+
642+ .. attribute :: query
643+
644+ Query component.
645+
646+ .. attribute :: fragment
647+
648+ Fragment identifier.
649+
650+ .. attribute :: username
651+
652+ User name.
653+
654+ .. attribute :: password
655+
656+ Password.
657+
658+ .. attribute :: hostname
659+
660+ Host name, lower case.
661+
662+ .. attribute :: port
663+
664+ Port number as integer, if present.
665+
666+ .. method :: encode(encoding='ascii', errors='strict')
667+
668+ Return a :class: `SplitResultBytes ` instance.
592669
593670
594671The following classes provide the implementations of the parse results when
@@ -597,24 +674,33 @@ operating on :class:`bytes` or :class:`bytearray` objects:
597674.. class :: DefragResultBytes(url, fragment)
598675
599676 Concrete class for :func: `urldefrag ` results containing :class: `bytes `
600- data. The :meth: `decode ` method returns a :class: `DefragResult `
601- instance.
677+ data.
678+
679+ .. method :: decode(encoding='ascii', errors='strict')
680+
681+ Return a :class: `DefragResult ` instance.
602682
603683 .. versionadded :: 3.2
604684
605685.. class :: ParseResultBytes(scheme, netloc, path, params, query, fragment)
606686
607687 Concrete class for :func: `urlparse ` results containing :class: `bytes `
608- data. The :meth: `decode ` method returns a :class: `ParseResult `
609- instance.
688+ data.
689+
690+ .. method :: decode(encoding='ascii', errors='strict')
691+
692+ Return a :class: `ParseResult ` instance.
610693
611694 .. versionadded :: 3.2
612695
613696.. class :: SplitResultBytes(scheme, netloc, path, query, fragment)
614697
615698 Concrete class for :func: `urlsplit ` results containing :class: `bytes `
616- data. The :meth: `decode ` method returns a :class: `SplitResult `
617- instance.
699+ data.
700+
701+ .. method :: decode(encoding='ascii', errors='strict')
702+
703+ Return a :class: `SplitResult ` instance.
618704
619705 .. versionadded :: 3.2
620706
0 commit comments