knowah/PyPDF2 — pull request #13 by jpvanhal (2013-06-14 08:11:56+00:00)
Title: Removed duplicate Destination class

I was experimenting with `PdfFileMerger` and when I tried to
write the data to a file the following exception was raised:

Traceback (most recent call last):
File "pypdf2/PyPDF2/merger.py", line 194, in write
self._write_bookmarks()
File "pypdf2/PyPDF2/merger.py", line 280, in _write_bookmarks
self._write_bookmarks(b, last_added)
File "pypdf2/PyPDF2/merger.py", line 292, in _write_bookmarks
last_added = self.output.addBookmarkDestination(b, parent)
File "pypdf2/PyPDF2/pdf.py", line 442, in addBookmarkDestination
parent.addChild(destRef, self)
AttributeError: 'Destination' object has no attribute 'addChild'

After debugging this for a while I noticed that there are two
different `Destination` classes in PyPDF2 defined in the following
modules: `PyPDF2.generic` and `PyPDF2.pdf`. The difference between
them is that the one defined in `generic` module inherits from
`TreeObject` and has a few extra methods (`getDestArray` and
`writeToStream`) whereas the one defined in `pdf` modules inherits
from `DictionaryObject`.

The `addBookmarkDestination` method expects that `parent` has
`addChild` method, which in turn is defined in `TreeObject` class.
Thus, in order to fix this issue, I removed `Destination` class
defined in `PyPDF2.pdf` module.