Skip to content

Commit 986dbd7

Browse files
gh-151943: Fix Sphinx reference warnings in Doc/library/pyexpat.rst
- Define xmlparser class directive - Cross-reference Parse, ParseFile, and handlers to xmlparser - Cross-reference XML_ERROR constants to xml.parsers.expat.errors - Cross-reference ExpatError to xml.parsers.expat - Suppress unresolved references for pyexpat module and parameter entity constants using ! - Remove Doc/library/pyexpat.rst from Doc/tools/.nitignore Signed-off-by: ANISAYAK MITRA <266799942+anisayakmitra-in@users.noreply.github.com>
1 parent 49a344e commit 986dbd7

2 files changed

Lines changed: 27 additions & 23 deletions

File tree

‎Doc/library/pyexpat.rst‎

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ the XML document.
3232

3333
.. index:: pair: module; pyexpat
3434

35-
This module uses the :mod:`pyexpat` module to provide access to the Expat
36-
parser. Direct use of the :mod:`pyexpat` module is deprecated.
35+
This module uses the :mod:`!pyexpat` module to provide access to the Expat
36+
parser. Direct use of the :mod:`!pyexpat` module is deprecated.
3737

3838
This module provides the following exception, type object and data items:
3939

@@ -46,7 +46,7 @@ This module provides the following exception, type object and data items:
4646

4747
.. exception:: error
4848

49-
Alias for :exc:`ExpatError`.
49+
Alias for :exc:`~xml.parsers.expat.ExpatError`.
5050

5151

5252
.. data:: XMLParserType
@@ -139,7 +139,7 @@ The :mod:`!xml.parsers.expat` module contains two functions:
139139
is considered the same as omission). When namespace processing is enabled,
140140
element type names and attribute names that belong to a namespace will be
141141
expanded. The element name passed to the element handlers
142-
:attr:`StartElementHandler` and :attr:`EndElementHandler` will be the
142+
:meth:`~xmlparser.StartElementHandler` and :meth:`~xmlparser.EndElementHandler` will be the
143143
concatenation of the namespace URI, the namespace separator character, and the
144144
local part of the name. If the namespace separator is a zero byte (``chr(0)``)
145145
then the namespace URI and the local part will be concatenated without any
@@ -157,7 +157,7 @@ The :mod:`!xml.parsers.expat` module contains two functions:
157157
<elem2 xmlns="" />
158158
</root>
159159
160-
:attr:`StartElementHandler` will receive the following strings for each
160+
:meth:`~xmlparser.StartElementHandler` will receive the following strings for each
161161
element::
162162

163163
http://default-namespace.org/ root
@@ -169,7 +169,7 @@ The :mod:`!xml.parsers.expat` module contains two functions:
169169
and is available as the :attr:`~xmlparser.intern` attribute.
170170
By default a new empty dictionary is created for every parser.
171171

172-
Due to limitations in the ``Expat`` library used by :mod:`pyexpat`,
172+
Due to limitations in the ``Expat`` library used by :mod:`!pyexpat`,
173173
the :class:`xmlparser` instance returned can only be used to parse a single
174174
XML document. Call ``ParserCreate`` for each document to provide unique
175175
parser instances.
@@ -185,6 +185,11 @@ The :mod:`!xml.parsers.expat` module contains two functions:
185185
XMLParser Objects
186186
-----------------
187187

188+
.. class:: xmlparser()
189+
190+
The type of an XML parser object created by :func:`ParserCreate`.
191+
192+
188193
:class:`xmlparser` objects have the following methods:
189194

190195

@@ -264,9 +269,9 @@ XMLParser Objects
264269
.. method:: xmlparser.SetParamEntityParsing(flag)
265270

266271
Control parsing of parameter entities (including the external DTD subset).
267-
Possible *flag* values are :const:`XML_PARAM_ENTITY_PARSING_NEVER`,
268-
:const:`XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE` and
269-
:const:`XML_PARAM_ENTITY_PARSING_ALWAYS`. Return true if setting the flag
272+
Possible *flag* values are :const:`!XML_PARAM_ENTITY_PARSING_NEVER`,
273+
:const:`!XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE` and
274+
:const:`!XML_PARAM_ENTITY_PARSING_ALWAYS`. Return true if setting the flag
270275
was successful.
271276

272277
.. method:: xmlparser.UseForeignDTD([flag])
@@ -281,9 +286,9 @@ XMLParser Objects
281286
Passing a false value for *flag* will cancel a previous call that passed a true
282287
value, but otherwise has no effect.
283288

284-
This method can only be called before the :meth:`Parse` or :meth:`ParseFile`
289+
This method can only be called before the :meth:`~xmlparser.Parse` or :meth:`~xmlparser.ParseFile`
285290
methods are called; calling it after either of those have been called causes
286-
:exc:`ExpatError` to be raised with the :attr:`code` attribute set to
291+
:exc:`~xml.parsers.expat.ExpatError` to be raised with the :attr:`code` attribute set to
287292
``errors.codes[errors.XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING]``.
288293

289294
.. method:: xmlparser.SetReparseDeferralEnabled(enabled)
@@ -336,7 +341,7 @@ against some common XML vulnerabilities.
336341
Parser objects usually have a protection activation threshold of 8 MiB,
337342
but the actual default value depends on the underlying Expat library.
338343

339-
An :exc:`ExpatError` is raised if this method is called on a
344+
An :exc:`~xml.parsers.expat.ExpatError` is raised if this method is called on a
340345
|xml-non-root-parser| parser.
341346
The corresponding :attr:`~ExpatError.lineno` and :attr:`~ExpatError.offset`
342347
should not be used as they may have no special meaning.
@@ -372,7 +377,7 @@ against some common XML vulnerabilities.
372377
Parser objects usually have a maximum amplification factor of 100,
373378
but the actual default value depends on the underlying Expat library.
374379

