Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.2k
gh-76007: Deprecate VERSION in xml.etree.ElementTree & version in xml.sax.expatreader & xml.sax.handler#142898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
c88d33f2bdf4b98007859020cc5ccecae395f1f5a9b296d6bFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -4705,6 +4705,19 @@ def get_option(config, option_name, default=None): | ||
| # -------------------------------------------------------------------- | ||
| class TestModule(unittest.TestCase): | ||
| def test_deprecated_version(self): | ||
| with self.assertWarnsRegex( | ||
| DeprecationWarning, | ||
| "'VERSION' is deprecated and slated for removal in Python 3.20", | ||
| ) as cm: | ||
| getattr(ET, "VERSION") | ||
merwok marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| self.assertEqual(cm.filename, __file__) | ||
| # -------------------------------------------------------------------- | ||
| def setUpModule(module=None): | ||
| # When invoked without a module, runs the Python ET tests by loading pyET. | ||
| # Otherwise, uses the given module as the ET. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -83,15 +83,12 @@ | ||
| "SubElement", | ||
| "tostring", "tostringlist", | ||
| "TreeBuilder", | ||
| "VERSION", | ||
| "XML", "XMLID", | ||
| "XMLParser", "XMLPullParser", | ||
| "register_namespace", | ||
| "canonicalize", "C14NWriterTarget", | ||
| ] | ||
| VERSION = "1.3.0" | ||
| import sys | ||
| import re | ||
| import warnings | ||
| @@ -2104,3 +2101,14 @@ def _escape_attrib_c14n(text): | ||
| pass | ||
| else: | ||
| _set_factories(Comment, ProcessingInstruction) | ||
| # -------------------------------------------------------------------- | ||
| def __getattr__(name): | ||
| if name == "VERSION": | ||
| from warnings import _deprecated | ||
| _deprecated("VERSION", remove=(3, 20)) | ||
| return "1.3.0" # Do not change | ||
| raise AttributeError(f"module {__name__!r} has no attribute {name!r}") | ||
merwok marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -3,8 +3,6 @@ | ||
| pyexpat.__version__ == '2.22'. | ||
| """ | ||
| version = "0.20" | ||
| from xml.sax._exceptions import * | ||
| from xml.sax.handler import feature_validation, feature_namespaces | ||
| from xml.sax.handler import feature_namespace_prefixes | ||
| @@ -446,6 +444,16 @@ def create_parser(*args, **kwargs): | ||
| # --- | ||
| def __getattr__(name): | ||
| if name == "version": | ||
| from warnings import _deprecated | ||
| _deprecated("version", remove=(3, 20)) | ||
| return "0.20" # Do not change | ||
merwok marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| raise AttributeError(f"module {__name__!r} has no attribute {name!r}") | ||
| # --- | ||
| if __name__ == "__main__": | ||
| import xml.sax.saxutils | ||
| p = create_parser() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Deprecate ``VERSION`` from :mod:`xml.etree.ElementTree` and ``version`` from | ||
| :mod:`!xml.sax.expatreader` and :mod:`xml.sax.handler`. Patch by Hugo van | ||
| Kemenade. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.