{"action":"created","issue":{"url":"https://api.github.com/repos/claird/PyPDF4/issues/11","repository_url":"https://api.github.com/repos/claird/PyPDF4","labels_url":"https://api.github.com/repos/claird/PyPDF4/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/claird/PyPDF4/issues/11/comments","events_url":"https://api.github.com/repos/claird/PyPDF4/issues/11/events","html_url":"https://github.com/claird/PyPDF4/issues/11","id":356248803,"node_id":"MDU6SXNzdWUzNTYyNDg4MDM=","number":11,"title":"strange issue with resolvedObjects","user":{"login":"DeliciousHair","id":6540809,"node_id":"MDQ6VXNlcjY1NDA4MDk=","avatar_url":"https://avatars2.githubusercontent.com/u/6540809?v=4","gravatar_id":"","url":"https://api.github.com/users/DeliciousHair","html_url":"https://github.com/DeliciousHair","followers_url":"https://api.github.com/users/DeliciousHair/followers","following_url":"https://api.github.com/users/DeliciousHair/following{/other_user}","gists_url":"https://api.github.com/users/DeliciousHair/gists{/gist_id}","starred_url":"https://api.github.com/users/DeliciousHair/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DeliciousHair/subscriptions","organizations_url":"https://api.github.com/users/DeliciousHair/orgs","repos_url":"https://api.github.com/users/DeliciousHair/repos","events_url":"https://api.github.com/users/DeliciousHair/events{/privacy}","received_events_url":"https://api.github.com/users/DeliciousHair/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-09-02T03:06:43Z","updated_at":"2018-09-02T21:40:30Z","closed_at":null,"author_association":"NONE","body":"Unfortunately, I cannot share the source documents that are causing this problem, so what I'm instead looking for is some hints as to where I may look to find what could be causing this (I took a look at the source for `PdfFileReader` and nothing is jumping out at me) so that I could create a workaround at a minimum.\r\n\r\nUsing IPython, this is what I get:\r\n```\r\nIn [1]: import PyPDF4\r\n\r\nIn [2]: pdf = PyPDF4.PdfFileReader('some_file.pdf')\r\n\r\nIn [3]: for key, val in pdf.resolvedObjects.items():\r\n   ...:     print(key, val)\r\n   ...:     \r\n(0, 634) {'/DecodeParms': {'/Columns': 3, '/Predictor': 12}, '/Filter': '/FlateDecode', '/ID': [b'<edited out>', b'<edited out>'], '/Index': [614, 22], '/Info': IndirectObject(613, 0), '/Prev': 1820112, '/Root': IndirectObject(615, 0), '/Size': 636, '/Type': '/XRef', '/W': [1, 2, 0]}\r\n(0, 611) {'/DecodeParms': {'/Columns': 4, '/Predictor': 12}, '/Filter': '/FlateDecode', '/ID': [b'<edited out>', b'<edited out>'], '/Info': IndirectObject(613, 0), '/Root': IndirectObject(615, 0), '/Size': 614, '/Type': '/XRef', '/W': [1, 3, 0]}\r\n\r\nIn [4]: pdf.resolvedObjects\r\nOut[4]: ---------------------------------------------------------------------------\r\nRuntimeError                              Traceback (most recent call last)\r\n/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/IPython/core/formatters.py in __call__(self, obj)\r\n    700                 type_pprinters=self.type_printers,\r\n    701                 deferred_pprinters=self.deferred_printers)\r\n--> 702             printer.pretty(obj)\r\n    703             printer.flush()\r\n    704             return stream.getvalue()\r\n\r\n/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/IPython/lib/pretty.py in pretty(self, obj)\r\n    381                 if cls in self.type_pprinters:\r\n    382                     # printer registered in self.type_pprinters\r\n--> 383                     return self.type_pprinters[cls](obj, self, cycle)\r\n    384                 else:\r\n    385                     # deferred printer\r\n\r\n/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/IPython/lib/pretty.py in inner(obj, p, cycle)\r\n    610                 and not (p.max_seq_length and len(obj) >= p.max_seq_length):\r\n    611             keys = _sorted_for_pprint(keys)\r\n--> 612         for idx, key in p._enumerate(keys):\r\n    613             if idx:\r\n    614                 p.text(',')\r\n\r\n/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/IPython/lib/pretty.py in _enumerate(self, seq)\r\n    284     def _enumerate(self, seq):\r\n    285         \"\"\"like enumerate, but with an upper limit on the number of items\"\"\"\r\n--> 286         for idx, x in enumerate(seq):\r\n    287             if self.max_seq_length and idx >= self.max_seq_length:\r\n    288                 self.text(',')\r\n\r\nRuntimeError: dictionary changed size during iteration\r\n\r\nIn [5]: for key, val in pdf.resolvedObjects.items():\r\n   ...:     print(key, val)\r\n   ...:     \r\n(0, 634) {'/DecodeParms': {'/Columns': 3, '/Predictor': 12}, '/Filter': '/FlateDecode', '/ID': [b'<edited out>', b'<edited out>'], '/Index': [614, 22], '/Info': IndirectObject(613, 0), '/Prev': 1820112, '/Root': IndirectObject(615, 0), '/Size': 636, '/Type': '/XRef', '/W': [1, 2, 0]}\r\n(0, 611) {'/DecodeParms': {'/Columns': 4, '/Predictor': 12}, '/Filter': '/FlateDecode', '/ID': [b'<edited out>', b'<edited out>'], '/Info': IndirectObject(613, 0), '/Root': IndirectObject(615, 0), '/Size': 614, '/Type': '/XRef', '/W': [1, 3, 0]}\r\n(0, 610) {'/Filter': '/FlateDecode', '/First': 6, '/N': 1, '/Type': '/ObjStm'}\r\n(0, 613) {'/CreationDate': \"D:20150730143930+10'00'\", '/Creator': '28C-1', '/ModDate': \"D:20150803093650+10'00'\", '/Producer': 'Develop ineo+ 280'}\r\n(0, 615) {'/Metadata': IndirectObject(608, 0), '/OpenAction': [IndirectObject(616, 0), '/Fit'], '/Pages': IndirectObject(612, 0), '/Type': '/Catalog'}\r\n(0, 608) {'/Subtype': '/XML', '/Type': '/Metadata'}\r\n(0, 609) {'/Filter': '/FlateDecode', '/First': 6, '/N': 1, '/Type': '/ObjStm'}\r\n(0, 612) {'/Count': 26, '/Kids': [IndirectObject(616, 0), IndirectObject(1, 0), IndirectObject(23, 0), IndirectObject(43, 0), IndirectObject(53, 0), IndirectObject(68, 0), IndirectObject(109, 0), IndirectObject(127, 0), IndirectObject(163, 0), IndirectObject(217, 0), IndirectObject(275, 0), IndirectObject(305, 0), IndirectObject(334, 0), IndirectObject(389, 0), IndirectObject(414, 0), IndirectObject(426, 0), IndirectObject(435, 0), IndirectObject(460, 0), IndirectObject(468, 0), IndirectObject(478, 0), IndirectObject(489, 0), IndirectObject(508, 0), IndirectObject(518, 0), IndirectObject(540, 0), IndirectObject(554, 0), IndirectObject(575, 0)], '/Type': '/Pages'}\r\n```\r\n\r\nso `pdf.resolvedObjects` is clearly changing somehow, in that the `__init__` method seems to be giving something incomplete. I can make a workable-ish workaround via:\r\n\r\n```\r\nIn [15]: pdf = PyPDF4.PdfFileReader('some_file.pdf')\r\n\r\nIn [16]: pdf._flatten()\r\n\r\nIn [17]: for key, val in pdf.resolvedObjects.items():\r\n    ...:     print(key, val)\r\n    ...:     \r\n(0, 634) {'/DecodeParms': {'/Columns': 3, '/Predictor': 12}, '/Filter': '/FlateDecode', '/ID': [b'<edited out>', b'<edited out>'], '/Index': [614, 22], '/Info': IndirectObject(613, 0), '/Prev': 1820112, '/Root': IndirectObject(615, 0), '/Size': 636, '/Type': '/XRef', '/W': [1, 2, 0]}\r\n(0, 611) {'/DecodeParms': {'/Columns': 4, '/Predictor': 12}, '/Filter': '/FlateDecode', '/ID': [b'<edited out>', b'<edited out>'], '/Info': IndirectObject(613, 0), '/Root': IndirectObject(615, 0), '/Size': 614, '/Type': '/XRef', '/W': [1, 3, 0]}\r\n(0, 615) {'/Metadata': IndirectObject(608, 0), '/OpenAction': [IndirectObject(616, 0), '/Fit'], '/Pages': IndirectObject(612, 0), '/Type': '/Catalog'}\r\n(0, 609) {'/Filter': '/FlateDecode', '/First': 6, '/N': 1, '/Type': '/ObjStm'}\r\n(0, 612) {'/Count': 26, '/Kids': [IndirectObject(616, 0), IndirectObject(1, 0), IndirectObject(23, 0), IndirectObject(43, 0), IndirectObject(53, 0), IndirectObject(68, 0), IndirectObject(109, 0), IndirectObject(127, 0), IndirectObject(163, 0), IndirectObject(217, 0), IndirectObject(275, 0), IndirectObject(305, 0), IndirectObject(334, 0), IndirectObject(389, 0), IndirectObject(414, 0), IndirectObject(426, 0), IndirectObject(435, 0), IndirectObject(460, 0), IndirectObject(468, 0), IndirectObject(478, 0), IndirectObject(489, 0), IndirectObject(508, 0), IndirectObject(518, 0), IndirectObject(540, 0), IndirectObject(554, 0), IndirectObject(575, 0)], '/Type': '/Pages'}\r\n.\r\n.\r\n.\r\n```\r\nso I can at least do the tasks I need to do with the document, but making a call to `pdf.resolvedObjects` still raises an exception the first time I try to use it.\r\n\r\nAny idea what may be causing this? Would be more than happy to help with a fix if I can get some help tracking down the source of the problem."},"comment":{"url":"https://api.github.com/repos/claird/PyPDF4/issues/comments/417961707","html_url":"https://github.com/claird/PyPDF4/issues/11#issuecomment-417961707","issue_url":"https://api.github.com/repos/claird/PyPDF4/issues/11","id":417961707,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNzk2MTcwNw==","user":{"login":"DeliciousHair","id":6540809,"node_id":"MDQ6VXNlcjY1NDA4MDk=","avatar_url":"https://avatars2.githubusercontent.com/u/6540809?v=4","gravatar_id":"","url":"https://api.github.com/users/DeliciousHair","html_url":"https://github.com/DeliciousHair","followers_url":"https://api.github.com/users/DeliciousHair/followers","following_url":"https://api.github.com/users/DeliciousHair/following{/other_user}","gists_url":"https://api.github.com/users/DeliciousHair/gists{/gist_id}","starred_url":"https://api.github.com/users/DeliciousHair/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DeliciousHair/subscriptions","organizations_url":"https://api.github.com/users/DeliciousHair/orgs","repos_url":"https://api.github.com/users/DeliciousHair/repos","events_url":"https://api.github.com/users/DeliciousHair/events{/privacy}","received_events_url":"https://api.github.com/users/DeliciousHair/received_events","type":"User","site_admin":false},"created_at":"2018-09-02T21:40:30Z","updated_at":"2018-09-02T21:40:30Z","author_association":"NONE","body":"Ah yes, I think you've found the culprit--seems to work as it should in 2.7.\r\n\r\nAlright then, that means that the problem is 2 vs. 3 thing buried somewhere in `PdfFileReader.read` method (called on line 1148 in `__init__`) which uses `cacheIndirectObject` (among other things) to populate `self. resolvedObjects`.\r\n\r\nTime to put on my detective hat I guess, that is a particularly gruesome block of code, but at least I have a hint of what's going on now."}}
{"actor":{"display_login":"DeliciousHair"}}