Skip to content
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

DeprecationWarning: defusedxml.lxml is no longer supported #956

Closed
jaap3 opened this issue Apr 30, 2019 · 5 comments · Fixed by #1179
Closed

DeprecationWarning: defusedxml.lxml is no longer supported #956

jaap3 opened this issue Apr 30, 2019 · 5 comments · Fixed by #1179

Comments

@jaap3
Copy link

jaap3 commented Apr 30, 2019

zeep/loader.py imports defusedxml.lxml.fromstring, this works, but was (recently) deprecated:

DeprecationWarning: defusedxml.lxml is no longer supported and will be removed in a future release.

The best references to why it was deprecated I could find are here:

tiran/defusedxml#31
tiran/defusedxml#25

@markp2
Copy link

markp2 commented Jul 22, 2019

I am hitting this issue too with Zeep 3.4.0:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/zeep/loader.py:3:

DeprecationWarning: defusedxml.lxml is no longer supported and will be removed in a future release.
  from defusedxml.lxml import fromstring

The problem line is:

from defusedxml.lxml import fromstring

robodoo added a commit to odoo/odoo that referenced this issue Feb 4, 2020
@Julien00859 already made a pass on this at some point but there's a bunch of warnings either dynamic or from not the stdlib left over.

Some of them can't really be fixed in-code and have been explicitly ignored instead:

* `setuptools` uses the deprecated `imp` module until v41.6.0
* `zeep` uses defusedxml.lxml which was never intended to be a public / production API, not sure what to do there (cf  mvantellingen/python-zeep#956)
* there are a ton of invalid escapes in non-raw string literals, they're unlikely to ever be relevant so ignore them

closes #44164

Related: odoo/enterprise#8130
Signed-off-by: Xavier Morel (xmo) <[email protected]>
@jaap3
Copy link
Author

jaap3 commented Jun 18, 2020

There's some more information in this ticket: tiran/defusedxml#38, short summary, the module isn't going away until there's some alternative

@arjitkgupta
Copy link

Is this issue or #1014 fixed and released ?
I am getting the same error with below.
Python 3.6.1
pytest 5.4.2
zeep 3.4.0

@akeeman
Copy link
Contributor

akeeman commented Sep 7, 2020

There's some more information in this ticket: tiran/defusedxml#38, short summary, the module isn't going away until there's some alternative.

So Zeep is using defusedxml while deprecated while there is no alternative and it's not likely to not go away anytime soon.
Normally there are two things that can happen: (1) Zeep switches to something else (not available so not a real option) or (2) defusedxml removes the warning for now (not a Zeep issue). A nasty third could be to suppress the warning in Zeep, but that hides the fact that it is what it is: using a deprecated third party feature.

So I'd say it's your decision if you want the warning to be gone: (run before importing zeep stuff)

import warnings
warnings.filterwarnings("ignore", "defusedxml.lxml is no longer supported and will be removed in a future release.", DeprecationWarning)

Or just filter in the log:

import logging

logging.getLogger(*you logger here*).addFilter(lambda record: "defusedxml.lxml is no longer supported" not in message)
# may be:
# logging.root.addFilter(lambda record: "defusedxml.lxml is no longer supported" not in message)

@xmo-odoo
Copy link

According to defusedxml and lxml's own documentation, there's no need for a replacement because the protection of defused are largely built into lxml: when parsing a document it's possible to opt-out of resolving entities (which is the primary "internal" vulnerability of lxml according to defused's table), and then do whatever is desirable on the Entity nodes that leaves in the document, whether it's ignoring them, asserting there are none, stripping them out, or even resolving an acceptable subset of them. All that's missing is at best some amount of convenience for the latter part (deciding what to do with the entity nodes if they don't get resolved).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants