Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5e808f9

Browse files
miss-islingtontiran
authored andcommitted
bpo-34791: xml package obeys ignore env flags (GH-9544) (GH-9546)
The xml.sax and xml.dom.domreg modules now obey sys.flags.ignore_environment. Signed-off-by: Christian Heimes <[email protected]> https://bugs.python.org/issue34791 (cherry picked from commit 223e501) Co-authored-by: Christian Heimes <[email protected]>
1 parent 47413fe commit 5e808f9

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

Lib/xml/dom/domreg.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
# should be published by posting to [email protected], and are
77
# subsequently recorded in this file.
88

9+
import sys
10+
911
well_known_implementations = {
1012
'minidom':'xml.dom.minidom',
1113
'4DOM': 'xml.dom.DOMImplementation',
@@ -55,7 +57,7 @@ def getDOMImplementation(name=None, features=()):
5557
return mod.getDOMImplementation()
5658
elif name:
5759
return registered[name]()
58-
elif "PYTHON_DOM" in os.environ:
60+
elif not sys.flags.ignore_environment and "PYTHON_DOM" in os.environ:
5961
return getDOMImplementation(name = os.environ["PYTHON_DOM"])
6062

6163
# User did not specify a name, try implementations in arbitrary

Lib/xml/sax/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def parseString(string, handler, errorHandler=ErrorHandler()):
5858
import xml.sax.expatreader
5959

6060
import os, sys
61-
if "PY_SAX_PARSER" in os.environ:
61+
if not sys.flags.ignore_environment and "PY_SAX_PARSER" in os.environ:
6262
default_parser_list = os.environ["PY_SAX_PARSER"].split(",")
6363
del os
6464

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The xml.sax and xml.dom.domreg no longer use environment variables to
2+
override parser implementations when sys.flags.ignore_environment is set by
3+
-E or -I arguments.

0 commit comments

Comments
 (0)