Skip to content

TypeError: 'NumberObject' object is not subscriptable #1273

@DL6ER

Description

@DL6ER

See #1269 for further details.

Environment

Which environment were you using when you encountered the problem?

$ python -m platform
Linux-5.4.0-122-generic-x86_64-with-glibc2.29

$ python -c "import PyPDF2;print(PyPDF2.__version__)"
2.10.3

Code + PDF

This is a minimal, complete example that shows the issue:

import PyPDF2
with open("shiv_resume.pdf", "rb") as f:
  pdfreader = PyPDF2.PdfFileReader(f, strict=False)

PDF used above: shiv_resume.pdf

Traceback

This is the complete Traceback I see:

Xref table not zero-indexed. ID numbers for objects will be corrected.
Xref table not zero-indexed. ID numbers for objects will be corrected.
Superfluous whitespace found in object header b'17' b'23'

Traceback (most recent call last):
  File "test4.py", line 3, in <module>
    pdfreader = PyPDF2.PdfFileReader(f, strict=True)
  File "/usr/local/lib/python3.8/dist-packages/PyPDF2/_reader.py", line 1775, in __init__
    super().__init__(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/PyPDF2/_reader.py", line 275, in __init__
    self.read(stream)
  File "/usr/local/lib/python3.8/dist-packages/PyPDF2/_reader.py", line 1279, in read
    self._read_xref_tables_and_trailers(stream, startxref, xref_issue_nr)
  File "/usr/local/lib/python3.8/dist-packages/PyPDF2/_reader.py", line 1435, in _read_xref_tables_and_trailers
    xrefstream = self._read_pdf15_xref_stream(stream)
  File "/usr/local/lib/python3.8/dist-packages/PyPDF2/_reader.py", line 1515, in _read_pdf15_xref_stream
    assert cast(str, xrefstream["/Type"]) == "/XRef"
TypeError: 'NumberObject' object is not subscriptable

Metadata

Metadata

Assignees

No one assigned

    Labels

    is-robustness-issueFrom a users perspective, this is about robustness

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions