-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
ValueError: read length must be non-negative or -1 #1474
Comments
@tynanseltzer |
Here you go. Thank you!
|
This look like a null object ( cf pdf-association/safedocs#2 (comment))
|
Error is now
at what I believe is the identical crash point. |
new attempt :
|
Ran without error. |
Unsure if this should be left open, feel free to close. Thank you deeply for your help! |
preparing the PR. will be closed once merged |
You're both amazing ❤️ @pubpub-zz The PR was perfect - short, fixed the issue + added a test. Good work 👍 @tynanseltzer Your initial error report + being responsive surely helped a lot to get this fixed. We appreciate that. If you want, I would add you as a contributor to https://pypdf2.readthedocs.io/en/latest/meta/CONTRIBUTORS.html |
I will make a release to PyPI this weekend. That release will contain the bugfix. |
@MartinThoma I'm ok, thank you though. Appreciate you and pubpub working with a bug report that contained "I will not reproduce the pdf that causes the bug." |
Replace this: What happened? What were you trying to achieve?
Environment
Which environment were you using when you encountered the problem?
$ python -m platform macOS-10.16-x86_64-i386-64bit $ python -c "import PyPDF2;print(PyPDF2.__version__)"
2.11.2
Code + PDF
This is a minimal, complete example that shows the issue:
Share here the PDF file(s) that cause the issue. The smaller they are, the
better. Let us know if we may add them to our tests!
I (legally) can't share the PDF, but I can say that I ran this code on some 240 pdfs, and it broke on only this one pdf. The only thing I find different about this pdf is a bunch of math equations in LaTeX. Please feel free to close this issue, I understand non reproducible bug reports aren't exactly useful, but figured I'd give it a shot.
Traceback
This is the complete Traceback I see:
File "/Users/tynanseltzer/test2/splitter.py", line 135, in
write_public(PUBLIC_PDF, fls)
File "/Users/tynanseltzer/test2/splitter.py", line 64, in write_public
output.write(outstream)
File "/Users/tynanseltzer/anaconda3/lib/python3.9/site-packages/PyPDF2/_writer.py", line 832, in write
self.write_stream(stream)
File "/Users/tynanseltzer/anaconda3/lib/python3.9/site-packages/PyPDF2/_writer.py", line 805, in write_stream
self._sweep_indirect_references(self._root)
File "/Users/tynanseltzer/anaconda3/lib/python3.9/site-packages/PyPDF2/_writer.py", line 954, in _sweep_indirect_references
data = self._resolve_indirect_object(data)
File "/Users/tynanseltzer/anaconda3/lib/python3.9/site-packages/PyPDF2/_writer.py", line 999, in _resolve_indirect_object
real_obj = data.pdf.get_object(data)
File "/Users/tynanseltzer/anaconda3/lib/python3.9/site-packages/PyPDF2/_reader.py", line 1222, in get_object
retval = read_object(self.stream, self) # type: ignore
File "/Users/tynanseltzer/anaconda3/lib/python3.9/site-packages/PyPDF2/generic/_data_structures.py", line 872, in read_object
stream.read(-20)
ValueError: read length must be non-negative or -1
The text was updated successfully, but these errors were encountered: