Option to use python file operations when saving xml

Bug #1989343 reported by buhtz
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxml
Triaged
Low
Unassigned

Bug Description

Lxml doesn't use python in-build features to write/save xml files. You use your own C part for it. That makes Lxml much faster and attractive. I understand that and won't change it.

But in some circumstances (e.g. unittesting with fake/virtual filesystems like pyfakefs) this breaks a lot of things.

It would be nice if there could be an option to say lxml to use regular python Technics when writing files.

Revision history for this message
scoder (scoder) wrote :

Thanks for the report.

lxml actually does make use of the Python operations for files that you pass it as open file objects (as opposed to file paths). Does that help?

Maybe you could use mock to replace lxml's file writing functions with a wrapper that opens the file from a path before passing it on?

Changed in lxml:
importance: Undecided → Low
status: New → Triaged
Revision history for this message
buhtz (buhtz) wrote : Re: [Bug 1989343] Re: Option to use python file operations when saving xml

Hello

Am 12.09.2022 21:18 schrieb scoder:
> lxml actually does make use of the Python operations for files that you
> pass it as open file objects (as opposed to file paths). Does that
> help?
>
> Maybe you could use mock to replace lxml's file writing functions with
> a
> wrapper that opens the file from a path before passing it on?

No, that doesn't help. Because I use pandas, which uses openpyxl which
uses lxml. ;)

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.