You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
raises an attribute error. It doesn't appear PyQuery can do anything useful with an empty file, so perhaps it would be better to raise an exception when calling the PyQuery constructor on an empty file? Calling PyQuery on an empty string (rather than empty file) raises an lxml error.
The text was updated successfully, but these errors were encountered:
bchopson
changed the title
Parsing an empty file causes exceptions in instance methods
Parsing an empty file causes exceptions when calling instance methods
Mar 31, 2020
try:
result=getattr(etree, meth)(context)
exceptetree.XMLSyntaxErrorase:
ife.msg.startswith('Document is empty'):
raise
@gawel
Do you think it is a valid way to solve it?
At first, I tried to check e.code == 4, since 4 is XML_ERR_DOCUMENT_EMPTY, but it turned out, that this error code appears not only when document is empty. So, I ended up with checking exception message.
raises an attribute error. It doesn't appear PyQuery can do anything useful with an empty file, so perhaps it would be better to raise an exception when calling the PyQuery constructor on an empty file? Calling PyQuery on an empty string (rather than empty file) raises an lxml error.
The text was updated successfully, but these errors were encountered: