Skip to content

gh-156821: Fix inaccuracies in the xml.parsers.expat documentation - #156822

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-60930-parsefile-docs
Sep 2, 2026
Merged

gh-156821: Fix inaccuracies in the xml.parsers.expat documentation#156822
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-60930-parsefile-docs

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Sep 2, 2026

Copy link
Copy Markdown
Member

Fix statements which do not match the behaviour: the type and the extent of the result of GetInputContext(), the types accepted by Parse() and ParseFile(), the description of XML_ERROR_XML_DECL, and the Expat version required for UnparsedEntityDeclHandler. The docstrings are corrected too.

Document the intern parameter of ParserCreate(), the intern and namespace_prefixes attributes, SkippedEntityHandler, XML_CTYPE_MIXED and XML_CTYPE_NAME, and the EXPAT_VERSION, version_info and features data items.

Remove obsolete notes about Expat 1.2 and 1.95.0, complete the list of attribute types in AttlistDeclHandler, and remove :noindex: from the content model constants, which have no other description and were therefore not referenceable.

This also fixes gh-60930.

…ion and docstrings

GetInputContext() returns bytes, not a string, and its result extends to the
end of the buffered input.  Parse() accepts a bytes-like object as well as a
string, and ignores the encoding declaration for a string.  ParseFile() only
supports binary files.  XML_ERROR_XML_DECL was described as
XML_ERROR_NO_ELEMENTS.  UnparsedEntityDeclHandler is not restricted to Expat
1.2.  GetSpecifiedAttributeCount() is only meaningful if ordered_attributes
is true.

Document the intern parameter of ParserCreate(), the intern and
namespace_prefixes attributes, the SkippedEntityHandler handler, the
XML_CTYPE_MIXED and XML_CTYPE_NAME content model types, and the
EXPAT_VERSION, version_info and features data items, which describe the
Expat library loaded by the interpreter.

Remove obsolete notes about Expat versions 1.2 and 1.95.0, complete the list
of attribute types in AttlistDeclHandler, and remove :noindex: from the
content model constants, which have no other description and were therefore
not referenceable.
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #34351312 | 📁 Comparing da3ccbb against main (d557d64)

  🔍 Preview build  

1 file changed
± library/pyexpat.html

@serhiy-storchaka
serhiy-storchaka merged commit d16a691 into python:main Sep 2, 2026
65 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@serhiy-storchaka
serhiy-storchaka deleted the gh-60930-parsefile-docs branch September 2, 2026 18:58
@miss-islington-app

Copy link
Copy Markdown

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.15 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker d16a691111503798820a4b3a60ffae7b76c4d85a 3.15

@miss-islington-app

Copy link
Copy Markdown

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker d16a691111503798820a4b3a60ffae7b76c4d85a 3.14

@miss-islington-app

Copy link
Copy Markdown

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker d16a691111503798820a4b3a60ffae7b76c4d85a 3.13

serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Sep 2, 2026
…umentation (pythonGH-156822)

Corrected, in the documentation and in the docstrings:

* GetInputContext() returns bytes, and its result extends to the end of the
  buffered input;
* Parse() accepts a bytes-like object as well as a string, and ignores the
  encoding declaration for a string;
* ParseFile() only supports binary files;
* XML_ERROR_XML_DECL was described as XML_ERROR_NO_ELEMENTS;
* UnparsedEntityDeclHandler is not restricted to Expat 1.2;
* GetSpecifiedAttributeCount() needs ordered_attributes.

Documented the intern parameter and attribute, namespace_prefixes,
SkippedEntityHandler, XML_CTYPE_MIXED and XML_CTYPE_NAME, and EXPAT_VERSION,
version_info and features.

Removed obsolete notes about Expat 1.2 and 1.95.0, and :noindex: from the
content model constants, which are not documented elsewhere; completed the
list of attribute types in AttlistDeclHandler.
(cherry picked from commit d16a691)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-app

bedevere-app Bot commented Sep 2, 2026

Copy link
Copy Markdown

GH-156852 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Sep 2, 2026
@bedevere-app

bedevere-app Bot commented Sep 2, 2026

Copy link
Copy Markdown

GH-156853 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Sep 2, 2026
@bedevere-app

bedevere-app Bot commented Sep 2, 2026

Copy link
Copy Markdown

GH-156854 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Sep 2, 2026
serhiy-storchaka added a commit that referenced this pull request Sep 2, 2026
…tion (GH-156822) (GH-156854)

Corrected, in the documentation and in the docstrings:

* GetInputContext() returns bytes, and its result extends to the end of the
  buffered input;
* Parse() accepts a bytes-like object as well as a string, and ignores the
  encoding declaration for a string;
* ParseFile() only supports binary files;
* XML_ERROR_XML_DECL was described as XML_ERROR_NO_ELEMENTS;
* UnparsedEntityDeclHandler is not restricted to Expat 1.2;
* GetSpecifiedAttributeCount() needs ordered_attributes.

Documented the intern parameter and attribute, namespace_prefixes,
SkippedEntityHandler, XML_CTYPE_MIXED and XML_CTYPE_NAME, and EXPAT_VERSION,
version_info and features.

Removed obsolete notes about Expat 1.2 and 1.95.0, and :noindex: from the
content model constants, which are not documented elsewhere; completed the
list of attribute types in AttlistDeclHandler.
(cherry picked from commit d16a691)
serhiy-storchaka added a commit that referenced this pull request Sep 2, 2026
…tion (GH-156822) (GH-156853)

Corrected, in the documentation and in the docstrings:

* GetInputContext() returns bytes, and its result extends to the end of the
  buffered input;
* Parse() accepts a bytes-like object as well as a string, and ignores the
  encoding declaration for a string;
* ParseFile() only supports binary files;
* XML_ERROR_XML_DECL was described as XML_ERROR_NO_ELEMENTS;
* UnparsedEntityDeclHandler is not restricted to Expat 1.2;
* GetSpecifiedAttributeCount() needs ordered_attributes.

Documented the intern parameter and attribute, namespace_prefixes,
SkippedEntityHandler, XML_CTYPE_MIXED and XML_CTYPE_NAME, and EXPAT_VERSION,
version_info and features.

Removed obsolete notes about Expat 1.2 and 1.95.0, and :noindex: from the
content model constants, which are not documented elsewhere; completed the
list of attribute types in AttlistDeclHandler.
(cherry picked from commit d16a691)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

expat ParseFile expects bytes, not string

1 participant