Closed chimosky closed 4 years ago
Thanks.
https://bugzilla.redhat.com/show_bug.cgi is a bad link?
On Python 3 we get ModuleNotFoundError not ImportError. Is the exception handler properly constructed to be both Python 2 and Python 3 compatible?
Can't we just replace the import with import xml.etree.ElementTree as ET
?
https://bugzilla.redhat.com/show_bug.cgi is a bad link?
Yeah, replaced that in my opening comment.
On Python 3 we get ModuleNotFoundError not ImportError. Is the exception handler properly constructed to be both Python 2 and Python 3 compatible?
Yeah, my bad.
Can't we just replace the import with import
xml.etree.ElementTree as ET
?
Yes we can just do that, I added the exception for convenience.
I'll just import xml.etree.Elementree as ET
.
8c976bd56a488d5612b1f69b24c45af114219079
On Python 3 we get ModuleNotFoundError not ImportError.
FWIW, ModuleNotFoundError is a subclass of ImportError, so except ImportError
would handle both.
On Python 3 we get ModuleNotFoundError not ImportError.
FWIW, ModuleNotFoundError is a subclass of ImportError, so
except ImportError
would handle both.
Yeah it should but for some reason, isinstance(ModuleNotFoundError, ImportError)
returns False
.
You want issubclass
for classes.
>>> issubclass(ModuleNotFoundError, ImportError)
True
>>> isinstance(ModuleNotFoundError(), ImportError) # note extra parentheses
True
>>> try:
... raise ModuleNotFoundError
... except ImportError:
... print('handled')
...
handled
You want
issubclass
for classes.>>> issubclass(ModuleNotFoundError, ImportError) True >>> isinstance(ModuleNotFoundError(), ImportError) # note extra parentheses True >>> try: ... raise ModuleNotFoundError ... except ImportError: ... print('handled') ... handled
Thanks
This is a fix for https://bugzilla.redhat.com/show_bug.cgi?id=1817644
@nullr0ute @aperezbios
@quozl kindly review.