375-
An :exc:`ExpatError` is raised if this method is called on a
380+
An :exc:`~xml.parsers.expat.ExpatError` is raised if this method is called on a
376381
|xml-non-root-parser| parser or if *max_factor* is outside the valid range.
377382
The corresponding :attr:`~ExpatError.lineno` and :attr:`~ExpatError.offset`
378383
should not be used as they may have no special meaning.
@@ -398,7 +403,7 @@ against some common XML vulnerabilities.
398403
Parser objects usually have an allocation activation threshold of 64 MiB,
399404
but the actual default value depends on the underlying Expat library.
400405

401-
An :exc:`ExpatError` is raised if this method is called on a
406+
An :exc:`~xml.parsers.expat.ExpatError` is raised if this method is called on a
402407
|xml-non-root-parser| parser.
403408
The corresponding :attr:`~ExpatError.lineno` and :attr:`~ExpatError.offset`
404409
should not be used as they may have no special meaning.
@@ -428,7 +433,7 @@ against some common XML vulnerabilities.
428433
Parser objects usually have a maximum amplification factor of 100,
429434
but the actual default value depends on the underlying Expat library.
430435

431-
An :exc:`ExpatError` is raised if this method is called on a
436+
An :exc:`~xml.parsers.expat.ExpatError` is raised if this method is called on a
432437
|xml-non-root-parser| parser or if *max_factor* is outside the valid range.
433438
The corresponding :attr:`~ExpatError.lineno` and :attr:`~ExpatError.offset`
434439
should not be used as they may have no special meaning.
@@ -514,7 +519,7 @@ against some common XML vulnerabilities.
514519

515520
The following attributes contain values relating to the most recent error
516521
encountered by an :class:`xmlparser` object, and will only have correct values
517-
once a call to :meth:`Parse` or :meth:`ParseFile` has raised an
522+
once a call to :meth:`~xmlparser.Parse` or :meth:`~xmlparser.ParseFile` has raised an
518523
:exc:`xml.parsers.expat.ExpatError` exception.
519524

520525

@@ -728,7 +733,7 @@ otherwise stated.
728733
This happens when there is an external subset or a reference to a parameter
729734
entity, but the XML declaration does not set standalone to ``yes`` in an XML
730735
declaration. If this handler returns ``0``, then the parser will raise an
731-
:const:`XML_ERROR_NOT_STANDALONE` error. If this handler is not set, no
736+
:const:`~xml.parsers.expat.errors.XML_ERROR_NOT_STANDALONE` error. If this handler is not set, no
732737
exception is raised by the parser for this condition.
733738

734739

@@ -754,7 +759,7 @@ otherwise stated.
754759
``ExternalEntityParserCreate(context)``, initializing it with the appropriate
755760
callbacks, and parsing the entity. This handler should return an integer; if it
756761
returns ``0``, the parser will raise an
757-
:const:`XML_ERROR_EXTERNAL_ENTITY_HANDLING` error, otherwise parsing will
762+
:const:`~xml.parsers.expat.errors.XML_ERROR_EXTERNAL_ENTITY_HANDLING` error, otherwise parsing will
758763
continue.
759764

760765
If this handler is not provided, external entities are reported by the
@@ -776,7 +781,7 @@ otherwise stated.
776781
ExpatError Exceptions
777782
---------------------
778783

779-
:exc:`ExpatError` exceptions have a number of interesting attributes:
784+
:exc:`~xml.parsers.expat.ExpatError` exceptions have a number of interesting attributes:
780785

781786

782787
.. attribute:: ExpatError.code
@@ -936,7 +941,7 @@ Expat error constants
936941

937942
The following constants are provided in the :mod:`!xml.parsers.expat.errors`
938943
module. These constants are useful in interpreting some of the attributes of
939-
the :exc:`ExpatError` exception objects raised when an error has occurred.
944+
the :exc:`~xml.parsers.expat.ExpatError` exception objects raised when an error has occurred.
940945
Since for backwards compatibility reasons, the constants' value is the error
941946
*message* and not the numeric error *code*, you do this by comparing its
942947
:attr:`code` attribute with
@@ -1067,7 +1072,7 @@ The ``errors`` module has the following attributes:
10671072
.. data:: XML_ERROR_NOT_STANDALONE
10681073

10691074
The parser determined that the document was not "standalone" though it declared
1070-
itself to be in the XML declaration, and the :attr:`NotStandaloneHandler` was
1075+
itself to be in the XML declaration, and the :meth:`~xml.parsers.expat.xmlparser.NotStandaloneHandler` was
10711076
set and returned ``0``.
10721077

10731078

@@ -1088,7 +1093,7 @@ The ``errors`` module has the following attributes:
10881093

10891094
A behavioral change was requested after parsing started that can only be changed
10901095
before parsing has started. This is (currently) only raised by
1091-
:meth:`UseForeignDTD`.
1096+
:meth:`~xml.parsers.expat.xmlparser.UseForeignDTD`.
10921097

10931098

10941099
.. data:: XML_ERROR_UNBOUND_PREFIX

‎Doc/tools/.nitignore‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ Doc/library/logging.handlers.rst
88
Doc/library/multiprocessing.rst
99
Doc/library/optparse.rst
1010
Doc/library/pickletools.rst
11-
Doc/library/pyexpat.rst
1211
Doc/library/select.rst
1312
Doc/library/socket.rst
1413
Doc/library/ssl.rst

0 commit comments

Comments
 (0)