File tree Expand file tree Collapse file tree 4 files changed +29
-9
lines changed
Expand file tree Collapse file tree 4 files changed +29
-9
lines changed Original file line number Diff line number Diff line change 11Pending removal in Python 3.20
22------------------------------
33
4- * The ``__version__ `` and ``VERSION `` attributes have been deprecated in these
5- standard library modules and will be removed in Python 3.20.
6- Use :py:data: `sys.version_info ` instead.
4+ * The ``__version__ ``, `` version `` and ``VERSION `` attributes have been
5+ deprecated in these standard library modules and will be removed in
6+ Python 3.20. Use :py:data: `sys.version_info ` instead.
77
88 - :mod: `argparse `
99 - :mod: `csv `
@@ -24,6 +24,7 @@ Pending removal in Python 3.20
2424 - :mod: `tkinter.font `
2525 - :mod: `tkinter.ttk `
2626 - :mod: `xml.etree.ElementTree `
27+ - :mod: `xml.sax.expatreader `
2728 - :mod: `wsgiref.simple_server `
2829 - :mod: `zlib `
2930
Original file line number Diff line number Diff line change @@ -1018,9 +1018,9 @@ New deprecations
10181018
10191019* ``__version__ ``
10201020
1021- * The ``__version__ `` and ``VERSION `` attributes have been deprecated in these
1022- standard library modules and will be removed in Python 3.20.
1023- Use :py:data: `sys.version_info ` instead.
1021+ * The ``__version__ ``, `` version `` and ``VERSION `` attributes have been
1022+ deprecated in these standard library modules and will be removed in
1023+ Python 3.20. Use :py:data: `sys.version_info ` instead.
10241024
10251025 - :mod: `argparse `
10261026 - :mod: `csv `
@@ -1041,6 +1041,7 @@ New deprecations
10411041 - :mod: `tkinter.font `
10421042 - :mod: `tkinter.ttk `
10431043 - :mod: `xml.etree.ElementTree `
1044+ - :mod: `xml.sax.expatreader `
10441045 - :mod: `wsgiref.simple_server `
10451046 - :mod: `zlib `
10461047
Original file line number Diff line number Diff line change @@ -1573,5 +1573,15 @@ def test_all(self):
15731573 check__all__ (self , sax , extra = extra )
15741574
15751575
1576+ class TestModule (unittest .TestCase ):
1577+ def test_deprecated_version (self ):
1578+ with self .assertWarnsRegex (
1579+ DeprecationWarning ,
1580+ "'version' is deprecated and slated for removal in Python 3.20" ,
1581+ ) as cm :
1582+ getattr (sax .expatreader , "version" )
1583+ self .assertEqual (cm .filename , __file__ )
1584+
1585+
15761586if __name__ == "__main__" :
15771587 unittest .main ()
Original file line number Diff line number Diff line change 33pyexpat.__version__ == '2.22'.
44"""
55
6- version = "0.20"
7-
86from xml .sax ._exceptions import *
97from xml .sax .handler import feature_validation , feature_namespaces
108from xml .sax .handler import feature_namespace_prefixes
@@ -446,9 +444,19 @@ def create_parser(*args, **kwargs):
446444
447445# ---
448446
447+ def __getattr__ (name ):
448+ if name == "version" :
449+ from warnings import _deprecated
450+
451+ _deprecated ("version" , remove = (3 , 20 ))
452+ return "0.20" # Do not change
453+ raise AttributeError (f"module { __name__ !r} has no attribute { name !r} " )
454+
455+ # ---
456+
449457if __name__ == "__main__" :
450458 import xml .sax .saxutils
451459 p = create_parser ()
452460 p .setContentHandler (xml .sax .saxutils .XMLGenerator ())
453461 p .setErrorHandler (xml .sax .ErrorHandler ())
454- p .parse ("http ://www.ibiblio.org/xml/examples/shakespeare/hamlet.xml" )
462+ p .parse ("https ://www.ibiblio.org/xml/examples/shakespeare/hamlet.xml" )
You can’t perform that action at this time.
0 commit comments