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
If there is no pdf named inv2.pdf in the directory
File "my_file.py", line 4, in <module>
factx = FacturX('inv2.pdf')
File "D:\GSoC\factur-x\facturx\facturx.py", line 59, in __init__
xml = self._xml_from_file(pdf_file)
File "D:\GSoC\factur-x\facturx\facturx.py", line 80, in _xml_from_file
pdf = PdfFileReader(pdf_file)
File "D:\Projects\Invoice2data-GUI\venv\lib\site-packages\PyPDF2\pdf.py", line 1084, in __init__
self.read(stream)
File "D:\Projects\Invoice2data-GUI\venv\lib\site-packages\PyPDF2\pdf.py", line 1697, in read
line = self.readNextEndLine(stream)
File "D:\Projects\Invoice2data-GUI\venv\lib\site-packages\PyPDF2\pdf.py", line 1937, in readNextEnd
Line
raise utils.PdfReadError("Could not read malformed PDF file")
PyPDF2.utils.PdfReadError: Could not read malformed PDF file
The text was updated successfully, but these errors were encountered:
if the path is a string and exists then it is handled by first if condition: isinstance(pdf_invoice, str) and pdf_invoice.endswith('.pdf') and os.path.isfile(pdf_invoice)
if the path was in form of BytesIO or file point it is handled by third condition: isinstance(pdf_invoice, file_types)
when path is a string and doesn't exist or it isn't of pdf format, then second condition was handling it: isinstance(pdf_invoice, str)
Hence I added a commit (#18) to raise FileNotFoundError in second condition: isinstance(pdf_invoice, str)
Cool. To put the icing on the cake you could also make a test that triggers this exception. Would be a good habit to always do feature + test together. Else tests generally get neglected.
If there is no pdf named
inv2.pdf
in the directoryThe text was updated successfully, but these errors were encountered: