setting XML_CATALOG_FILES environment variable ignored by lxml 3.4.4

Bug #1459118 reported by ian
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxml
Invalid
Undecided
Unassigned

Bug Description

Windows 7, 64 bit, using the whl from the "Unofficial Windows Binaries for Python Extension Packages"

Using os.environ['XML_CATALOG_FILES'] in a script sets the environment variable correctly (I assume, as os.getenv returns the expected content), but when the variable is used by lxml, the following error is reported:
  File "lxml.etree.pyx", line 3310, in lxml.etree.parse (src\lxml\lxml.etree.c:72517)
  File "parser.pxi", line 1791, in lxml.etree._parseDocument (src\lxml\lxml.etree.c:105979)
  File "parser.pxi", line 1817, in lxml.etree._parseDocumentFromURL (src\lxml\lxml.etree.c:106278)
  File "parser.pxi", line 1721, in lxml.etree._parseDocFromFile (src\lxml\lxml.etree.c:105277)
  File "parser.pxi", line 1122, in lxml.etree._BaseParser._parseDocFromFile (src\lxml\lxml.etree.c:100227)
  File "parser.pxi", line 580, in lxml.etree._ParserContext._handleParseResultDoc (src\lxml\lxml.etree.c:94350)
  File "parser.pxi", line 690, in lxml.etree._handleParseResult (src\lxml\lxml.etree.c:95786)
  File "parser.pxi", line 620, in lxml.etree._raiseParseError (src\lxml\lxml.etree.c:94853)
lxml.etree.XMLSyntaxError: failed to load external entity "file:/E:/tmp/Main/map.dtd", line 2, column 61

The final line of which means that the catalog referenced by the environment variable is not being used.
This is run with the following:
Python : sys.version_info(major=3, minor=4, micro=3, releaselevel='final', serial=0)
lxml.etree : (3, 4, 4, 0)
libxml used : (2, 9, 2)
libxml compiled : (2, 9, 2)
libxslt used : (1, 1, 28)
libxslt compiled : (1, 1, 28)

* setting the variable is the DOS shell before running the script does not encounter this error.
* running the same script with an earlier version of lxml works as expected:
   Python : sys.version_info(major=3, minor=4, micro=3, releaselevel='final', serial=0)
   lxml.etree : (3, 3, 5, 0)
   libxml used : (2, 9, 1)
   libxml compiled : (2, 9, 1)
   libxslt used : (1, 1, 28)
   libxslt compiled : (1, 1, 28)

Revision history for this message
scoder (scoder) wrote :

Using "os.environ" to set an environment variable only applies to processes being started as subprocesses later on, not to the current process itself. I therefore cannot imagine that this ever worked. Most likely, there's something else that differs between the two installations on your side.

Changed in lxml:
status: New → Incomplete
Revision history for this message
ian (ianbalanza) wrote :

As I said, yes this did work as I was able to see default attribute values drawn from the DITA DTDs referenced through the catalog.

Revision history for this message
scoder (scoder) wrote :

I wasn't questioning that it worked in your specific setup. I was questioning that it worked *because of* the older lxml version.

Revision history for this message
scoder (scoder) wrote :

Closing as outdated.

Changed in lxml:
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.